Refactoring of majorType, maintype and subType
authorbenblan <benblan@3ce38193-f967-438d-acd5-fc4e68e0da95>
Tue, 8 Jul 2014 08:03:14 +0000 (08:03 +0000)
committerbenblan <benblan@3ce38193-f967-438d-acd5-fc4e68e0da95>
Tue, 8 Jul 2014 08:03:14 +0000 (08:03 +0000)
- majorType is now MapObject::nature
- maintype has been dispatched in subclasses of MapObject and renamed in type
- subtype has been moved to Statics

17 files changed:
freesynd/branches/rework-actions/src/agent.cpp
freesynd/branches/rework-actions/src/mapobject.cpp
freesynd/branches/rework-actions/src/mapobject.h
freesynd/branches/rework-actions/src/menus/gameplaymenu.cpp
freesynd/branches/rework-actions/src/menus/minimaprenderer.cpp
freesynd/branches/rework-actions/src/mission.cpp
freesynd/branches/rework-actions/src/mission.h
freesynd/branches/rework-actions/src/missionmanager.cpp
freesynd/branches/rework-actions/src/model/shot.cpp
freesynd/branches/rework-actions/src/model/shot.h
freesynd/branches/rework-actions/src/ped.cpp
freesynd/branches/rework-actions/src/ped.h
freesynd/branches/rework-actions/src/pedmanager.cpp
freesynd/branches/rework-actions/src/vehicle.cpp
freesynd/branches/rework-actions/src/vehicle.h
freesynd/branches/rework-actions/src/weapon.cpp
freesynd/branches/rework-actions/src/weapon.h

index 0125b3d8bca75b5da9792a5e7f3fc7b3f5a92d22..f9019554067996cd28b8bf5e0d2286bb11f79151 100644 (file)
@@ -82,7 +82,7 @@ bool Agent::saveToFile(PortableFile &file) {
     file.write32(nb);
     for (int wIndex = 0; wIndex < numWeapons(); wIndex++) {
         WeaponInstance *pWinst = weapon(wIndex);
-        file.write32(pWinst->getMainType());
+        file.write32(pWinst->getWeaponType());
         file.write32(pWinst->ammoRemaining());
     }
     return true;
index 4fcf9f6506ca360054c6abdf462dff51f28482bd..dabd4fe99bf625703bbc286d155f8f3d8c5526c7 100644 (file)
 uint32 MapObject::debugIdCnt = 0;
 #endif
 
-MapObject::MapObject(int m):size_x_(1), size_y_(1), size_z_(2),
+const int Static::kStaticSubtype1 = 0;
+const int Static::kStaticSubtype2 = 2;
+
+MapObject::MapObject(int m, ObjectNature nature):size_x_(1), size_y_(1), size_z_(2),
     map_(m), frame_(0), elapsed_carry_(0),
-    frames_per_sec_(8), sub_type_(0), main_type_(0),
-    major_type_(MapObject::mjt_Undefined), dir_(0),
+    frames_per_sec_(8),
+    dir_(0),
     time_show_anim_(-1), time_showing_anim_(-1),
     is_ignored_(false), is_frame_drawn_(false),
     state_(0xFFFFFFFF)
@@ -46,6 +49,7 @@ MapObject::MapObject(int m):size_x_(1), size_y_(1), size_z_(2),
 #ifdef _DEBUG
     debugId_ = ++debugIdCnt;
 #endif
+    nature_ = nature; 
 }
 
 int MapObject::screenX()
