mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
- Fixed some issues and crashes
- Simplified projectile handling. New creatures can now shoot.
This commit is contained in:
@@ -768,13 +768,7 @@ bool CShootingAnimation::init()
|
|||||||
|
|
||||||
spi.step = 0;
|
spi.step = 0;
|
||||||
spi.frameNum = 0;
|
spi.frameNum = 0;
|
||||||
if(vstd::contains(CGI->creh->idToProjectileSpin, shooterInfo->idNumber))
|
spi.spin = shooterInfo->projectileSpin;
|
||||||
spi.spin = CGI->creh->idToProjectileSpin[shooterInfo->idNumber];
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tlog2 << "Warning - no projectile spin for spi.creID " << shooterInfo->idNumber << std::endl;
|
|
||||||
spi.spin = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Point xycoord = CClickableHex::getXYUnitAnim(shooter->position, true, shooter, owner);
|
Point xycoord = CClickableHex::getXYUnitAnim(shooter->position, true, shooter, owner);
|
||||||
Point destcoord;
|
Point destcoord;
|
||||||
|
|||||||
@@ -284,10 +284,10 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
|
|||||||
BOOST_FOREACH(const CStack *s, stacks)
|
BOOST_FOREACH(const CStack *s, stacks)
|
||||||
{
|
{
|
||||||
int creID = (s->getCreature()->idNumber == 149) ? CGI->creh->factionToTurretCreature[siegeH->town->town->typeID] : s->getCreature()->idNumber; //id of creature whose shots should be loaded
|
int creID = (s->getCreature()->idNumber == 149) ? CGI->creh->factionToTurretCreature[siegeH->town->town->typeID] : s->getCreature()->idNumber; //id of creature whose shots should be loaded
|
||||||
if(s->getCreature()->isShooting() && vstd::contains(CGI->creh->idToProjectile, creID))
|
if(s->getCreature()->isShooting())
|
||||||
{
|
{
|
||||||
CDefHandler *&projectile = idToProjectile[s->getCreature()->idNumber];
|
CDefHandler *&projectile = idToProjectile[s->getCreature()->idNumber];
|
||||||
projectile = CDefHandler::giveDef(CGI->creh->idToProjectile[creID]);
|
projectile = CDefHandler::giveDef(s->getCreature()->projectile);
|
||||||
|
|
||||||
if(projectile->ourImages.size() > 2) //add symmetric images
|
if(projectile->ourImages.size() > 2) //add symmetric images
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "../lib/VCMIDirs.h"
|
#include "../lib/VCMIDirs.h"
|
||||||
#include "../lib/NetPacks.h"
|
#include "../lib/NetPacks.h"
|
||||||
#include "CMessage.h"
|
#include "CMessage.h"
|
||||||
|
#include "../lib/CModHandler.h"
|
||||||
#include "../lib/CObjectHandler.h"
|
#include "../lib/CObjectHandler.h"
|
||||||
#include "../lib/CArtHandler.h"
|
#include "../lib/CArtHandler.h"
|
||||||
#include "../lib/CScriptingModule.h"
|
#include "../lib/CScriptingModule.h"
|
||||||
@@ -758,8 +759,9 @@ static void listenForEvents()
|
|||||||
vstd::clear_pointer(client);
|
vstd::clear_pointer(client);
|
||||||
|
|
||||||
delete CGI->dobjinfo.get();
|
delete CGI->dobjinfo.get();
|
||||||
const_cast<CGameInfo*>(CGI)->dobjinfo = new CDefObjInfoHandler;
|
const_cast<CGameInfo*>(CGI)->dobjinfo = new CDefObjInfoHandler;
|
||||||
const_cast<CGameInfo*>(CGI)->dobjinfo->load();
|
const_cast<CGameInfo*>(CGI)->dobjinfo->load();
|
||||||
|
const_cast<CGameInfo*>(CGI)->modh->recreateAdvMapDefs(); //add info about new creatures to dobjinfo
|
||||||
};
|
};
|
||||||
|
|
||||||
switch(ev.user.code)
|
switch(ev.user.code)
|
||||||
|
|||||||
@@ -432,10 +432,10 @@ void CCreatureHandler::loadCreatures()
|
|||||||
value = &creature["projectile_defname"];
|
value = &creature["projectile_defname"];
|
||||||
if (!value->isNull())
|
if (!value->isNull())
|
||||||
{
|
{
|
||||||
idToProjectile[creatureID] = value->String();
|
c->projectile = value->String();
|
||||||
|
|
||||||
value = &creature["projectile_spin"];
|
value = &creature["projectile_spin"];
|
||||||
idToProjectileSpin[creatureID] = value->Bool();
|
c->projectileSpin = value->Bool();
|
||||||
}
|
}
|
||||||
|
|
||||||
value = &creature["turret_shooter"];
|
value = &creature["turret_shooter"];
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public:
|
|||||||
double missleFrameAngles[12];
|
double missleFrameAngles[12];
|
||||||
int troopCountLocationOffset, attackClimaxFrame;
|
int troopCountLocationOffset, attackClimaxFrame;
|
||||||
std::string projectile;
|
std::string projectile;
|
||||||
|
ui8 projectileSpin; //if true, appropriate projectile is spinning during flight
|
||||||
///end of anim info
|
///end of anim info
|
||||||
|
|
||||||
//sound info
|
//sound info
|
||||||
@@ -109,7 +110,7 @@ public:
|
|||||||
& timeBetweenFidgets & walkAnimationTime & attackAnimationTime & flightAnimationDistance
|
& timeBetweenFidgets & walkAnimationTime & attackAnimationTime & flightAnimationDistance
|
||||||
& upperRightMissleOffsetX & rightMissleOffsetX & lowerRightMissleOffsetX & upperRightMissleOffsetY & rightMissleOffsetY & lowerRightMissleOffsetY
|
& upperRightMissleOffsetX & rightMissleOffsetX & lowerRightMissleOffsetX & upperRightMissleOffsetY & rightMissleOffsetY & lowerRightMissleOffsetY
|
||||||
& missleFrameAngles & troopCountLocationOffset & attackClimaxFrame;
|
& missleFrameAngles & troopCountLocationOffset & attackClimaxFrame;
|
||||||
h & sounds & projectile;
|
h & sounds & projectile & projectileSpin;
|
||||||
|
|
||||||
h & doubleWide;
|
h & doubleWide;
|
||||||
}
|
}
|
||||||
@@ -129,8 +130,6 @@ public:
|
|||||||
std::set<TCreature> doubledCreatures; //they get double week
|
std::set<TCreature> doubledCreatures; //they get double week
|
||||||
std::vector<ConstTransitivePtr<CCreature> > creatures; //creature ID -> creature info
|
std::vector<ConstTransitivePtr<CCreature> > creatures; //creature ID -> creature info
|
||||||
bmap<std::string,int> nameToID;
|
bmap<std::string,int> nameToID;
|
||||||
bmap<int,std::string> idToProjectile;
|
|
||||||
bmap<int,bool> idToProjectileSpin; //if true, appropriate projectile is spinning during flight
|
|
||||||
std::vector<si8> factionAlignments; //1 for good, 0 for neutral and -1 for evil with faction ID as index
|
std::vector<si8> factionAlignments; //1 for good, 0 for neutral and -1 for evil with faction ID as index
|
||||||
int factionToTurretCreature[GameConstants::F_NUMBER]; //which creature's animation should be used to dispaly creature in turret while siege
|
int factionToTurretCreature[GameConstants::F_NUMBER]; //which creature's animation should be used to dispaly creature in turret while siege
|
||||||
|
|
||||||
@@ -168,7 +167,7 @@ public:
|
|||||||
template <typename Handler> void serialize(Handler &h, const int version)
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
{
|
{
|
||||||
//TODO: should be optimized, not all these informations needs to be serialized (same for ccreature)
|
//TODO: should be optimized, not all these informations needs to be serialized (same for ccreature)
|
||||||
h & notUsedMonsters & creatures & nameToID & idToProjectile & idToProjectileSpin & factionToTurretCreature;
|
h & notUsedMonsters & creatures & nameToID & factionToTurretCreature;
|
||||||
h & stackBonuses & expRanks & maxExpPerBattle & expAfterUpgrade;
|
h & stackBonuses & expRanks & maxExpPerBattle & expAfterUpgrade;
|
||||||
h & factionCommanders & skillLevels & skillRequirements & commanderLevelPremy;
|
h & factionCommanders & skillLevels & skillRequirements & commanderLevelPremy;
|
||||||
h & allCreatures;
|
h & allCreatures;
|
||||||
|
|||||||
@@ -234,10 +234,10 @@ CCreature * CModHandler::loadCreature (const JsonNode &node)
|
|||||||
cre->missleFrameAngles[i++] = angle.Float();
|
cre->missleFrameAngles[i++] = angle.Float();
|
||||||
}
|
}
|
||||||
cre->advMapDef = graphics["map"].String();
|
cre->advMapDef = graphics["map"].String();
|
||||||
//TODO: we need to know creature id to add it
|
|
||||||
//FIXME: creature handler is not yet initialized
|
//TODO: parse
|
||||||
//VLC->creh->idToProjectile[cre->idNumber] = "PLCBOWX.DEF";
|
|
||||||
cre->projectile = "PLCBOWX.DEF";
|
cre->projectile = "PLCBOWX.DEF";
|
||||||
|
cre->projectileSpin = false;
|
||||||
|
|
||||||
const JsonNode & sounds = node["sound"];
|
const JsonNode & sounds = node["sound"];
|
||||||
|
|
||||||
@@ -257,6 +257,16 @@ CCreature * CModHandler::loadCreature (const JsonNode &node)
|
|||||||
creatures.push_back(cre);
|
creatures.push_back(cre);
|
||||||
return cre;
|
return cre;
|
||||||
}
|
}
|
||||||
|
void CModHandler::recreateAdvMapDefs()
|
||||||
|
{
|
||||||
|
BOOST_FOREACH (auto creature, creatures)
|
||||||
|
{
|
||||||
|
//generate adventure map object info & graphics
|
||||||
|
CGDefInfo* nobj = new CGDefInfo (*VLC->dobjinfo->gobjs[GameConstants::CREI_TYPE][0]);//copy all typical properties
|
||||||
|
nobj->name = creature->advMapDef; //change only def name (?)
|
||||||
|
VLC->dobjinfo->gobjs[GameConstants::CREI_TYPE][creature->idNumber] = nobj;
|
||||||
|
}
|
||||||
|
}
|
||||||
void CModHandler::recreateHandlers()
|
void CModHandler::recreateHandlers()
|
||||||
{
|
{
|
||||||
//TODO: consider some template magic to unify all handlers?
|
//TODO: consider some template magic to unify all handlers?
|
||||||
@@ -273,11 +283,8 @@ void CModHandler::recreateHandlers()
|
|||||||
// VLC->creh->nameToID[creature->nameRef] = creature->idNumber;
|
// VLC->creh->nameToID[creature->nameRef] = creature->idNumber;
|
||||||
VLC->creh->nameToID[creature->nameSing] = creature->idNumber;
|
VLC->creh->nameToID[creature->nameSing] = creature->idNumber;
|
||||||
|
|
||||||
//generate adventure map object info & graphics
|
|
||||||
CGDefInfo* nobj = new CGDefInfo (*VLC->dobjinfo->gobjs[GameConstants::CREI_TYPE][0]);//copy all typical properties
|
|
||||||
nobj->name = creature->advMapDef; //change only def name (?)
|
|
||||||
VLC->dobjinfo->gobjs[GameConstants::CREI_TYPE][creature->idNumber] = nobj;
|
|
||||||
}
|
}
|
||||||
|
recreateAdvMapDefs();
|
||||||
BOOST_FOREACH (auto creature, VLC->creh->creatures) //populate upgrades described with string
|
BOOST_FOREACH (auto creature, VLC->creh->creatures) //populate upgrades described with string
|
||||||
{
|
{
|
||||||
BOOST_FOREACH (auto upgradeName, creature->upgradeNames)
|
BOOST_FOREACH (auto upgradeName, creature->upgradeNames)
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ public:
|
|||||||
|
|
||||||
void loadConfigFromFile (std::string name);
|
void loadConfigFromFile (std::string name);
|
||||||
void saveConfigToFile (std::string name);
|
void saveConfigToFile (std::string name);
|
||||||
CCreature * loadCreature (const JsonNode &node); //TODO: handler collections now use ModHandler vector index. Should they be aligned according to mods actually used??
|
CCreature * loadCreature (const JsonNode &node);
|
||||||
|
void recreateAdvMapDefs();
|
||||||
void recreateHandlers();
|
void recreateHandlers();
|
||||||
|
|
||||||
struct DLL_LINKAGE hardcodedFeatures
|
struct DLL_LINKAGE hardcodedFeatures
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ void LibClasses::init()
|
|||||||
tlog0<<"\tSpell handler: "<<pomtime.getDiff()<<std::endl;
|
tlog0<<"\tSpell handler: "<<pomtime.getDiff()<<std::endl;
|
||||||
|
|
||||||
modh->recreateHandlers(); //load all new creatures parsed in the meantime.
|
modh->recreateHandlers(); //load all new creatures parsed in the meantime.
|
||||||
|
//FIXME: make sure that everything is ok after game restart
|
||||||
//TODO: This should be done every time mod config changes
|
//TODO: This should be done every time mod config changes
|
||||||
|
|
||||||
IS_AI_ENABLED = false;
|
IS_AI_ENABLED = false;
|
||||||
@@ -145,6 +146,7 @@ void LibClasses::callWhenDeserializing()
|
|||||||
generaltexth = new CGeneralTextHandler;
|
generaltexth = new CGeneralTextHandler;
|
||||||
generaltexth->load();
|
generaltexth->load();
|
||||||
arth->loadArtifacts(true);
|
arth->loadArtifacts(true);
|
||||||
|
//modh->recreateHandlers();
|
||||||
//modh->loadConfigFromFile ("defaultMods"); //TODO: remember last saved config
|
//modh->loadConfigFromFile ("defaultMods"); //TODO: remember last saved config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user