1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00

get rid of few more magic numbers (obj types)

+stub for wog objects
This commit is contained in:
alexvins 2012-12-24 15:07:30 +00:00
parent 889031a95a
commit 616cedb2f2
4 changed files with 153 additions and 104 deletions

View File

@ -433,8 +433,15 @@ ui64 evaluateDanger(const CGObjectInstance *obj)
case Obj::DRAGON_UTOPIA: case Obj::DRAGON_UTOPIA:
case Obj::SHIPWRECK: //shipwreck case Obj::SHIPWRECK: //shipwreck
case Obj::DERELICT_SHIP: //derelict ship case Obj::DERELICT_SHIP: //derelict ship
case Obj::PYRAMID: // case Obj::PYRAMID:
return fh->estimateBankDanger (VLC->objh->bankObjToIndex(obj)); return fh->estimateBankDanger (VLC->objh->bankObjToIndex(obj));
case Obj::PYRAMID:
{
if(obj.subID == 0)
return fh->estimateBankDanger (VLC->objh->bankObjToIndex(obj));
else
return 0;
}
default: default:
return 0; return 0;
} }

View File

@ -208,7 +208,7 @@ int CObjectHandler::bankObjToIndex (const CGObjectInstance * obj)
case Obj::SHIPWRECK: case Obj::SHIPWRECK:
return 7; return 7;
default: default:
tlog2 << "Unrecognixed Bank indetifier!\n"; tlog2 << "Unrecognized Bank indetifier!\n";
return 0; return 0;
} }
} }

View File