@@ -433,8 +437,8 @@ void MapObject::offzOnStairs(uint8 twd) {
  * \param t_show
  * \param managed True means object is destroyed by another object than Mission
  */
-SFXObject::SFXObject(int m, int type, int t_show, bool managed) : MapObject(m) {
-    main_type_ = type;
+SFXObject::SFXObject(int m, SfxTypeEnum type, int t_show, bool managed) : MapObject(m, kNatureUndefined) {
+    type_ = type;
     managed_ = managed;
     draw_all_frames_ = true;
     loopAnimation_ = false;
@@ -508,7 +512,7 @@ bool SFXObject::animate(int elapsed) {
 
     if (is_frame_drawn_) {
         bool changed = draw_all_frames_ ? MapObject::animate(elapsed) : false;
-        if (main_type_ == SFXObject::sfxt_ExplosionBall) {
+        if (type_ == SFXObject::sfxt_ExplosionBall) {
             int z = tile_z_ * 128 + off_z_;
             // 250 per sec
             z += ((elapsed + elapsed_left_) >> 2);
@@ -534,7 +538,7 @@ bool SFXObject::animate(int elapsed) {
 }
 
 void SFXObject::correctZ() {
-    if (main_type_ == SFXObject::sfxt_ExplosionBall) {
+    if (type_ == SFXObject::sfxt_ExplosionBall) {
         int z = tile_z_ * 128 + off_z_;
         z += 512;
         if (z > (g_Session.getMission()->mmax_z_ - 1) * 128)
@@ -550,13 +554,13 @@ void SFXObject::reset() {
     elapsed_left_ = 0;
 }
 
-ShootableMapObject::ShootableMapObject(int m):MapObject(m)
+ShootableMapObject::ShootableMapObject(int m, ObjectNature nature):MapObject(m, nature)
 {
     rcv_damage_def_ = MapObject::ddmg_Invulnerable;
 }
 
-ShootableMovableMapObject::
-ShootableMovableMapObject(int m):ShootableMapObject(m),
+ShootableMovableMapObject::ShootableMovableMapObject(int m, ObjectNature nature):
+    ShootableMapObject(m, nature),
 speed_(0), base_speed_(0), dist_to_pos_(0)
 {
 }
@@ -704,14 +708,14 @@ Static *Static::loadInstance(uint8 * data, int m)
             if (gamdata->orientation == 0x00 || gamdata->orientation == 0x80
                 || gamdata->orientation == 0x7E || gamdata->orientation == 0xFE) {
                 s = new Door(m, baseanim, baseanim + 2, baseanim + 4, baseanim + 6);
-                s->setSubType(0);
+                s->setSubType(kStaticSubtype1);
                 s->setSizeX(256);
                 s->setSizeY(1);
                 s->setSizeZ(196);
             } else {
                 baseanim++;
                 s = new Door(m, baseanim, baseanim + 2, baseanim + 4, baseanim + 6);
-                s->setSubType(2);
+                s->setSubType(kStaticSubtype2);
                 s->setSizeX(1);
                 s->setSizeY(256);
                 s->setSizeZ(196);
@@ -721,14 +725,14 @@ Static *Static::loadInstance(uint8 * data, int m)
             if (gamdata->orientation == 0x00 || gamdata->orientation == 0x80
                 || gamdata->orientation == 0x7E || gamdata->orientation == 0xFE) {
                 s = new Door(m, baseanim, baseanim + 2, baseanim + 4, baseanim + 6);
-                s->setSubType(0);
+                s->setSubType(kStaticSubtype1);
                 s->setSizeX(256);
                 s->setSizeY(1);
                 s->setSizeZ(196);
             } else {
                 baseanim++;
                 s = new Door(m, baseanim, baseanim + 2, baseanim + 4, baseanim + 6);
-                s->setSubType(2);
+                s->setSubType(kStaticSubtype2);
                 s->setSizeX(1);
                 s->setSizeY(256);
                 s->setSizeZ(196);
@@ -738,14 +742,14 @@ Static *Static::loadInstance(uint8 * data, int m)
             if (gamdata->orientation == 0x00 || gamdata->orientation == 0x80
                 || gamdata->orientation == 0x7E || gamdata->orientation == 0xFE) {
                 s = new Door(m, baseanim, baseanim + 2, baseanim + 4, baseanim + 6);
-                s->setSubType(0);
+                s->setSubType(kStaticSubtype1);
                 s->setSizeX(256);
                 s->setSizeY(1);
                 s->setSizeZ(196);
             } else {
                 baseanim++;
                 s = new Door(m, baseanim, baseanim + 2, baseanim + 4, baseanim + 6);
-                s->setSubType(2);
+                s->setSubType(kStaticSubtype2);
                 s->setSizeX(1);
                 s->setSizeY(256);
                 s->setSizeZ(196);
@@ -756,14 +760,14 @@ Static *Static::loadInstance(uint8 * data, int m)
             if (gamdata->orientation == 0x00 || gamdata->orientation == 0x80
                 || gamdata->orientation == 0x7E || gamdata->orientation == 0xFE) {
                 s = new Door(m, baseanim, baseanim + 2, baseanim + 4, baseanim + 6);
-                s->setSubType(0);
+                s->setSubType(kStaticSubtype1);
                 s->setSizeX(256);
                 s->setSizeY(1);
                 s->setSizeZ(196);
             } else {
                 baseanim++;
                 s = new Door(m, baseanim, baseanim + 2, baseanim + 4, baseanim + 6);
-                s->setSubType(2);
+                s->setSubType(kStaticSubtype2);
                 s->setSizeX(1);
                 s->setSizeY(256);
                 s->setSizeZ(196);
@@ -779,12 +783,12 @@ Static *Static::loadInstance(uint8 * data, int m)
             // open window
             s = new WindowObj(m, curanim - 2, curanim, curanim + 2, curanim + 4);
             if (gamdata->orientation == 0x00 || gamdata->orientation == 0x80) {
-                s->setSubType(0);
+                s->setSubType(kStaticSubtype1);
                 s->setSizeX(96);
                 s->setSizeY(4);
                 s->setSizeZ(96);
             } else {
-                s->setSubType(2);
+                s->setSubType(kStaticSubtype2);
                 s->setSizeX(4);
                 s->setSizeY(96);
                 s->setSizeZ(96);
@@ -797,12 +801,12 @@ Static *Static::loadInstance(uint8 * data, int m)
             // closed window
             s = new WindowObj(m, curanim, curanim + 2, curanim + 4, curanim + 6);
             if (gamdata->orientation == 0x00 || gamdata->orientation == 0x80) {
-                s->setSubType(0);
+                s->setSubType(kStaticSubtype1);
                 s->setSizeX(96);
                 s->setSizeY(4);
                 s->setSizeZ(96);
             } else {
-                s->setSubType(2);
+                s->setSubType(kStaticSubtype2);
                 s->setSizeX(4);
                 s->setSizeY(96);
                 s->setSizeZ(96);
@@ -849,8 +853,7 @@ Static *Static::loadInstance(uint8 * data, int m)
             break;
         case 0x1F:
             // advertisement on wall
-            s = new EtcObj(m, curanim, curanim, curanim);
-            s->setMainType(smt_Advertisement);
+            s = new EtcObj(m, curanim, curanim, curanim, smt_Advertisement);
             s->setIsIgnored(true);
             break;
 
@@ -900,12 +903,12 @@ Static *Static::loadInstance(uint8 * data, int m)
             // 0x40,0xC0 weast - east = 2
             s = new LargeDoor(m, curanim, curanim + 1, curanim + 2);
             if (gamdata->orientation == 0x00 || gamdata->orientation == 0x80) {
-                s->setSubType(0);
+                s->setSubType(kStaticSubtype1);
                 s->setSizeX(384);
                 s->setSizeY(64);
                 s->setSizeZ(192);
             } else {
-                s->setSubType(2);
+                s->setSubType(kStaticSubtype2);
                 s->setSizeX(64);
                 s->setSizeY(384);
                 s->setSizeZ(192);
@@ -930,7 +933,7 @@ Static *Static::loadInstance(uint8 * data, int m)
         int z = READ_LE_UINT16(gamdata->mapposz) >> 7;
         int oz = gamdata->mapposz[0] & 0x7F;
         // trick to draw
-        if (s->getMainType() == Static::smt_Advertisement)
+        if (s->type() == Static::smt_Advertisement)
             z += 1;
 
         s->setPosition(gamdata->mapposx[1], gamdata->mapposy[1],
@@ -947,13 +950,10 @@ Static *Static::loadInstance(uint8 * data, int m)
     return s;
 }
 
-Door::Door(int m, int anim, int closingAnim, int openAnim, int openingAnim)
-: Static(m), anim_(anim), closing_anim_(closingAnim),open_anim_(openAnim),
-opening_anim_(openingAnim)
-{
+Door::Door(int m, int anim, int closingAnim, int openAnim, int openingAnim) :
+    Static(m, Static::smt_Door), anim_(anim), closing_anim_(closingAnim),
+        open_anim_(openAnim), opening_anim_(openingAnim) {
     state_ = Static::sttdoor_Closed;
-    major_type_ = MapObject::mjt_Static;
-    main_type_ = Static::smt_Door;
 }
 
 void Door::draw(int x, int y)
@@ -968,7 +968,7 @@ bool Door::animate(int elapsed, Mission *obj)
     int x = tileX();
     int y = tileY();
     int z = tileZ();
-    MapObject::MajorTypeEnum mt;
+    MapObject::ObjectNature nature;
     int si;
     char inc_rel = 0, rel_inc = 0;
     char *i = 0, *j = 0;
@@ -977,19 +977,19 @@ bool Door::animate(int elapsed, Mission *obj)
     bool changed = MapObject::animate(elapsed);
     switch(state_) {
         case Static::sttdoor_Open:
-            if (sub_type_ == 0) {
+            if (subType_ == kStaticSubtype1) {
                 i = &rel_inc;
                 j = &inc_rel;
-            } else if (sub_type_ == 2) {
+            } else if (subType_ == kStaticSubtype2) {
                 i = &inc_rel;
                 j = &rel_inc;
             }
             assert(i != 0 && j != 0);
             for(*i = 0; *i < 2; *i += 1) {
-                mt = MapObject::mjt_Ped; si = 0;
+                nature = MapObject::kNaturePed; si = 0;
                 do {
                     p = (PedInstance *)(obj->findAt(x + inc_rel,
-                        y + rel_inc, z, &mt, &si, true));
+                        y + rel_inc, z, &nature, &si, true));
                     if (!p && state_ == Static::sttdoor_Open && (!found)) {
                         state_ = Static::sttdoor_Closing;
                         is_ignored_ = false;
@@ -1004,19 +1004,19 @@ bool Door::animate(int elapsed, Mission *obj)
             }
             break;
         case Static::sttdoor_Closed:
-            if (sub_type_ == 0) {
+            if (subType_ == kStaticSubtype1) {
                 i = &rel_inc;
                 j = &inc_rel;
-            } else if (sub_type_ == 2) {
+            } else if (subType_ == kStaticSubtype2) {
                 i = &inc_rel;
                 j = &rel_inc;
             }
             assert(i != 0 && j != 0);
             *i = 1;
-            mt = MapObject::mjt_Ped; si = 0;
+            nature = MapObject::kNaturePed; si = 0;
             do {
                 p = (PedInstance *)(obj->findAt(x + inc_rel,
-                    y + rel_inc, z, &mt, &si, true));
+                    y + rel_inc, z, &nature, &si, true));
                 if (p && p->isAlive()) {
                     if (!found) {
                         state_ = Static::sttdoor_Opening;
@@ -1034,10 +1034,10 @@ bool Door::animate(int elapsed, Mission *obj)
                 }
             } while (p);
             *i = 0;
-            mt = MapObject::mjt_Ped; si = 0;
+            nature = MapObject::kNaturePed; si = 0;
             do {
                 p = (PedInstance *)(obj->findAt(x + inc_rel,
-                    y + rel_inc, z, &mt, &si, true));
+                    y + rel_inc, z, &nature, &si, true));
                 if (p && p->isAlive()) {
                     if (!found) {
                         state_ = Static::sttdoor_Opening;
@@ -1079,12 +1079,10 @@ bool Door::isPathBlocker()
 }
 
 
-LargeDoor::LargeDoor(int m, int anim, int closingAnim, int openingAnim):Static(m), anim_(anim),
-closing_anim_(closingAnim), opening_anim_(openingAnim)
-{
+LargeDoor::LargeDoor(int m, int anim, int closingAnim, int openingAnim):
+        Static(m, Static::smt_LargeDoor), anim_(anim),
+        closing_anim_(closingAnim), opening_anim_(openingAnim) {
     state_ = Static::sttdoor_Closed;
-    major_type_ = MapObject::mjt_Static;
-    main_type_ = Static::smt_LargeDoor;
 }
 
 void LargeDoor::draw(int x, int y)
@@ -1113,7 +1111,7 @@ bool LargeDoor::animate(int elapsed, Mission *obj)
     int x = tileX();
     int y = tileY();
     int z = tileZ();
-    MapObject::MajorTypeEnum mt;
+    MapObject::ObjectNature nature;
     int si;
     char inc_rel = 0, rel_inc = 0;
     char *i = 0, *j = 0;
@@ -1129,19 +1127,19 @@ bool LargeDoor::animate(int elapsed, Mission *obj)
     uint32 cur_state = state_;
     switch(state_) {
         case Static::sttdoor_Open:
-            if (sub_type_ == 0) {
+            if (subType_ == kStaticSubtype1) {
                 i = &rel_inc;
                 j = &inc_rel;
-            } else if (sub_type_ == 2) {
+            } else if (subType_ == kStaticSubtype2) {
                 i = &inc_rel;
                 j = &rel_inc;
             }
             assert(i != 0 && j != 0);
             *j = -1;
             for(*i = -2; *i < 3; (*i)++) {
-                mt = MapObject::mjt_Vehicle; si = 0;
+                nature = MapObject::kNatureVehicle; si = 0;
                 v = (VehicleInstance *)(obj->findAt(x + inc_rel,
-                    y + rel_inc,z, &mt, &si, true));
+                    y + rel_inc,z, &nature, &si, true));
                 if (!v && !found) {
                     state_ = Static::sttdoor_Closing;
                     is_ignored_ = false;
@@ -1154,9 +1152,9 @@ bool LargeDoor::animate(int elapsed, Mission *obj)
             }
             *j = 1;
             for(*i = -2; *i < 3; (*i)++) {
-                mt = MapObject::mjt_Vehicle; si = 0;
+                nature = MapObject::kNatureVehicle; si = 0;
                 v = (VehicleInstance *)(obj->findAt(x + inc_rel,
-                    y + rel_inc,z,&mt,&si,true));
+                    y + rel_inc,z,&nature,&si,true));
                 if (!v && !found) {
                     state_ = Static::sttdoor_Closing;
                     is_ignored_ = false;
@@ -1169,10 +1167,10 @@ bool LargeDoor::animate(int elapsed, Mission *obj)
             }
             *j = -1;
             for (*i = -1; *i <= 1; (*i)++ ) {
-                mt = MapObject::mjt_Ped; si = 0;
+                nature = MapObject::kNaturePed; si = 0;
                 do {
                     p = (PedInstance *)(obj->findAt(x + rel_inc,
-                        y + inc_rel, z, &mt, &si, true));
+                        y + inc_rel, z, &nature, &si, true));
                     if (p) {
                         found_peds.push_back(p);
                         if (!found && p->hasAccessCard()) {
@@ -1185,10 +1183,10 @@ bool LargeDoor::animate(int elapsed, Mission *obj)
             }
             *j = 1;
             for (*i = -1; *i <= 1; (*i)++ ) {
-                mt = MapObject::mjt_Ped; si = 0;
+                nature = MapObject::kNaturePed; si = 0;
                 do {
                     p = (PedInstance *)(obj->findAt(x + rel_inc,
-                        y + inc_rel, z, &mt, &si, true));
+                        y + inc_rel, z, &nature, &si, true));
                     if (p) {
                         found_peds.push_back(p);
                         if (!found && p->hasAccessCard()) {
@@ -1201,10 +1199,10 @@ bool LargeDoor::animate(int elapsed, Mission *obj)
             }
             *j = 0;
             for (*i = -1; *i <= 1; (*i)++ ) {
-                mt = MapObject::mjt_Ped; si = 0;
+                nature = MapObject::kNaturePed; si = 0;
                 do {
                     p = (PedInstance *)(obj->findAt(x + rel_inc,
-                        y + inc_rel, z, &mt, &si, true));
+                        y + inc_rel, z, &nature, &si, true));
                     if (p) {
                         found_peds_mid.push_back(p);
                         if (!found && p->hasAccessCard()) {
@@ -1234,10 +1232,10 @@ bool LargeDoor::animate(int elapsed, Mission *obj)
                     p->hold_on_.wayFree = 2;
                     p->hold_on_.tilex = x;
                     p->hold_on_.tiley = y;
-                    if (sub_type_ == 0) {
+                    if (subType_ == kStaticSubtype1) {
                         p->hold_on_.xadj = 1;
                         p->hold_on_.yadj = 0;
-                    } else if (sub_type_ == 2) {
+                    } else if (subType_ == kStaticSubtype2) {
                         p->hold_on_.xadj = 0;
                         p->hold_on_.yadj = 1;
                     }
@@ -1258,11 +1256,11 @@ bool LargeDoor::animate(int elapsed, Mission *obj)
             }
             break;
         case Static::sttdoor_Closed:
-            if (sub_type_ == 0) {
+            if (subType_ == kStaticSubtype1) {
                 i = &rel_inc;
                 j = &inc_rel;
                 sign = 1;
-            } else if (sub_type_ == 2) {
+            } else if (subType_ == kStaticSubtype2) {
                 i = &inc_rel;
                 j = &rel_inc;
                 sign = -1;
@@ -1270,9 +1268,9 @@ bool LargeDoor::animate(int elapsed, Mission *obj)
             assert(i != 0 && j != 0);
             *j = -1 * sign;
             *i = -2;
-            mt = MapObject::mjt_Vehicle; si = 0;
+            nature = MapObject::kNatureVehicle; si = 0;
             v = (VehicleInstance *)(obj->findAt(x + inc_rel,
-                y + rel_inc,z, &mt, &si,true));
+                y + rel_inc,z, &nature, &si,true));
             if (v) {
                 if (!found) {
                     state_ = Static::sttdoor_Opening;
@@ -1284,9 +1282,9 @@ bool LargeDoor::animate(int elapsed, Mission *obj)
             }
             *j = 1 * sign;
             *i = 2;
-            mt = MapObject::mjt_Vehicle; si = 0;
+            nature = MapObject::kNatureVehicle; si = 0;
             v = (VehicleInstance *)(obj->findAt(x + inc_rel,
-                y + rel_inc,z, &mt, &si,true));
+                y + rel_inc,z, &nature, &si,true));
             if (v) {
                 if (!found) {
                     state_ = Static::sttdoor_Opening;
@@ -1298,10 +1296,10 @@ bool LargeDoor::animate(int elapsed, Mission *obj)
             }
             *j = -1;
             for (*i = -1; *i <= 1; (*i)++ ) {
-                mt = MapObject::mjt_Ped; si = 0;
+                nature = MapObject::kNaturePed; si = 0;
                 do {
                     p = (PedInstance *)(obj->findAt(x + rel_inc,
-                        y + inc_rel, z, &mt, &si, true));
+                        y + inc_rel, z, &nature, &si, true));
                     if (p) {
                         found_peds.push_back(p);
                         if (!found && p->hasAccessCard()) {
@@ -1314,10 +1312,10 @@ bool LargeDoor::animate(int elapsed, Mission *obj)
             }
             *j = 1;
             for (*i = -1; *i <= 1; (*i)++ ) {
-                mt = MapObject::mjt_Ped; si = 0;
+                nature = MapObject::kNaturePed; si = 0;
                 do {
                     p = (PedInstance *)(obj->findAt(x + rel_inc,
-                        y + inc_rel, z, &mt, &si, true));
+                        y + inc_rel, z, &nature, &si, true));
                     if (p) {
                         found_peds.push_back(p);
                         if (!found && p->hasAccessCard()) {
@@ -1336,10 +1334,10 @@ bool LargeDoor::animate(int elapsed, Mission *obj)
                 p->hold_on_.wayFree = set_wayFree;
                 p->hold_on_.tilex = x;
                 p->hold_on_.tiley = y;
-                if (sub_type_ == 0) {
+                if (subType_ == kStaticSubtype1) {
                     p->hold_on_.xadj = 1;
                     p->hold_on_.yadj = 0;
-                } else if (sub_type_ == 2) {
+                } else if (subType_ == kStaticSubtype2) {
                     p->hold_on_.xadj = 0;
                     p->hold_on_.yadj = 1;
                 }
@@ -1359,11 +1357,11 @@ bool LargeDoor::animate(int elapsed, Mission *obj)
                 state_ = Static::sttdoor_Open;
                 is_ignored_ = true;
             }
-            if (sub_type_ == 0) {
+            if (subType_ == kStaticSubtype1) {
                 i = &rel_inc;
                 j = &inc_rel;
                 sign = 1;
-            } else if (sub_type_ == 2) {
+            } else if (subType_ == kStaticSubtype2) {
                 i = &inc_rel;
                 j = &rel_inc;
                 sign = -1;
@@ -1372,28 +1370,28 @@ bool LargeDoor::animate(int elapsed, Mission *obj)
             *j = -1 * sign;
             *i = -2;
             set_wayFree = state_ == Static::sttdoor_Opening ? 1 : 2;
-            mt = MapObject::mjt_Vehicle; si = 0;
+            nature = MapObject::kNatureVehicle; si = 0;
             v = (VehicleInstance *)(obj->findAt(x + inc_rel,
-                y + rel_inc,z, &mt, &si,true));
+                y + rel_inc,z, &nature, &si,true));
             if (v) {
                 v->hold_on_.wayFree = 1;
                 v->hold_on_.pathBlocker = this;
             }
             *j = 1 * sign;
             *i = 2;
-            mt = MapObject::mjt_Vehicle; si = 0;
+            nature = MapObject::kNatureVehicle; si = 0;
             v = (VehicleInstance *)(obj->findAt(x + inc_rel,
-                y + rel_inc,z, &mt, &si,true));
+                y + rel_inc,z, &nature, &si,true));
             if (v) {
                 v->hold_on_.wayFree = 1;
                 v->hold_on_.pathBlocker = this;
             }
             *j = -1;
             for (*i = -1; *i <= 1; (*i)++ ) {
-                mt = MapObject::mjt_Ped; si = 0;
+                nature = MapObject::kNaturePed; si = 0;
                 do {
                     p = (PedInstance *)(obj->findAt(x + rel_inc,
-                        y + inc_rel, z, &mt, &si, true));
+                        y + inc_rel, z, &nature, &si, true));
                     if (p) {
                         found_peds.push_back(p);
                     }
@@ -1401,10 +1399,10 @@ bool LargeDoor::animate(int elapsed, Mission *obj)
             }
             *j = 1;
             for (*i = -1; *i <= 1; (*i)++ ) {
-                mt = MapObject::mjt_Ped; si = 0;
+                nature = MapObject::kNaturePed; si = 0;
                 do {
                     p = (PedInstance *)(obj->findAt(x + rel_inc,
-                        y + inc_rel, z, &mt, &si, true));
+                        y + inc_rel, z, &nature, &si, true));
                     if (p) {
                         found_peds.push_back(p);
                     }
@@ -1417,10 +1415,10 @@ bool LargeDoor::animate(int elapsed, Mission *obj)
                 p->hold_on_.wayFree = set_wayFree;
                 p->hold_on_.tilex = x;
                 p->hold_on_.tiley = y;
-                if (sub_type_ == 0) {
+                if (subType_ == kStaticSubtype1) {
                     p->hold_on_.xadj = 1;
                     p->hold_on_.yadj = 0;
-                } else if (sub_type_ == 2) {
+                } else if (subType_ == kStaticSubtype2) {
                     p->hold_on_.xadj = 0;
                     p->hold_on_.yadj = 1;
                 }
@@ -1440,13 +1438,11 @@ bool LargeDoor::isPathBlocker()
 }
 
 
-Tree::Tree(int m, int anim, int burningAnim, int damagedAnim) : Static(m),
-anim_(anim), burning_anim_(burningAnim), damaged_anim_(damagedAnim)
-{
+Tree::Tree(int m, int anim, int burningAnim, int damagedAnim) :
+        Static(m, Static::smt_Tree), anim_(anim), burning_anim_(burningAnim),
+        damaged_anim_(damagedAnim) {
     rcv_damage_def_ = MapObject::ddmg_StaticTree;
-    major_type_ = MapObject::mjt_Static;
     state_ = Static::stttree_Healthy;
-    main_type_ = Static::smt_Tree;
 }
 
 void Tree::draw(int x, int y)
@@ -1494,14 +1490,11 @@ bool Tree::handleDamage(ShootableMapObject::DamageInflictType *d) {
     return true;
 }
 
-WindowObj::WindowObj(int m, int anim, int openAnim,
-int breakingAnim, int damagedAnim) : Static(m),
-anim_(anim), open_anim_(openAnim), breaking_anim_(breakingAnim),
-damaged_anim_(damagedAnim)
-{
+WindowObj::WindowObj(int m, int anim, int openAnim, int breakingAnim,
+                     int damagedAnim) :
+        Static(m, Static::smt_Window), anim_(anim), open_anim_(openAnim),
+        breaking_anim_(breakingAnim), damaged_anim_(damagedAnim) {
     rcv_damage_def_ = MapObject::ddmg_StaticWindow;
-    major_type_ = MapObject::mjt_Static;
-    main_type_ = Static::smt_Window;
 }
 
 bool WindowObj::animate(int elapsed, Mission *obj) {
@@ -1536,12 +1529,10 @@ bool WindowObj::handleDamage(ShootableMapObject::DamageInflictType *d) {
     return true;
 }
 
-EtcObj::EtcObj(int m, int anim, int burningAnim, int damagedAnim) : Static(m),
-anim_(anim), burning_anim_(burningAnim), damaged_anim_(damagedAnim)
-{
+EtcObj::EtcObj(int m, int anim, int burningAnim, int damagedAnim, StaticType type) :
+        Static(m, type), anim_(anim), burning_anim_(burningAnim),
+        damaged_anim_(damagedAnim) {
     rcv_damage_def_ = MapObject::ddmg_StaticGeneral;
-    major_type_ = MapObject::mjt_Static;
-    main_type_ = -1;
 }
 
 void EtcObj::draw(int x, int y)
@@ -1550,11 +1541,8 @@ void EtcObj::draw(int x, int y)
     g_App.gameSprites().drawFrame(anim_, frame_, x, y);
 }
 
-NeonSign::NeonSign(int m, int anim):Static(m),
-anim_(anim)
-{
-    major_type_ = MapObject::mjt_Static;
-    main_type_ = Static::smt_NeonSign;
+NeonSign::NeonSign(int m, int anim) : Static(m, Static::smt_NeonSign) {
+    anim_ = anim;
 }
 
 void NeonSign::draw(int x, int y)
@@ -1563,13 +1551,11 @@ void NeonSign::draw(int x, int y)
     g_App.gameSprites().drawFrame(anim_, frame_, x, y);
 }
 
-Semaphore::Semaphore(int m, int anim, int damagedAnim) : Static(m),
-anim_(anim), damaged_anim_(damagedAnim), elapsed_left_smaller_(0),
-elapsed_left_bigger_(0), up_down_(1)
-{
+Semaphore::Semaphore(int m, int anim, int damagedAnim) :
+        Static(m, Static::smt_Semaphore), anim_(anim),
+        damaged_anim_(damagedAnim), elapsed_left_smaller_(0),
+        elapsed_left_bigger_(0), up_down_(1) {
     rcv_damage_def_ = MapObject::ddmg_StaticGeneral;
-    major_type_ = MapObject::mjt_Static;
-    main_type_ = Static::smt_Semaphore;
     setFramesPerSec(2);
 }
 
@@ -1652,14 +1638,11 @@ void Semaphore::draw(int x, int y)
     g_App.gameSprites().drawFrame(anim_ +  state_, frame_, x, y);
 }
 
-AnimWindow::AnimWindow(int m, int anim) : Static(m),
-anim_(anim)
-{
+AnimWindow::AnimWindow(int m, int anim) : Static(m, smt_AnimatedWindow) {
     rcv_damage_def_ = MapObject::ddmg_StaticGeneral;
-    major_type_ = MapObject::mjt_Static;
-    main_type_ = smt_AnimatedWindow;
     setIsIgnored(true);
     setFramesPerSec(4);
+    anim_ = anim;
 }
 
 void AnimWindow::draw(int x, int y)
index fe4a52fe5010cf288b7d8e777e473d9bea24952e..e02f5a3d423569422aef03048460d249adb2135a 100644 (file)
@@ -41,9 +41,24 @@ class WeaponInstance;
  */
 class MapObject {
 public:
-    MapObject(int m);
+    /*!
+     * Express the nature of a MapObject.
+     */
+    enum ObjectNature {
+        kNatureUndefined = 0,
+        kNaturePed = 1,
+        kNatureWeapon = 2,
+        kNatureStatic = 4,
+        kNatureVehicle = 8
+    };
+
+public:
+    MapObject(int m, ObjectNature nature);
     virtual ~MapObject() {}
 
+    //! Return the nature of the object
+    ObjectNature nature() { return nature_; }
+
     virtual void draw(int x, int y) = 0;
     enum DamageType {
         dmg_None = 0x0000,
@@ -190,10 +205,6 @@ public:
 
     virtual bool animate(int elapsed);
 
-    void setSubType(int objSubType) { sub_type_ = objSubType; }
-    int getSubType() { return sub_type_; }
-    void setMainType(int objMainType) { main_type_ = objMainType; }
-    int getMainType() { return main_type_; }
     void setFramesPerSec(int framesPerSec)
     {
         frames_per_sec_ = framesPerSec;
@@ -253,17 +264,6 @@ public:
     bool isBlocker(toDefineXYZ * startXYZ, toDefineXYZ * endXYZ,
                double * inc_xyz);
 
-    typedef enum {
-        mjt_Undefined = 0,
-        mjt_Ped = 1,
-        mjt_Weapon = 2,
-        mjt_Static = 4,
-        mjt_Vehicle = 8
-    } MajorTypeEnum;
-
-    MajorTypeEnum majorType() { return major_type_; }
-    void setMajorType(MajorTypeEnum mt) { major_type_ = mt; }
-
     void setStateMasks(unsigned int state) {
         state_ = state;
     }
@@ -276,6 +276,8 @@ public:
 #endif
 
 protected:
+    //! the nature of this object
+    ObjectNature nature_;
     /*!
      * Tile based coordinates, tile_x_ and tile_y_ have 256
      * tile_z_ has 128 base
@@ -294,9 +296,6 @@ protected:
     int elapsed_carry_;
     //! how often this frame should be drawn per seccond
     int frames_per_sec_;
-    int sub_type_, main_type_;
-    //! 0 - not defined, 1 - ped, 2 - weapon, 4 - static, 8 - vehicle
-    MajorTypeEnum major_type_;
     DefDamageType rcv_damage_def_;
     //! objects direction
     int dir_;
@@ -326,7 +325,26 @@ private:
  */
 class SFXObject : public MapObject {
 public:
-    SFXObject(int m, int type, int t_show = 0, bool managed = false);
+    /*!
+     * Type of SfxObject.
+     */
+    enum SfxTypeEnum {
+        sfxt_Unknown = 0,
+        sfxt_BulletHit = 1,
+        sfxt_FlamerFire = 2,
+        sfxt_Smoke = 3,
+        sfxt_Fire_LongSmoke = 4,
+        sfxt_ExplosionFire = 5,
+        sfxt_ExplosionBall = 6,
+        sfxt_LargeFire = 7,
+        sfxt_SelArrow = 8,
+        sfxt_AgentFirst = 9,
+        sfxt_AgentSecond = 10,
+        sfxt_AgentThird = 11,
+        sfxt_AgentFourth = 12
+    };
+
+    SFXObject(int m, SfxTypeEnum type, int t_show = 0, bool managed = false);
     virtual ~SFXObject() {}
 
     bool sfxLifeOver() { return sfx_life_over_; }
@@ -346,23 +364,9 @@ public:
             frame_ = 0;
         }
     }
-
-    enum SfxTypeEnum {
-        sfxt_Unknown = 0,
-        sfxt_BulletHit = 1,
-        sfxt_FlamerFire = 2,
-        sfxt_Smoke = 3,
-        sfxt_Fire_LongSmoke = 4,
-        sfxt_ExplosionFire = 5,
-        sfxt_ExplosionBall = 6,
-        sfxt_LargeFire = 7,
-        sfxt_SelArrow = 8,
-        sfxt_AgentFirst = 9,
-        sfxt_AgentSecond = 10,
-        sfxt_AgentThird = 11,
-        sfxt_AgentFourth = 12
-    };
 protected:
+    /*! The type of SfxObject.*/
+    SfxTypeEnum type_;
     int anim_;
     bool sfx_life_over_;
     // to draw all frames or first frame only
@@ -402,7 +406,7 @@ public:
     };
 
 public:
-    ShootableMapObject(int m);
+    ShootableMapObject(int m, ObjectNature nature);
     virtual ~ShootableMapObject() {}
 
     int health() { return health_; }
@@ -491,7 +495,7 @@ public:
  */
 class ShootableMovableMapObject : public ShootableMapObject {
 public:
-    ShootableMovableMapObject(int m);
+    ShootableMovableMapObject(int m, ObjectNature nature);
     virtual ~ShootableMovableMapObject() {}
 
     void setSpeed(int new_speed) {
@@ -542,10 +546,35 @@ protected:
  * Static map object class.
  */
 class Static : public ShootableMapObject {
+public:
+    /*! Const for subtype 1 of Static.*/
+    static const int kStaticSubtype1;
+    /*! Const for subtype 2 of Static.*/
+    static const int kStaticSubtype2;
+
+    enum StaticType {
+        // NOTE: should be the same name as Class
+        smt_None = 0,
+        smt_Advertisement,
+        smt_Semaphore,
+        smt_Door,
+        smt_LargeDoor,
+        smt_Tree,
+        smt_Window,
+        smt_AnimatedWindow,
+        smt_NeonSign
+    };
 public:
     static Static *loadInstance(uint8 *data, int m);
     virtual ~Static() {}
 
+    //! Return the type of statics
+    StaticType type() { return type_; }
+    //! Set the sub type of statics
+    void setSubType(int objSubType) { subType_ = objSubType; }
+    //! Return the type of statics
+    int subType() { return subType_; }
+
     virtual bool animate(int elapsed, Mission *obj) {
         return MapObject::animate(elapsed);
     }
@@ -588,21 +617,18 @@ public:
         sttawnd_LightOn
     }stateAnimatedWindows;
 
-    typedef enum {
-        // NOTE: should be the same name as Class
-        smt_None = 0,
-        smt_Advertisement,
-        smt_Semaphore,
-        smt_Door,
-        smt_LargeDoor,
-        smt_Tree,
-        smt_Window,
-        smt_AnimatedWindow,
-        smt_NeonSign
-    }staticMainType;
+protected:
+    Static(int m, StaticType type) :
+            ShootableMapObject(m, MapObject::kNatureStatic) {
+        type_ = type;
+        subType_ = kStaticSubtype1;
+    }
 
 protected:
-    Static(int m):ShootableMapObject(m) {}
+    /*! Type of statics.*/
+    StaticType type_;
+    /*! Sub division for statics of same type.*/
+    int subType_;
 };
 
 /*!
@@ -674,7 +700,7 @@ protected:
  */
 class EtcObj : public Static {
 public:
-    EtcObj(int m, int anim, int burningAnim, int damagedAnim);
+    EtcObj(int m, int anim, int burningAnim, int damagedAnim, StaticType type = smt_None);
     virtual ~EtcObj() {}
 
     void draw(int x, int y);
index 3de2f17b9c09b6f7b684f0f87f031eff93dc6ade..8c25d38805d51847fbccf7a07262537f811f9383 100644 (file)
@@ -623,13 +623,13 @@ void GameplayMenu::handleMouseMotion(int x, int y, int state, const int modKeys)
     }
 
     if (target_) {
-        if (target_->majorType() == MapObject::mjt_Ped || 
-            target_->majorType() == MapObject::mjt_Vehicle) {
+        if (target_->nature() == MapObject::kNaturePed || 
+            target_->nature() == MapObject::kNatureVehicle) {
             if (inrange)
                 g_System.useTargetRedCursor();
             else
                 g_System.useTargetCursor();
-        } else if (target_->majorType() == MapObject::mjt_Weapon) {
+        } else if (target_->nature() == MapObject::kNatureWeapon) {
             g_System.usePickupCursor();
         }
     } else if (x > 128) {
@@ -775,7 +775,7 @@ void GameplayMenu::handleClickOnMap(int x, int y, int button, const int modKeys)
 
         if (target_) {
             printf("target id  : %i == majorType : %i\n",
-                target_->getDebugID(), target_->majorType());
+                target_->getDebugID(), target_->nature());
         }
         return;
     }
@@ -784,14 +784,14 @@ void GameplayMenu::handleClickOnMap(int x, int y, int button, const int modKeys)
     bool ctrl = (modKeys & KMD_CTRL) != 0;
     if (button == kMouseLeftButton) {
         if (target_) {
-            switch (target_->majorType()) {
-            case MapObject::mjt_Weapon:
+            switch (target_->nature()) {
+            case MapObject::kNatureWeapon:
                 selection_.pickupWeapon(dynamic_cast<WeaponInstance *>(target_), ctrl);
                 break;
-            case MapObject::mjt_Ped:
+            case MapObject::kNaturePed:
                 selection_.followPed(dynamic_cast<PedInstance *>(target_), ctrl);
                 break;
-            case MapObject::mjt_Vehicle:
+            case MapObject::kNatureVehicle:
                 selection_.enterOrLeaveVehicle(dynamic_cast<Vehicle *>(target_), ctrl);
                 break;
             default:
@@ -1191,7 +1191,7 @@ void GameplayMenu::drawMissionHint(int elapsed) {
     mission_hint_ += inc;
 
     bool inversed = false;
-    bool text_pw = (target_ && target_->majorType() == MapObject::mjt_Weapon
+    bool text_pw = (target_ && target_->nature() == MapObject::kNatureWeapon
         && target_->map() != -1);
 
     std::string str;
@@ -1286,7 +1286,7 @@ void GameplayMenu::drawWeaponSelectors() {
                     if (p->selectedWeapon() && p->selectedWeapon() == wi)
                         s += 40;
                 } else if (draw_pw) {
-                    if (target_ && target_->majorType() == MapObject::mjt_Weapon
+                    if (target_ && target_->nature() == MapObject::kNatureWeapon
                         && (mission_hint_ % 20) < 10
                         && target_->map() != -1)
                     {
index 8de3dca20352c61bbd9a17a20a7de410c2f809e3..097deed4ef649b859643a01493bd7a866ff50299 100644 (file)
@@ -573,7 +573,7 @@ void GamePlayMinimapRenderer::drawPedestrians(uint8 * a_minimap) {
                 uint8 borderColor = (mm_timer_ped.state()) ? fs_cmn::kColorLightGreen : fs_cmn::kColorBlack;
                 drawPedCircle(a_minimap, px, py, fs_cmn::kColorYellow, borderColor);
             } else {
-                switch (p_ped->getMainType())
+                switch (p_ped->type())
                 {
                 case PedInstance::m_tpPedestrian:
                 case PedInstance::m_tpCriminal:
index d3c30b3d59ab65177b103ebb08d31426f38e07f3..ce50e4c731334c59830591fd779044d55df4c0c0 100644 (file)
@@ -275,7 +275,7 @@ void Mission::addWeaponsFromPedToAgent(PedInstance* p, Agent* pAg)
         weapons_.erase(it);
         wi->deactivate();
         // auto-reload for pistol
-        if (wi->getMainType() == Weapon::Pistol)
+        if (wi->getWeaponType() == Weapon::Pistol)
             wi->setAmmoRemaining(wi->ammo());
         wi->resetWeaponUsedTime();
         pAg->addWeapon(wi);
@@ -292,7 +292,7 @@ void Mission::end()
         // civilians+police, more killed less happy
         // TODO: add money per every persuaded non-agent ped
         if (p->isDead()) {
-            switch (p->getMainType()) {
+            switch (p->type()) {
                 case PedInstance::m_tpAgent:
                     stats_.incrEnemyKilled();
                     break;
@@ -353,62 +353,62 @@ void Mission::addWeapon(WeaponInstance * w)
 }
 
 MapObject * Mission::findAt(int tilex, int tiley, int tilez,
-                            MapObject::MajorTypeEnum *majorT, int *searchIndex,
+                            MapObject::ObjectNature *nature, int *searchIndex,
                             bool only)
 {
-    switch(*majorT) {
-        case MapObject::mjt_Ped:
+    switch(*nature) {
+        case MapObject::kNaturePed:
             for (unsigned int i = *searchIndex; i < peds_.size(); i++)
                 if ((!peds_[i]->isIgnored()) && peds_[i]->tileX() == tilex
                     && peds_[i]->tileY() == tiley
                     && peds_[i]->tileZ() == tilez)
                 {
                     *searchIndex = i + 1;
-                    *majorT = MapObject::mjt_Ped;
+                    *nature = MapObject::kNaturePed;
                     return peds_[i];
                 }
             if(only)
                 return NULL;
             *searchIndex = 0;
-        case MapObject::mjt_Weapon:
+        case MapObject::kNatureWeapon:
             for (unsigned int i = *searchIndex; i < weapons_.size(); i++)
                 if ((!weapons_[i]->isIgnored()) && weapons_[i]->tileX() == tilex
                     && weapons_[i]->tileY() == tiley
                     && weapons_[i]->tileZ() == tilez)
                 {
                     *searchIndex = i + 1;
-                    *majorT = MapObject::mjt_Weapon;
+                    *nature = MapObject::kNatureWeapon;
                     return weapons_[i];
                 }
             if(only)
                 return NULL;
             *searchIndex = 0;
-        case MapObject::mjt_Static:
+        case MapObject::kNatureStatic:
             for (unsigned int i = *searchIndex; i < statics_.size(); i++)
                 if (statics_[i]->tileX() == tilex
                     && statics_[i]->tileY() == tiley
                     && statics_[i]->tileZ() == tilez)
                 {
                     *searchIndex = i + 1;
-                    *majorT = MapObject::mjt_Static;
+                    *nature = MapObject::kNatureStatic;
                     return statics_[i];
                 }
             if(only)
                 return NULL;
             *searchIndex = 0;
-        case MapObject::mjt_Vehicle:
+        case MapObject::kNatureVehicle:
             for (unsigned int i = *searchIndex; i < vehicles_.size(); i++)
                 if (vehicles_[i]->tileX() == tilex
                     && vehicles_[i]->tileY() == tiley
                     && vehicles_[i]->tileZ() == tilez)
                 {
                     *searchIndex = i + 1;
-                    *majorT = MapObject::mjt_Vehicle;
+                    *nature = MapObject::kNatureVehicle;
                     return vehicles_[i];
                 }
             break;
         default:
-            printf("undefined majortype %i", *majorT);
+            printf("undefined majortype %i", *nature);
             break;
     }
     return NULL;
@@ -476,16 +476,16 @@ bool Mission::setSurfaces() {
         it != statics_.end(); ++it)
     {
         Static *s = *it;
-        if (s->getMainType() == Static::smt_LargeDoor) {
+        if (s->type() == Static::smt_LargeDoor) {
             int indx = s->tileX() + s->tileY() * mmax_x_
                 + s->tileZ() * mmax_m_xy;
             mtsurfaces_[indx].twd = 0x00;
-            if (s->getSubType() == 0) {
+            if (s->subType() == Static::kStaticSubtype1) {
                 if (indx - 1 >= 0)
                     mtsurfaces_[indx - 1].twd = 0x00;
                 if (indx + 1 < mmax_m_all)
                     mtsurfaces_[indx + 1].twd = 0x00;
-            } else if (s->getSubType() == 2) {
+            } else if (s->subType() == Static::kStaticSubtype2) {
                 if (indx - mmax_x_ >= 0)
                     mtsurfaces_[indx - mmax_x_].twd = 0x00;
                 if (indx + mmax_x_ < mmax_m_all)
@@ -2825,7 +2825,7 @@ void Mission::getInRangeAll(toDefineXYZ * cp,
    std::vector<ShootableMapObject *> & targets, uint8 mask,
    bool checkTileOnly, double maxr)
 {
-    if (mask & MapObject::mjt_Ped) {
+    if (mask & MapObject::kNaturePed) {
         for (size_t i = 0; i < numPeds(); ++i) {
             ShootableMapObject *p = ped(i);
             if (!p->isIgnored() && p->isAlive())
@@ -2836,7 +2836,7 @@ void Mission::getInRangeAll(toDefineXYZ * cp,
                 }
         }
     }
-    if (mask & MapObject::mjt_Static) {
+    if (mask & MapObject::kNatureStatic) {
         for (size_t i = 0; i < numStatics(); ++i) {
             ShootableMapObject *st = statics(i);
             if (!st->isIgnored())
@@ -2847,7 +2847,7 @@ void Mission::getInRangeAll(toDefineXYZ * cp,
                 }
         }
     }
-    if (mask & MapObject::mjt_Vehicle) {
+    if (mask & MapObject::kNatureVehicle) {
         for (size_t i = 0; i < numVehicles(); ++i) {
             ShootableMapObject *v = vehicle(i);
             if (!v->isIgnored())
@@ -2858,7 +2858,7 @@ void Mission::getInRangeAll(toDefineXYZ * cp,
                 }
         }
     }
-    if (mask & MapObject::mjt_Weapon) {
+    if (mask & MapObject::kNatureWeapon) {
         for (size_t i = 0; i < numWeapons(); ++i) {
             ShootableMapObject *w = weapon(i);
             if (!w->isIgnored())
index 8d0ed55f6e69c098535195097843ddcd3491bccd..f24f814c00b8cea4fe4764a005c8ba11cb5bde65 100644 (file)
@@ -231,7 +231,7 @@ public:
     void end();
 
     MapObject * findAt(int tilex, int tiley, int tilez,
-        MapObject::MajorTypeEnum *majorT, int *searchIndex, bool only);
+        MapObject::ObjectNature *nature, int *searchIndex, bool only);
     bool setSurfaces();
     void clrSurfaces();
     bool getWalkable(MapTilePoint &mtp);
index fd7bad0fd749ba5c9fed12a6f3fefa53d55b401e..1970d669e1610c91ef0af570e1db9afc1103fae9 100644 (file)
@@ -504,10 +504,10 @@ VehicleInstance * MissionManager::createVehicleInstance(const LevelData::Cars &g
     int cur_anim = READ_LE_UINT16(gamdata.index_current_anim) - dir;
     //setVehicleBaseAnim(vehicleanim, cur_anim);
     vehicleanim->set_base_anims(cur_anim);
-    VehicleInstance *vehivle_new = new VehicleInstance(vehicleanim, map);
-    vehivle_new->setHealth(hp);
-    vehivle_new->setStartHealth(hp);
-    vehivle_new->setMainType(gamdata.sub_type);
+    VehicleInstance *vehicle_new = new VehicleInstance(vehicleanim, map);
+    vehicle_new->setHealth(hp);
+    vehicle_new->setStartHealth(hp);
+    vehicle_new->setType(gamdata.sub_type);
     switch (gamdata.sub_type) {
         case 0x01:
             // large armored
@@ -517,9 +517,9 @@ VehicleInstance * MissionManager::createVehicleInstance(const LevelData::Cars &g
             // it is actually base animation and they have 8 directions
             //setVehicleBaseAnim(vehicleanim, cur_anim - 12 + (dir >> 1));
             vehicleanim->set_base_anims(cur_anim - 12 + (dir >> 1));
-            vehivle_new->setStartHealth(0);
-            vehivle_new->setHealth(-1);
-            vehivle_new->setIsIgnored(true);
+            vehicle_new->setStartHealth(0);
+            vehicle_new->setHealth(-1);
+            vehicle_new->setIsIgnored(true);
             vehicleanim->set_animation_type(VehicleAnimation::kBurntAnim);
             break;
         case 0x05:
@@ -560,17 +560,17 @@ VehicleInstance * MissionManager::createVehicleInstance(const LevelData::Cars &g
 
     // TODO: the size should be adjusted on orientation/direction change
     // and it should be different per vehicle type
-    vehivle_new->setSizeX(256);
-    vehivle_new->setSizeY(256);
-    vehivle_new->setSizeZ(192);
+    vehicle_new->setSizeX(256);
+    vehicle_new->setSizeY(256);
+    vehicle_new->setSizeZ(192);
 
     int oz = gamdata.mapposz[0] & 0x7F;
-    vehivle_new->setPosition(gamdata.mapposx[1], gamdata.mapposy[1],
+    vehicle_new->setPosition(gamdata.mapposx[1], gamdata.mapposy[1],
                             z, gamdata.mapposx[0],
                             gamdata.mapposy[0], oz);
-    vehivle_new->setDirection(gamdata.orientation);
+    vehicle_new->setDirection(gamdata.orientation);
 
-    return vehivle_new;
+    return vehicle_new;
 }
 
 void MissionManager::createPeds(const LevelData::LevelDataAll &level_data, DataIndex &di, Mission *pMission) {
@@ -652,7 +652,7 @@ void MissionManager::createPeds(const LevelData::LevelDataAll &level_data, DataI
                 // adds the agent to the mission squad
                 pMission->getSquad()->setMember(i, p);
             } else {
-                unsigned int mt = p->getMainType();
+                unsigned int mt = p->type();
                 p->setObjGroupDef(mt);
                 if (mt == PedInstance::og_dmAgent) {
                     p->setObjGroupID(2);
index 3e670ca9e843e7eae830bce464ae687cae448a3c..960d7effb22cba4a84fd7db2bc26d1e745433e2d 100644 (file)
@@ -206,7 +206,7 @@ ShootableMapObject *InstantImpactShot::checkHitTarget(toDefineXYZ &originLocW, P
  * Some weapons can have no animations for an impact.
  */
 void InstantImpactShot::createImpactAnimation(Mission *pMission, ShootableMapObject * pTargetHit, PathNode &impactLocT) {
-    int impactAnimId = 
+    SFXObject::SfxTypeEnum impactAnimId = 
         (pTargetHit != NULL ? 
             dmg_.pWeapon->getWeaponClass()->impactAnims()->objectHit :
             dmg_.pWeapon->getWeaponClass()->impactAnims()->groundHit);
@@ -235,7 +235,7 @@ void Explosion::createExplosion(Mission *pMission, ShootableMapObject *pOwner, d
 
 void Explosion::createExplosion(Mission *pMission, ShootableMapObject *pOwner, const toDefineXYZ &location, double range, int dmgValue) {
     ShootableMapObject::DamageInflictType dmg;
-    if (pOwner && pOwner->majorType() == MapObject::mjt_Weapon) {
+    if (pOwner && pOwner->nature() == MapObject::kNatureWeapon) {
         // It's a bomb that exploded (other waepons do not explode)
         dmg.pWeapon = dynamic_cast<WeaponInstance *>(pOwner);
     } else {
index f0f44e535e622a65c6a744861a168bbcfac22072..5bd677d62bfc9b33fc2e35a10acbb72f0082e6af 100644 (file)
@@ -109,7 +109,7 @@ class Explosion : public Shot {
 
  private:
     /*! Type of animation for the explosion.*/
-    int rngDmgAnim_;
+    SFXObject::SfxTypeEnum rngDmgAnim_;
 };
 
 /*!
index ded4901a22ff14866da3e167ce8bd674657ca538..ed4b20ce02bd9c5ce3a41c32cfeaaa98aa985fa8 100644 (file)
@@ -177,6 +177,26 @@ int Ped::lastPersuadeFrame() {
     return g_App.gameSprites().lastFrame(persuade_anim_);
 }
 
+void PedInstance::setTypeFromValue(uint8 value) {
+    switch(value) {
+    case 0x01:
+        type_ = m_tpPedestrian;
+        break;
+    case 0x02:
+        type_ = m_tpAgent;
+        break;
+    case 0x04:
+        type_ = m_tpPolice;
+        break;
+    case 0x08:
+        type_ = m_tpGuard;
+        break;
+    case 0x10:
+        type_ = m_tpCriminal;
+        break;
+    }
+}
+
 bool PedInstance::switchActionStateTo(uint32 as) {
     uint32 prevState = state_;
     switch(as) {
@@ -711,7 +731,7 @@ bool PedInstance::animate(int elapsed, Mission *mission) {
                 if ((aqt->act_exec & PedInstance::ai_aAquireControl) != 0)
                 {
                     if (aqt->target.t_smo->isAlive()) {
-                        if (aqt->target.t_smo->majorType() == MapObject::mjt_Ped) {
+                        if (aqt->target.t_smo->nature() == MapObject::kNaturePed) {
                             if (selectRequiredWeapon(&aqt->multi_var.enemy_var.pw_to_use))
                             {
                                 WeaponInstance *wi = selectedWeapon();
@@ -726,8 +746,8 @@ bool PedInstance::animate(int elapsed, Mission *mission) {
                                     aqt->state |= 8;
                             } else
                                 aqt->state |= 8;
-                        } else if (aqt->target.t_smo->majorType()
-                                    == MapObject::mjt_Vehicle)
+                        } else if (aqt->target.t_smo->nature()
+                                    == MapObject::kNatureVehicle)
                         {
                             VehicleInstance *v = (VehicleInstance *)aqt->target.t_smo;
                             if (v->isAlive() && (state_
@@ -768,10 +788,10 @@ bool PedInstance::animate(int elapsed, Mission *mission) {
                 if ((aqt->act_exec & PedInstance::ai_aLoseControl) != 0)
                 {
                     if (aqt->state == 1) {
-                        if (aqt->target.t_smo->majorType() == MapObject::mjt_Ped) {
+                        if (aqt->target.t_smo->nature() == MapObject::kNaturePed) {
                             // TODO: but not now
-                        } else if (aqt->target.t_smo->majorType()
-                                   == MapObject::mjt_Vehicle)
+                        } else if (aqt->target.t_smo->nature()
+                                   == MapObject::kNatureVehicle)
                         {
                             VehicleInstance *v = (VehicleInstance *)aqt->target.t_smo;
                             if (v->isInsideVehicle(this)) {
@@ -812,7 +832,7 @@ bool PedInstance::animate(int elapsed, Mission *mission) {
                             // but goal reached
                             // TODO: projectile shot?
                             aqt->state |= 12;
-                        } else if ((aqt->target.t_smo->majorType() == MapObject::mjt_Ped
+                        } else if ((aqt->target.t_smo->nature() == MapObject::kNaturePed
                             ? aqt->multi_var.enemy_var.forced_shot
                             || !isFriendWith((PedInstance *)aqt->target.t_smo) : true)
                             && selectRequiredWeapon(&aqt->multi_var.enemy_var.pw_to_use))
@@ -867,7 +887,7 @@ bool PedInstance::animate(int elapsed, Mission *mission) {
                     } else if ((aqt->act_exec & PedInstance::ai_aWaitToStart) != 0)
                     {
                         //if (aqt->multi_var.time_var.desc == 0) {
-                            if ((aqt->target.t_smo->majorType() == MapObject::mjt_Ped
+                            if ((aqt->target.t_smo->nature() == MapObject::kNaturePed
                                 && !isHostileTo((PedInstance *)aqt->target.t_smo))
                                 || aqt->target.t_smo->isDead())
                             {
@@ -2036,7 +2056,7 @@ void PedInstance::showPath(int scrollX, int scrollY) {
     }
 }
 
-PedInstance::PedInstance(Ped *ped, int m) : ShootableMovableMapObject(m),
+PedInstance::PedInstance(Ped *ped, int m) : ShootableMovableMapObject(m, MapObject::kNaturePed),
     ped_(ped), action_grp_id_(1),
     desc_state_(PedInstance::pd_smUndefined),
     hostile_desc_(PedInstance::pd_smUndefined),
@@ -2049,7 +2069,6 @@ PedInstance::PedInstance(Ped *ped, int m) : ShootableMovableMapObject(m),
 {
     hold_on_.wayFree = 0;
     rcv_damage_def_ = MapObject::ddmg_Ped;
-    major_type_ = MapObject::mjt_Ped;
     state_ = PedInstance::pa_smNone;
     drop_actions_ = false;
     is_our_ = false;
@@ -2815,11 +2834,11 @@ bool PedInstance::isHostileTo(ShootableMapObject *obj,
 {
     bool isHostile = false;
 
-    if (obj->majorType() == MapObject::mjt_Vehicle) {
+    if (obj->nature() == MapObject::kNatureVehicle) {
         Vehicle *pVehicle = static_cast<Vehicle *>(obj);
         isHostile = pVehicle->containsHostilesForPed(
             this, hostile_desc_alt);
-    } else if (obj->majorType() == MapObject::mjt_Ped) {
+    } else if (obj->nature() == MapObject::kNaturePed) {
         PedInstance *pPed = static_cast<PedInstance *>(obj);
         if (!isFriendWith(pPed)) {
             // Ped is not a declared friend, check its group
@@ -2879,9 +2898,9 @@ void PedInstance::verifyHostilesFound(Mission *m) {
     {
         ShootableMapObject *smo = it->first;
         double distTo = 0;
-        if (smo->isDead() || (smo->majorType() == MapObject::mjt_Ped
+        if (smo->isDead() || (smo->nature() == MapObject::kNaturePed
             && isFriendWith((PedInstance *)(smo)))
-            || (smo->majorType() == MapObject::mjt_Vehicle
+            || (smo->nature() == MapObject::kNatureVehicle
             && ((VehicleInstance *)smo)->containsHostilesForPed(this, hostile_desc_))
             || (m->inRangeCPos(&cur_xyz, &smo, NULL, false, false,
             check_rng, &distTo) != 1))
index fa15fde7c2e6525b75d851b36de2ee18b2a01af4..b8bb1bb14b512258f6536f97d342d2a5b20afac0 100644 (file)
@@ -168,6 +168,16 @@ public:
     static const int kAgentMaxHealth;
     //! Default time for a ped between two shoots
     static const int kDefaultShootReactionTime;
+    /*!
+     * Type of Ped.
+     */
+    enum PedType {
+        m_tpPedestrian = 0x01,
+        m_tpAgent = 0x02,
+        m_tpPolice = 0x04,
+        m_tpGuard = 0x08,
+        m_tpCriminal = 0x10
+    } ;
 
     PedInstance(Ped *ped, int m);
     ~PedInstance();
@@ -177,8 +187,9 @@ public:
     bool isOurAgent() { return is_our_; }
     //! Sets if the agent is one of us or not
     void set_is_our(bool is_our) { is_our_ = is_our; }
-    
-    
+    //! Return the type of Ped
+    PedType type() { return type_; }
+    void setTypeFromValue(uint8 value);
 
     typedef enum {
         ad_NoAnimation,
@@ -202,14 +213,6 @@ public:
         ad_PersuadedAnim
     } AnimationDrawn;
 
-    typedef enum {
-        m_tpPedestrian = 0x01,
-        m_tpAgent = 0x02,
-        m_tpPolice = 0x04,
-        m_tpGuard = 0x08,
-        m_tpCriminal = 0x10
-    } mainPedType;
-
     //! MapObject::state_
     enum pedActionStateMasks {
         pa_smNone = 0x0,
@@ -876,6 +879,8 @@ protected:
     void insertHitAction(DamageInflictType &d);
 protected:
     Ped *ped_;
+    //! Type of Ped
+    PedType type_;
     //! If this flag is true, all actions should be dropped
     bool drop_actions_;
     std::vector <actionQueueGroupType> actions_queue_;
index c5ccdbbca7bb741362acc7647d53f7ba049c5512..5ce7146786768306fbed529f56a76e1944e744cb 100644 (file)
@@ -198,7 +198,7 @@ PedInstance *PedManager::loadInstance(const LevelData::People & gamdata, uint16
     newped->setPosition(gamdata.mapposx[1], gamdata.mapposy[1],
                         z, gamdata.mapposx[0],
                         gamdata.mapposy[0], oz);
-    newped->setMainType(gamdata.type_ped);
+    newped->setTypeFromValue(gamdata.type_ped);
 
     newped->setAllAdrenaLevels(gamdata.adrena_amount,
         gamdata.adrena_dependency, gamdata.adrena_effect);
index 378fff64a777fc1460b844d9fabd8300a7afaf82..eebd32e4a83ed911268b6ae2964bea8c3151d717 100644 (file)
@@ -113,7 +113,6 @@ VehicleInstance::VehicleInstance(VehicleAnimation * vehicle, int m):
 {
     hold_on_.wayFree = 0;
     rcv_damage_def_ = MapObject::ddmg_Vehicle;
-    major_type_ = MapObject::mjt_Vehicle;
 }
 
 bool VehicleInstance::animate(int elapsed)
index 0fd7b2741c8b1eb3c4a695b1b500149096f3cecc..3d0b0d8a5280ea3ca3e962143590d457687bfe8e 100644 (file)
@@ -80,13 +80,15 @@ protected:
  */
 class Vehicle : public ShootableMovableMapObject{
 public:
-    Vehicle(int m, bool drivable) : ShootableMovableMapObject(m) {
+    Vehicle(int m, bool drivable) : ShootableMovableMapObject(m, MapObject::kNatureVehicle) {
         isDrivable_ = drivable;
     }
 
     //! Return true if vehicle can be driven by a ped
     bool isDrivable() { return isDrivable_; }
 
+    void setType(uint8 type) { type_ = type; }
+
     //! Adds the given ped to the list of passengers
     virtual void addPassenger(PedInstance *p);
     //! Removes the passenger from the vehicle
@@ -107,6 +109,8 @@ protected:
 private:
     /*! A vehicle can be driven (car) or not (train).*/
     bool isDrivable_;
+    /*! Type of vehicle.*/
+    uint8 type_;
 };
 
 /*!
index 9fd9e0011c4aa0dc3e8aee2419f5fd768a008dc0..f583864b8ff02da821855d0604fedbd73c24e5e7 100644 (file)
@@ -256,17 +256,15 @@ WeaponInstance *WeaponInstance::createInstance(Weapon *pWeaponClass) {
     return new WeaponInstance(pWeaponClass);
 }
 
-WeaponInstance::WeaponInstance(Weapon * w) : ShootableMapObject(-1),
+WeaponInstance::WeaponInstance(Weapon * w) : ShootableMapObject(-1, MapObject::kNatureWeapon),
     bombSoundTimer(w->timeReload()), bombExplosionTimer(w->timeForShot()),
     flamerTimer_(180) {
     pWeaponClass_ = w;
     ammo_remaining_ = w->ammo();
     weapon_used_time_ = 0;
-    major_type_ = MapObject::mjt_Weapon;
     pOwner_ = NULL;
     activated_ = false;
     time_consumed_ = false;
-    main_type_ = w->getWeaponType();
     if (w->getWeaponType() == Weapon::TimeBomb
         || w->getWeaponType() == Weapon::Flamer)
     {
@@ -283,7 +281,7 @@ WeaponInstance::WeaponInstance(Weapon * w) : ShootableMapObject(-1),
 bool WeaponInstance::animate(int elapsed) {
 
     if (activated_) {
-        if (main_type_ == Weapon::EnergyShield) {
+        if (getWeaponType() == Weapon::EnergyShield) {
             if (ammo_remaining_ == 0)
                 return false;
             int tm_left = elapsed;
@@ -294,7 +292,7 @@ bool WeaponInstance::animate(int elapsed) {
             } else
                 ammo_remaining_ -= ammoused;
             return true;
-        } else if (main_type_ == Weapon::TimeBomb) {
+        } else if (getWeaponType() == Weapon::TimeBomb) {
             if (bombSoundTimer.update(elapsed)) {
                 g_App.gameSounds().play(snd::TIMEBOMB);
             }
@@ -483,7 +481,7 @@ uint16 WeaponInstance::inflictDamage(ShootableMapObject * tobj, PathNode * tp,
     if (pOwner_) {
         xb = pOwner_->tileX() * 256 + pOwner_->offX();
         yb = pOwner_->tileY() * 256 + pOwner_->offY();
-        if (main_type_ == Weapon::Flamer) {
+        if (getWeaponType() == Weapon::Flamer) {
             int dir = pOwner_->getDirection(8);
             switch (dir) {
                 case 0:
@@ -607,9 +605,9 @@ uint16 WeaponInstance::inflictDamage(ShootableMapObject * tobj, PathNode * tp,
     // perseudatron skipping, due to no target
 
     double accuracy = pWeaponClass_->shotAcurracy();
-    if (main_type_ != Weapon::Persuadatron)
+    if (getWeaponType() != Weapon::Persuadatron)
         this->playSound();
-    if (pOwner_ && pOwner_->majorType() == MapObject::mjt_Ped)
+    if (pOwner_ && pOwner_->nature() == MapObject::kNaturePed)
     {
         if (pWeaponClass_->dmgType() != MapObject::dmg_Persuasion
             && pOwner_->isOurAgent())
@@ -684,7 +682,7 @@ uint16 WeaponInstance::inflictDamage(ShootableMapObject * tobj, PathNode * tp,
                         this->playSound();
                     }
                 }*/
-                if (tobj && tobj->majorType() == MapObject::mjt_Ped) {
+                if (tobj && tobj->nature() == MapObject::kNaturePed) {
                     if (pOwner_->isFriendWith(
                         (PedInstance *)tobj))
                     {
@@ -937,7 +935,7 @@ void WeaponInstance::activate() {
 
 void WeaponInstance::deactivate() {
     activated_ = false;
-    if (main_type_ == Weapon::TimeBomb)
+    if (getWeaponType() == Weapon::TimeBomb)
         weapon_used_time_ = 0;
 }
 
@@ -1033,8 +1031,8 @@ void WeaponInstance::fire(Mission *pMission, ShootableMapObject::DamageInflictTy
     }
 }
 
-void ShotClass::makeShot(bool rangeChecked, toDefineXYZ &cp, int anim_hit,
-    std::vector <Weapon::ShotDesc> &all_shots, int anim_obj_hit,
+void ShotClass::makeShot(bool rangeChecked, toDefineXYZ &cp, SFXObject::SfxTypeEnum anim_hit,
+    std::vector <Weapon::ShotDesc> &all_shots, SFXObject::SfxTypeEnum anim_obj_hit,
     WeaponInstance * w)
 {
     Mission *m = g_Session.getMission();
@@ -1079,7 +1077,7 @@ void ShotClass::makeShot(bool rangeChecked, toDefineXYZ &cp, int anim_hit,
                     if (it_a->target_object == smp
                         && it_a->d.d_owner
 #ifdef _DEBUG
-                        && it_a->d.d_owner->majorType() == MapObject::mjt_Ped
+                        && it_a->d.d_owner->nature() == MapObject::kNaturePed
 #endif
                         && ((PedInstance *)it_a->d.d_owner)->isOurAgent())
                     {
@@ -1124,7 +1122,7 @@ void ShotClass::makeShot(bool rangeChecked, toDefineXYZ &cp, int anim_hit,
                     if (it_a->target_object == smp
                         &&it_a->d.d_owner
 #ifdef _DEBUG
-                        && it_a->d.d_owner->majorType() == MapObject::mjt_Ped
+                        && it_a->d.d_owner->nature() == MapObject::kNaturePed
 #endif
                         && ((PedInstance *)it_a->d.d_owner)->isOurAgent())
                     {
@@ -1165,7 +1163,7 @@ void WeaponInstance::getHostileInRange(toDefineXYZ * cp,
     double d = -1;
     Mission * m = g_Session.getMission();
 
-    if (mask & MapObject::mjt_Ped) {
+    if (mask & MapObject::kNaturePed) {
         for (size_t i = 0; i < m->numPeds(); i++) {
             ShootableMapObject *p = m->ped(i);
             if (!p->isIgnored() && (pOwner_->isHostileTo(p)
@@ -1189,7 +1187,7 @@ void WeaponInstance::getHostileInRange(toDefineXYZ * cp,
             }
         }
     }
-    if (mask & MapObject::mjt_Vehicle) {
+    if (mask & MapObject::kNatureVehicle) {
         for (size_t i = 0; i < m->numVehicles(); i++) {
             ShootableMapObject *v = m->vehicle(i);
             if (!v->isIgnored() && (pOwner_->isHostileTo(v)
@@ -1273,7 +1271,7 @@ void WeaponInstance::getNonFriendInRange(toDefineXYZ * cp,
 void WeaponInstance::handleHit(ShootableMapObject::DamageInflictType & d)
 {
     // When a bomb is hit, it explodes
-    if (main_type_ == Weapon::TimeBomb && health_ > 0) {
+    if (getWeaponType() == Weapon::TimeBomb && health_ > 0) {
         is_ignored_ = true;
         // we pass the given DamageInflictType just for the compiler
         // as it is not used by the fire method for a Bomb
@@ -1294,48 +1292,3 @@ void WeaponInstance::updtWeaponUsedTime(int elapsed) {
         }
     }
 }
-
-/*! Draws animation of impact/explosion
- * @param cp current position (center)
- * @param dmg_rng effective range for drawing
- * @param rngdamg_anim animation to be used for drawing
- */
-void ShotClass::rangeDamageAnim(toDefineXYZ &cp, double dmg_rng,
-    int rngdamg_anim)
-{
-    Mission *m = g_Session.getMission();
-    toDefineXYZ base_pos = cp;
-    cp.z += Z_SHIFT_TO_AIR;
-    if (cp.z > (m->mmax_z_ - 1) * 128)
-        cp.z = (m->mmax_z_ - 1) * 128;
-    // TODO: exclude flames on water, put these flames to the ground,
-    // don't draw in air(, stairs problem?)
-    double angle_inc = PI;
-    const uint8 waves = (int)dmg_rng / 144 + 1;
-
-    for (uint8 i = 0; i < waves; i++) {
-        double base_angle = 0.0;
-        if (rand() % 100 > 74)
-            base_angle += angle_inc;
-
-        for (int j = 0; j < (4 << i); j++) {
-            double x = (double)(144 * i) * cos(base_angle);
-            double y = (double)(144 * i) * sin(base_angle);
-            base_angle += angle_inc;
-            PathNode pn = PathNode((base_pos.x + (int)x) / 256,
-                (base_pos.y + (int)y) / 256,
-                base_pos.z / 128, (base_pos.x + (int)x) % 256,
-                (base_pos.y + (int)y) % 256, base_pos.z % 128);
-
-            uint8 block_mask = m->inRangeCPos(&cp, NULL, &pn, true, true, dmg_rng);
-            if (block_mask != 32) {
-                SFXObject *so = new SFXObject(m->map(), rngdamg_anim,
-                                100 * (rand() % 16));
-                so->setPosition(pn.tileX(), pn.tileY(), pn.tileZ(),
-                                pn.offX(), pn.offY(), pn.offZ());
-                m->addSfxObject(so);
-            }
-        }
-        angle_inc /= 2.0;
-    }
-}
index 3e864fce50c7f16c9a9cf94f1fa445688c0891ab..3a4945cd297c4da0f8856a9d5555ff5700bf7be6 100644 (file)
@@ -79,10 +79,10 @@ public:
      */
     struct ImpactAnims {
         //! Animation played when impact is on the ground.
-        int groundHit;
+        SFXObject::SfxTypeEnum groundHit;
         //! Animation played when impact is on a living object.
-        int objectHit;
-        int trace_anim;
+        SFXObject::SfxTypeEnum objectHit;
+        SFXObject::SfxTypeEnum trace_anim;
         /*! if weapon can do range damage this is used for range definition
          * with animation.*/
         int rd_anim;
@@ -193,10 +193,10 @@ public:
             (spe_Owner | spe_ChangeAttribute | spe_UsesAmmo),
     } WeaponShotPropertyType;
 
-    typedef enum {
-        stm_AllObjects = MapObject::mjt_Ped | MapObject::mjt_Vehicle
-        | MapObject::mjt_Static | MapObject::mjt_Weapon
-    } SearchTargetMask;
+    enum SearchTargetMask {
+        stm_AllObjects = MapObject::kNaturePed | MapObject::kNatureVehicle
+        | MapObject::kNatureStatic | MapObject::kNatureWeapon
+    };
 
     typedef struct {
         PathNode tpn;
@@ -278,10 +278,6 @@ protected:
 };
 
 class ShotClass {
-public:
-    static void rangeDamageAnim(toDefineXYZ &cp, double dmg_rng,
-        int rngdamg_anim);
-
 public:
     ShotClass(ShootableMapObject *tobj = NULL) : target_object_(tobj){}
     ~ShotClass(){}
@@ -290,8 +286,8 @@ public:
         double dist_new = -1, bool exclude_z = false);
 
 protected:
-    void makeShot(bool rangeChecked, toDefineXYZ &cp, int anim_hit,
-        std::vector <Weapon::ShotDesc> &all_shots, int anim_obj_hit,
+    void makeShot(bool rangeChecked, toDefineXYZ &cp, SFXObject::SfxTypeEnum anim_hit,
+        std::vector <Weapon::ShotDesc> &all_shots, SFXObject::SfxTypeEnum anim_obj_hit,
         WeaponInstance *w = NULL);
 
 protected:
@@ -336,7 +332,7 @@ public:
     Weapon::WeaponType getWeaponType() { return pWeaponClass_->getWeaponType(); }
 
     bool operator==(WeaponInstance wi) {
-        return main_type_ == wi.getMainType();
+        return getWeaponType() == wi.getWeaponType();
     }
 
     //! Plays the weapon's sound.