aboutsummaryrefslogtreecommitdiffstats
path: root/src/entities.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2015-11-30 08:47:07 -0500
committerClyne Sullivan <tullivan99@gmail.com>2015-11-30 08:47:07 -0500
commit45bca98b792f8ced1a57ef8c5beed2a90a79d47f (patch)
tree0ac3026c2a9bac4037cfe9003f532eca02db92f0 /src/entities.cpp
parentfbe1b6c3a0a3427111577e6b77600f5669012583 (diff)
switched to 100% new/delete
Diffstat (limited to 'src/entities.cpp')
-rw-r--r--src/entities.cpp30
1 files changed, 11 insertions, 19 deletions
diff --git a/src/entities.cpp b/src/entities.cpp
index 97b4d35..4e582c9 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -33,7 +33,7 @@ void Entity::spawn(float x, float y){ //spawns the entity you pass to it based o
}
}
- name = (char*)malloc(16);
+ name = new char[16]; //(char*)malloc(16);
getName();
}
@@ -100,21 +100,13 @@ Mob::Mob(int sub){
inv = new Inventory(NPC_INV_SIZE);
}
-Object::Object(int id):identifier(id){
- type = OBJECTT;
- alive = true;
- near = false;
- width = HLINE * 8;
- height = HLINE * 8;
-
- maxHealth = health = 1;
- //tex = new Texturec(1, item[id].textureLoc);
-
- questObject = false;
- pickupDialog="\0";
-}
-
-Object::Object(int id, bool qo, char *pd):identifier(id),questObject(qo),pickupDialog(pd){
+Object::Object(ITEM_ID id, bool qo, const char *pd){
+ identifier = id;
+ questObject = qo;
+
+ pickupDialog = new char[strlen(pd)+1];
+ strcpy(pickupDialog,pd);
+
type = OBJECTT;
alive = true;
near = false;
@@ -122,7 +114,7 @@ Object::Object(int id, bool qo, char *pd):identifier(id),questObject(qo),pickupD
height = HLINE * 8;
maxHealth = health = 1;
- //tex = new Texturec(1, item[id].textureLoc);
+ tex = new Texturec(1,getItemTexturePath(id));
}
@@ -218,7 +210,7 @@ NOPE:
void Entity::getName(){
rewind(names);
- char buf,*bufs = (char *)malloc(16);
+ char buf,*bufs = new char[16]; //(char *)malloc(16);
int tempNum,max = 0;
for(;!feof(names);max++){
fgets(bufs,16,(FILE*)names);
@@ -245,7 +237,7 @@ void Entity::getName(){
bufs[strlen(bufs)-1] = '\0';
strcpy(name,bufs);
}
- free(bufs);
+ delete[] bufs; //free(bufs);
}
void Player::interact(){ //the function that will cause the player to search for things to interact with