@ -233,14 +233,13 @@ namespace EWallParts
{ {
INDESTRUCTIBLE_PART = -2, INVALID = -1, INDESTRUCTIBLE_PART = -2, INVALID = -1,
KEEP = 0, BOTTOM_TOWER, BOTTOM_WALL, BELOW_GATE, OVER_GATE, UPPER_WAL, UPPER_TOWER, GATE, KEEP = 0, BOTTOM_TOWER, BOTTOM_WALL, BELOW_GATE, OVER_GATE, UPPER_WAL, UPPER_TOWER, GATE,
PARTS_COUNT PARTS_COUNT
}; };
} }
namespace EWallState namespace EWallState
{ {
enum enum EWallState
{ {
NONE, //no wall NONE, //no wall
INTACT, INTACT,
@ -251,7 +250,7 @@ namespace EWallState
namespace Obj namespace Obj
{ {
enum enum Obj
{ {
ALTAR_OF_SACRIFICE = 2, ALTAR_OF_SACRIFICE = 2,
ANCHOR_POINT = 3, ANCHOR_POINT = 3,
@ -287,15 +286,18 @@ namespace Obj
GARRISON = 33, GARRISON = 33,
HERO = 34, HERO = 34,
HILL_FORT = 35, HILL_FORT = 35,
GRAIL = 36,
HUT_OF_MAGI = 37, HUT_OF_MAGI = 37,
IDOL_OF_FORTUNE = 38, IDOL_OF_FORTUNE = 38,
LEAN_TO = 39, LEAN_TO = 39,
LIBRARY_OF_ENLIGHTENMENT = 41, LIBRARY_OF_ENLIGHTENMENT = 41,
LIGHTHOUSE = 42,
MONOLITH1 = 43, MONOLITH1 = 43,
MONOLITH2 = 44, MONOLITH2 = 44,
MONOLITH3 = 45, MONOLITH3 = 45,
MAGIC_PLAINS1 = 46, MAGIC_PLAINS1 = 46,
SCHOOL_OF_MAGIC = 47, SCHOOL_OF_MAGIC = 47,
MAGIC_SPRING = 48,
MAGIC_WELL = 49, MAGIC_WELL = 49,
MERCENARY_CAMP = 51, MERCENARY_CAMP = 51,
MERMAID = 52, MERMAID = 52,
@ -309,7 +311,8 @@ namespace Obj
PILLAR_OF_FIRE = 60, PILLAR_OF_FIRE = 60,
STAR_AXIS = 61, STAR_AXIS = 61,
PRISON = 62, PRISON = 62,
PYRAMID = 63, PYRAMID = 63,//subtype 0
WOG_OBJECT = 63,//subtype > 0
RALLY_FLAG = 64, RALLY_FLAG = 64,
RANDOM_ART = 65, RANDOM_ART = 65,
RANDOM_TREASURE_ART = 66, RANDOM_TREASURE_ART = 66,
@ -334,7 +337,11 @@ namespace Obj
SHIPWRECK = 85, SHIPWRECK = 85,
SHIPWRECK_SURVIVOR = 86, SHIPWRECK_SURVIVOR = 86,
SHIPYARD = 87, SHIPYARD = 87,
SHRINE_OF_MAGIC_INCANTATION = 88,
SHRINE_OF_MAGIC_GESTURE = 89,
SHRINE_OF_MAGIC_THOUGHT = 90, SHRINE_OF_MAGIC_THOUGHT = 90,
SIGN = 91,
SIRENS = 92,
SPELL_SCROLL = 93, SPELL_SCROLL = 93,
STABLES = 94, STABLES = 94,
TAVERN = 95, TAVERN = 95,
@ -355,6 +362,7 @@ namespace Obj
WATERING_HOLE = 110, WATERING_HOLE = 110,
WHIRLPOOL = 111, WHIRLPOOL = 111,
WINDMILL = 112, WINDMILL = 112,
WITCH_HUT = 113,
HOLE = 124, HOLE = 124,
RANDOM_MONSTER_L5 = 162, RANDOM_MONSTER_L5 = 162,
RANDOM_MONSTER_L6 = 163, RANDOM_MONSTER_L6 = 163,

View File

@ -1135,53 +1135,61 @@ void CMapLoaderH3M::readObjects()
pos += 4; pos += 4;
break; break;
} }
case 34: case 70: case 62: //34 - hero; 70 - random hero; 62 - prison case Obj::HERO:
case Obj::RANDOM_HERO:
case Obj::PRISON:
{ {
nobj = readHero(idToBeGiven); nobj = readHero(idToBeGiven);
break; break;
} }
case 4: //Arena case Obj::ARENA:
case 51: //Mercenary Camp case Obj::MERCENARY_CAMP:
case 23: //Marletto Tower case Obj::MARLETTO_TOWER:
case 61: // Star Axis case Obj::STAR_AXIS:
case 32: // Garden of Revelation case Obj::GARDEN_OF_REVELATION:
case 100: //Learning Stone case Obj::LEARNING_STONE:
case 102: //Tree of Knowledge case Obj::TREE_OF_KNOWLEDGE:
case 41: //Library of Enlightenment case Obj::LIBRARY_OF_ENLIGHTENMENT:
case 47: //School of Magic case Obj::SCHOOL_OF_MAGIC:
case 107: //School of War case Obj::SCHOOL_OF_WAR:
{ {
nobj = new CGVisitableOPH(); nobj = new CGVisitableOPH();
break; break;
} }
case 55: //mystical garden case Obj::MYSTICAL_GARDEN:
case 112://windmill case Obj::WINDMILL:
case 109://water wheel case Obj::WATER_WHEEL:
{ {
nobj = new CGVisitableOPW(); nobj = new CGVisitableOPW();
break; break;
} }
case 43: //teleport case Obj::MONOLITH1:
case 44: //teleport case Obj::MONOLITH2:
case 45: //teleport case Obj::MONOLITH3:
case 103://subterranean gate case Obj::SUBTERRANEAN_GATE:
case 111://Whirlpool case Obj::WHIRLPOOL:
{ {
nobj = new CGTeleport(); nobj = new CGTeleport();
break; break;
} }
case 12: //campfire case Obj::CAMPFIRE:
case 29: //Flotsam case Obj::FLOTSAM:
case 82: //Sea Chest case Obj::SEA_CHEST:
case 86: //Shipwreck Survivor case Obj::SHIPWRECK_SURVIVOR:
case 101://treasure chest case Obj::TREASURE_CHEST:
{ {
nobj = new CGPickable(); nobj = new CGPickable();
break; break;
} }
case 54: //Monster case Obj::MONSTER: //Monster
case 71: case 72: case 73: case 74: case 75: // Random Monster 1 - 4 case Obj::RANDOM_MONSTER:
case 162: case 163: case 164: // Random Monster 5 - 7 case Obj::RANDOM_MONSTER_L1:
case Obj::RANDOM_MONSTER_L2:
case Obj::RANDOM_MONSTER_L3:
case Obj::RANDOM_MONSTER_L4:
case Obj::RANDOM_MONSTER_L5:
case Obj::RANDOM_MONSTER_L6:
case Obj::RANDOM_MONSTER_L7:
{ {
CGCreature * cre = new CGCreature(); CGCreature * cre = new CGCreature();
nobj = cre; nobj = cre;
@ -1256,7 +1264,8 @@ void CMapLoaderH3M::readObjects()
pos += 2; pos += 2;
break; break;
} }
case 59: case 91: //ocean bottle and sign case Obj::OCEAN_BOTTLE:
case Obj::SIGN:
{ {
CGSignBottle * sb = new CGSignBottle(); CGSignBottle * sb = new CGSignBottle();
nobj = sb; nobj = sb;
@ -1264,18 +1273,18 @@ void CMapLoaderH3M::readObjects()
pos += 4; pos += 4;
break; break;
} }
case 83: //seer's hut case Obj::SEER_HUT:
{ {
nobj = readSeerHut(); nobj = readSeerHut();
addQuest(nobj); addQuest(nobj);
break; break;
} }
case 113: //witch hut case Obj::WITCH_HUT:
{ {
CGWitchHut * wh = new CGWitchHut(); CGWitchHut * wh = new CGWitchHut();
nobj = wh; nobj = wh;
// in reo we cannot specify it - all are allowed (I hope) // in RoE we cannot specify it - all are allowed (I hope)
if(map->version > EMapFormat::ROE) if(map->version > EMapFormat::ROE)
{ {
int ist=pos; int ist=pos;
@ -1304,7 +1313,7 @@ void CMapLoaderH3M::readObjects()
} }
break; break;
} }
case 81: //scholar case Obj::SCHOLAR:
{ {
CGScholar * sch = new CGScholar(); CGScholar * sch = new CGScholar();
nobj = sch; nobj = sch;
@ -1313,7 +1322,8 @@ void CMapLoaderH3M::readObjects()
pos += 6; pos += 6;
break; break;
} }
case 33: case 219: //garrison case Obj::GARRISON:
case Obj::GARRISON2:
{ {
CGGarrison * gar = new CGGarrison(); CGGarrison * gar = new CGGarrison();
nobj = gar; nobj = gar;
@ -1332,9 +1342,13 @@ void CMapLoaderH3M::readObjects()
pos += 8; pos += 8;
break; break;
} }
case 5: //artifact case Obj::ARTIFACT:
case 65: case 66: case 67: case 68: case 69: //random artifact case Obj::RANDOM_ART:
case 93: //spell scroll case Obj::RANDOM_TREASURE_ART:
case Obj::RANDOM_MINOR_ART:
case Obj::RANDOM_MAJOR_ART:
case Obj::RANDOM_RELIC_ART:
case Obj::SPELL_SCROLL:
{ {
int artID = -1; int artID = -1;
int spellID = -1; int spellID = -1;
@ -1353,13 +1367,13 @@ void CMapLoaderH3M::readObjects()
pos += 4; pos += 4;
} }
if(defInfo->id == 93) if(defInfo->id == Obj::SPELL_SCROLL)
{ {
spellID = read_le_u32(buffer + pos); spellID = read_le_u32(buffer + pos);
pos += 4; pos += 4;
artID = 1; artID = 1;
} }
else if(defInfo->id == 5) else if(defInfo->id == Obj::ARTIFACT)
{ {
//specific artifact //specific artifact
artID = defInfo->subid; artID = defInfo->subid;
@ -1368,7 +1382,8 @@ void CMapLoaderH3M::readObjects()
art->storedArtifact = createArtifact(artID, spellID); art->storedArtifact = createArtifact(artID, spellID);
break; break;
} }
case 76: case 79: //random resource; resource case Obj::RANDOM_RESOURCE:
case Obj::RESOURCE:
{ {
CGResource * res = new CGResource(); CGResource * res = new CGResource();
nobj = res; nobj = res;
@ -1395,33 +1410,39 @@ void CMapLoaderH3M::readObjects()
break; break;
} }
case 77: case 98: //random town; town case Obj::RANDOM_TOWN:
case Obj::TOWN:
{ {
nobj = readTown(defInfo->subid); nobj = readTown(defInfo->subid);
break; break;
} }
case 53: case Obj::MINE:
case 220://mine (?) case Obj::ABANDONED_MINE:
{ {
nobj = new CGMine(); nobj = new CGMine();
nobj->setOwner(buffer[pos++]); nobj->setOwner(buffer[pos++]);
pos += 3; pos += 3;
break; break;
} }
case 17: case 18: case 19: case 20: //dwellings case Obj::CREATURE_GENERATOR1:
case Obj::CREATURE_GENERATOR2:
case Obj::CREATURE_GENERATOR3:
case Obj::CREATURE_GENERATOR4:
{ {
nobj = new CGDwelling(); nobj = new CGDwelling();
nobj->setOwner(buffer[pos++]); nobj->setOwner(buffer[pos++]);
pos += 3; pos += 3;
break; break;
} }
case 78: //Refugee Camp case Obj::REFUGEE_CAMP:
case 106: //War Machine Factory case Obj::WAR_MACHINE_FACTORY:
{ {
nobj = new CGDwelling(); nobj = new CGDwelling();
break; break;
} }
case 88: case 89: case 90: //spell shrine case Obj::SHRINE_OF_MAGIC_INCANTATION:
case Obj::SHRINE_OF_MAGIC_GESTURE:
case Obj::SHRINE_OF_MAGIC_THOUGHT:
{ {
CGShrine * shr = new CGShrine(); CGShrine * shr = new CGShrine();
nobj = shr; nobj = shr;
@ -1429,7 +1450,7 @@ void CMapLoaderH3M::readObjects()
pos += 4; pos += 4;
break; break;
} }
case 6: //pandora's box case Obj::PANDORAS_BOX:
{ {
CGPandoraBox * box = new CGPandoraBox(); CGPandoraBox * box = new CGPandoraBox();
nobj = box; nobj = box;
@ -1506,25 +1527,24 @@ void CMapLoaderH3M::readObjects()
pos += 8; pos += 8;
break; break;
} }
case 36: //grail case Obj::GRAIL:
{ {
map->grailPos = objPos; map->grailPos = objPos;
map->grailRadious = read_le_u32(buffer + pos); map->grailRadious = read_le_u32(buffer + pos);
pos += 4; pos += 4;
continue; continue;
} }
//dwellings case Obj::RANDOM_DWELLING: //same as castle + level range
case 216: //same as castle + level range case Obj::RANDOM_DWELLING_LVL: //same as castle, fixed level
case 217: //same as castle case Obj::RANDOM_DWELLING_FACTION: //level range, fixed faction
case 218: //level range
{ {
nobj = new CGDwelling(); nobj = new CGDwelling();
CSpecObjInfo * spec = nullptr; CSpecObjInfo * spec = nullptr;
switch(defInfo->id) switch(defInfo->id)
{ {
break; case 216: spec = new CCreGenLeveledCastleInfo(); break; case Obj::RANDOM_DWELLING: spec = new CCreGenLeveledCastleInfo();
break; case 217: spec = new CCreGenAsCastleInfo(); break; case Obj::RANDOM_DWELLING_LVL: spec = new CCreGenAsCastleInfo();
break; case 218: spec = new CCreGenLeveledInfo(); break; case Obj::RANDOM_DWELLING_FACTION: spec = new CCreGenLeveledInfo();
} }
spec->player = read_le_u32(buffer + pos); spec->player = read_le_u32(buffer + pos);
@ -1561,7 +1581,7 @@ void CMapLoaderH3M::readObjects()
static_cast<CGDwelling *>(nobj)->info = spec; static_cast<CGDwelling *>(nobj)->info = spec;
break; break;
} }
case 215: case Obj::QUEST_GUARD:
{ {
CGQuestGuard * guard = new CGQuestGuard(); CGQuestGuard * guard = new CGQuestGuard();
addQuest(guard); addQuest(guard);
@ -1569,60 +1589,60 @@ void CMapLoaderH3M::readObjects()
nobj = guard; nobj = guard;
break; break;
} }
case 28: //faerie ring case Obj::FAERIE_RING:
case 14: //Swan pond case Obj::SWAN_POND:
case 38: //idol of fortune case Obj::IDOL_OF_FORTUNE:
case 30: //Fountain of Fortune case Obj::FOUNTAIN_OF_FORTUNE:
case 64: //Rally Flag case Obj::RALLY_FLAG:
case 56: //oasis case Obj::OASIS:
case 96: //temple case Obj::TEMPLE:
case 110://Watering Hole case Obj::WATERING_HOLE:
case 31: //Fountain of Youth case Obj::FOUNTAIN_OF_YOUTH:
case 11: //Buoy case Obj::BUOY:
case 52: //Mermaid case Obj::MERMAID:
case 94: //Stables case Obj::STABLES:
{ {
nobj = new CGBonusingObject(); nobj = new CGBonusingObject();
break; break;
} }
case 49: //Magic Well case Obj::MAGIC_WELL:
{ {
nobj = new CGMagicWell(); nobj = new CGMagicWell();
break; break;
} }
case 15: //Cover of darkness case Obj::COVER_OF_DARKNESS:
case 58: //Redwood Observatory case Obj::REDWOOD_OBSERVATORY:
case 60: //Pillar of Fire case Obj::PILLAR_OF_FIRE:
{ {
nobj = new CGObservatory(); nobj = new CGObservatory();
break; break;
} }
case 22: //Corpse case Obj::CORPSE:
case 39: //Lean To case Obj::LEAN_TO:
case 105://Wagon case Obj::WAGON:
case 108://Warrior's Tomb case Obj::WARRIORS_TOMB:
{ {
nobj = new CGOnceVisitable(); nobj = new CGOnceVisitable();
break; break;
} }
case 8: //Boat case Obj::BOAT:
{ {
nobj = new CGBoat(); nobj = new CGBoat();
break; break;
} }
case 92: //Sirens case Obj::SIRENS:
{ {
nobj = new CGSirens(); nobj = new CGSirens();
break; break;
} }
case 87: //Shipyard case Obj::SHIPYARD:
{ {
nobj = new CGShipyard(); nobj = new CGShipyard();
nobj->setOwner(read_le_u32(buffer + pos)); nobj->setOwner(read_le_u32(buffer + pos));
pos += 4; pos += 4;
break; break;
} }
case 214: //hero placeholder case Obj::HERO_PLACEHOLDER: //hero placeholder
{ {
CGHeroPlaceholder * hp = new CGHeroPlaceholder(); CGHeroPlaceholder * hp = new CGHeroPlaceholder();
nobj = hp; nobj = hp;
@ -1644,79 +1664,93 @@ void CMapLoaderH3M::readObjects()
break; break;
} }
case 10: //Keymaster case Obj::KEYMASTER:
{ {
nobj = new CGKeymasterTent(); nobj = new CGKeymasterTent();
break; break;
} }
case 9: //Border Guard case Obj::BORDERGUARD:
{ {
nobj = new CGBorderGuard(); nobj = new CGBorderGuard();
addQuest(nobj); addQuest(nobj);
break; break;
} }
case 212: //Border Gate case Obj::BORDER_GATE:
{ {
nobj = new CGBorderGate(); nobj = new CGBorderGate();
addQuest (nobj); addQuest (nobj);
break; break;
} }
case 27: case 37: //Eye and Hut of Magi case Obj::EYE_OF_MAGI:
case Obj::HUT_OF_MAGI:
{ {
nobj = new CGMagi(); nobj = new CGMagi();
break; break;
} }
case 16: case 24: case 25: case 84: case 85: //treasure bank case Obj::CREATURE_BANK:
case Obj::DERELICT_SHIP:
case Obj::DRAGON_UTOPIA:
case Obj::CRYPT:
case Obj::SHIPWRECK:
{ {
nobj = new CBank(); nobj = new CBank();
break; break;
} }
case 63: //Pyramid case Obj::PYRAMID: //Pyramid of WoG object
{ {
nobj = new CGPyramid(); if(defInfo->subid == 0)
{
nobj = new CGPyramid();
}
else
{
//WoG object
//TODO: possible special handling
nobj = new CGObjectInstance();
}
break; break;
} }
case 13: //Cartographer case Obj::CARTOGRAPHER:
{ {
nobj = new CCartographer(); nobj = new CCartographer();
break; break;
} }
case 48: //Magic Spring case Obj::MAGIC_SPRING:
{ {
nobj = new CGMagicSpring(); nobj = new CGMagicSpring();
break; break;
} }
case 97: //den of thieves case Obj::DEN_OF_THIEVES:
{ {
nobj = new CGDenOfthieves(); nobj = new CGDenOfthieves();
break; break;
} }
case 57: //Obelisk case Obj::OBELISK:
{ {
nobj = new CGObelisk(); nobj = new CGObelisk();
break; break;
} }
case 42: //Lighthouse case Obj::LIGHTHOUSE: //Lighthouse
{ {
nobj = new CGLighthouse(); nobj = new CGLighthouse();
nobj->tempOwner = read_le_u32(buffer + pos); nobj->tempOwner = read_le_u32(buffer + pos);
pos += 4; pos += 4;
break; break;
} }
case 2: //Altar of Sacrifice case Obj::ALTAR_OF_SACRIFICE:
case 99: //Trading Post case Obj::TRADING_POST:
case 213: //Freelancer's Guild case Obj::FREELANCERS_GUILD:
case 221: //Trading Post (snow) case Obj::TRADING_POST_SNOW:
{ {
nobj = new CGMarket(); nobj = new CGMarket();
break; break;
} }
case 104: //University case Obj::UNIVERSITY:
{ {
nobj = new CGUniversity(); nobj = new CGUniversity();
break; break;
} }
case 7: //Black Market case Obj::BLACK_MARKET:
{ {
nobj = new CGBlackMarket(); nobj = new CGBlackMarket();
break; break;