mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Fixed cheats - sendMesssage will also pass current object.
Workaround-ish but should work. Branch should be fixed now.
This commit is contained in:
parent
c4fc8f08c0
commit
aa0433228a
@ -258,10 +258,10 @@ void CCallback::save( const std::string &fname )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CCallback::sendMessage(const std::string &mess)
|
void CCallback::sendMessage(const std::string &mess, const CGObjectInstance * currentObject)
|
||||||
{
|
{
|
||||||
ASSERT_IF_CALLED_WITH_PLAYER
|
ASSERT_IF_CALLED_WITH_PLAYER
|
||||||
PlayerMessage pm(*player, mess);
|
PlayerMessage pm(*player, mess, currentObject? currentObject->id : ObjectInstanceID(-1));
|
||||||
sendRequest(&(CPackForClient&)pm);
|
sendRequest(&(CPackForClient&)pm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ public:
|
|||||||
virtual void setFormation(const CGHeroInstance * hero, bool tight)=0;
|
virtual void setFormation(const CGHeroInstance * hero, bool tight)=0;
|
||||||
|
|
||||||
virtual void save(const std::string &fname) = 0;
|
virtual void save(const std::string &fname) = 0;
|
||||||
virtual void sendMessage(const std::string &mess) = 0;
|
virtual void sendMessage(const std::string &mess, const CGObjectInstance * currentObject = nullptr) = 0;
|
||||||
virtual void buildBoat(const IShipyard *obj) = 0;
|
virtual void buildBoat(const IShipyard *obj) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ public:
|
|||||||
void setFormation(const CGHeroInstance * hero, bool tight);
|
void setFormation(const CGHeroInstance * hero, bool tight);
|
||||||
void recruitHero(const CGObjectInstance *townOrTavern, const CGHeroInstance *hero);
|
void recruitHero(const CGObjectInstance *townOrTavern, const CGHeroInstance *hero);
|
||||||
void save(const std::string &fname);
|
void save(const std::string &fname);
|
||||||
void sendMessage(const std::string &mess);
|
void sendMessage(const std::string &mess, const CGObjectInstance * currentObject = nullptr);
|
||||||
void buildBoat(const IShipyard *obj);
|
void buildBoat(const IShipyard *obj);
|
||||||
void dig(const CGObjectInstance *hero);
|
void dig(const CGObjectInstance *hero);
|
||||||
void castSpell(const CGHeroInstance *hero, SpellID spellID, const int3 &pos = int3(-1, -1, -1));
|
void castSpell(const CGHeroInstance *hero, SpellID spellID, const int3 &pos = int3(-1, -1, -1));
|
||||||
|
@ -1168,7 +1168,7 @@ void CInGameConsole::endEnteringText(bool printEnteredText)
|
|||||||
if(printEnteredText)
|
if(printEnteredText)
|
||||||
{
|
{
|
||||||
std::string txt = enteredText.substr(0, enteredText.size()-1);
|
std::string txt = enteredText.substr(0, enteredText.size()-1);
|
||||||
LOCPLINT->cb->sendMessage(txt);
|
LOCPLINT->cb->sendMessage(txt, LOCPLINT->getSelection());
|
||||||
previouslyEntered.push_back(txt);
|
previouslyEntered.push_back(txt);
|
||||||
//print(txt);
|
//print(txt);
|
||||||
}
|
}
|
||||||
|
@ -2035,8 +2035,8 @@ struct SaveGame : public CPackForClient, public CPackForServer
|
|||||||
struct PlayerMessage : public CPackForClient, public CPackForServer //513
|
struct PlayerMessage : public CPackForClient, public CPackForServer //513
|
||||||
{
|
{
|
||||||
PlayerMessage(){CPackForClient::type = 513;};
|
PlayerMessage(){CPackForClient::type = 513;};
|
||||||
PlayerMessage(PlayerColor Player, const std::string &Text)
|
PlayerMessage(PlayerColor Player, const std::string &Text, ObjectInstanceID obj)
|
||||||
:player(Player),text(Text)
|
:player(Player),text(Text), currObj(obj)
|
||||||
{CPackForClient::type = 513;};
|
{CPackForClient::type = 513;};
|
||||||
void applyCl(CClient *cl);
|
void applyCl(CClient *cl);
|
||||||
void applyGs(CGameState *gs){};
|
void applyGs(CGameState *gs){};
|
||||||
@ -2044,10 +2044,11 @@ struct PlayerMessage : public CPackForClient, public CPackForServer //513
|
|||||||
|
|
||||||
PlayerColor player;
|
PlayerColor player;
|
||||||
std::string text;
|
std::string text;
|
||||||
|
ObjectInstanceID currObj; // optional parameter that specifies current object. For cheats :)
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h, const int version)
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
{
|
{
|
||||||
h & text & player;
|
h & text & player & currObj;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3778,18 +3778,18 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameHandler::playerMessage( PlayerColor player, const std::string &message )
|
void CGameHandler::playerMessage( PlayerColor player, const std::string &message, ObjectInstanceID currObj )
|
||||||
{
|
{
|
||||||
bool cheated=true;
|
bool cheated=true;
|
||||||
PlayerMessage temp_message(player, message);
|
PlayerMessage temp_message(player, message, ObjectInstanceID(-1)); // don't inform other client on selected object
|
||||||
|
|
||||||
sendAndApply(&temp_message);
|
sendAndApply(&temp_message);
|
||||||
if(message == "vcmiistari") //give all spells and 999 mana
|
if(message == "vcmiistari") //give all spells and 999 mana
|
||||||
{/*
|
{
|
||||||
SetMana sm;
|
SetMana sm;
|
||||||
ChangeSpells cs;
|
ChangeSpells cs;
|
||||||
|
|
||||||
CGHeroInstance *h = gs->getHero(gs->getPlayer(player)->currentSelection);
|
CGHeroInstance *h = gs->getHero(currObj);
|
||||||
if(!h && complain("Cannot realize cheat, no hero selected!")) return;
|
if(!h && complain("Cannot realize cheat, no hero selected!")) return;
|
||||||
|
|
||||||
sm.hid = cs.hid = h->id;
|
sm.hid = cs.hid = h->id;
|
||||||
@ -3813,13 +3813,13 @@ void CGameHandler::playerMessage( PlayerColor player, const std::string &message
|
|||||||
}
|
}
|
||||||
else if (message == "vcmiarmenelos") //build all buildings in selected town
|
else if (message == "vcmiarmenelos") //build all buildings in selected town
|
||||||
{
|
{
|
||||||
CGHeroInstance *hero = gs->getHero(gs->getPlayer(player)->currentSelection);
|
CGHeroInstance *hero = gs->getHero(currObj);
|
||||||
CGTownInstance *town;
|
CGTownInstance *town;
|
||||||
|
|
||||||
if (hero)
|
if (hero)
|
||||||
town = hero->visitedTown;
|
town = hero->visitedTown;
|
||||||
else
|
else
|
||||||
town = gs->getTown(gs->getPlayer(player)->currentSelection);
|
town = gs->getTown(currObj);
|
||||||
|
|
||||||
if (town)
|
if (town)
|
||||||
{
|
{
|
||||||
@ -3836,7 +3836,7 @@ void CGameHandler::playerMessage( PlayerColor player, const std::string &message
|
|||||||
}
|
}
|
||||||
else if(message == "vcmiainur") //gives 5 archangels into each slot
|
else if(message == "vcmiainur") //gives 5 archangels into each slot
|
||||||
{
|
{
|
||||||
CGHeroInstance *hero = gs->getHero(gs->getPlayer(player)->currentSelection);
|
CGHeroInstance *hero = gs->getHero(currObj);
|
||||||
const CCreature *archangel = VLC->creh->creatures.at(13);
|
const CCreature *archangel = VLC->creh->creatures.at(13);
|
||||||
if(!hero) return;
|
if(!hero) return;
|
||||||
|
|
||||||
@ -3846,7 +3846,7 @@ void CGameHandler::playerMessage( PlayerColor player, const std::string &message
|
|||||||
}
|
}
|
||||||
else if(message == "vcmiangband") //gives 10 black knight into each slot
|
else if(message == "vcmiangband") //gives 10 black knight into each slot
|
||||||
{
|
{
|
||||||
CGHeroInstance *hero = gs->getHero(gs->getPlayer(player)->currentSelection);
|
CGHeroInstance *hero = gs->getHero(currObj);
|
||||||
const CCreature *blackKnight = VLC->creh->creatures.at(66);
|
const CCreature *blackKnight = VLC->creh->creatures.at(66);
|
||||||
if(!hero) return;
|
if(!hero) return;
|
||||||
|
|
||||||
@ -3856,7 +3856,7 @@ void CGameHandler::playerMessage( PlayerColor player, const std::string &message
|
|||||||
}
|
}
|
||||||
else if(message == "vcminoldor") //all war machines
|
else if(message == "vcminoldor") //all war machines
|
||||||
{
|
{
|
||||||
CGHeroInstance *hero = gs->getHero(gs->getPlayer(player)->currentSelection);
|
CGHeroInstance *hero = gs->getHero(currObj);
|
||||||
if(!hero) return;
|
if(!hero) return;
|
||||||
|
|
||||||
if(!hero->getArt(ArtifactPosition::MACH1))
|
if(!hero->getArt(ArtifactPosition::MACH1))
|
||||||
@ -3868,24 +3868,24 @@ void CGameHandler::playerMessage( PlayerColor player, const std::string &message
|
|||||||
}
|
}
|
||||||
else if (message == "vcmiforgeofnoldorking") //hero gets all artifacts except war machines, spell scrolls and spell book
|
else if (message == "vcmiforgeofnoldorking") //hero gets all artifacts except war machines, spell scrolls and spell book
|
||||||
{
|
{
|
||||||
CGHeroInstance *hero = gs->getHero(gs->getPlayer(player)->currentSelection);
|
CGHeroInstance *hero = gs->getHero(currObj);
|
||||||
if(!hero) return;
|
if(!hero) return;
|
||||||
for (int g = 7; g < VLC->arth->artifacts.size(); ++g) //including artifacts from mods
|
for (int g = 7; g < VLC->arth->artifacts.size(); ++g) //including artifacts from mods
|
||||||
giveHeroNewArtifact(hero, VLC->arth->artifacts.at(g), ArtifactPosition::PRE_FIRST);
|
giveHeroNewArtifact(hero, VLC->arth->artifacts.at(g), ArtifactPosition::PRE_FIRST);
|
||||||
}
|
}
|
||||||
else if(message == "vcmiglorfindel") //selected hero gains a new level
|
else if(message == "vcmiglorfindel") //selected hero gains a new level
|
||||||
{
|
{
|
||||||
CGHeroInstance *hero = gs->getHero(gs->getPlayer(player)->currentSelection);
|
CGHeroInstance *hero = gs->getHero(currObj);
|
||||||
changePrimSkill(hero, PrimarySkill::EXPERIENCE, VLC->heroh->reqExp(hero->level+1) - VLC->heroh->reqExp(hero->level));
|
changePrimSkill(hero, PrimarySkill::EXPERIENCE, VLC->heroh->reqExp(hero->level+1) - VLC->heroh->reqExp(hero->level));
|
||||||
}
|
}
|
||||||
else if(message == "vcminahar") //1000000 movement points
|
else if(message == "vcminahar") //1000000 movement points
|
||||||
{
|
{
|
||||||
CGHeroInstance *hero = gs->getHero(gs->getPlayer(player)->currentSelection);
|
CGHeroInstance *hero = gs->getHero(currObj);
|
||||||
if(!hero) return;
|
if(!hero) return;
|
||||||
SetMovePoints smp;
|
SetMovePoints smp;
|
||||||
smp.hid = hero->id;
|
smp.hid = hero->id;
|
||||||
smp.val = 1000000;
|
smp.val = 1000000;
|
||||||
sendAndApply(&smp);*/
|
sendAndApply(&smp);
|
||||||
}
|
}
|
||||||
else if(message == "vcmiformenos") //give resources
|
else if(message == "vcmiformenos") //give resources
|
||||||
{
|
{
|
||||||
|
@ -198,7 +198,7 @@ public:
|
|||||||
void handleConnection(std::set<PlayerColor> players, CConnection &c);
|
void handleConnection(std::set<PlayerColor> players, CConnection &c);
|
||||||
PlayerColor getPlayerAt(CConnection *c) const;
|
PlayerColor getPlayerAt(CConnection *c) const;
|
||||||
|
|
||||||
void playerMessage( PlayerColor player, const std::string &message);
|
void playerMessage( PlayerColor player, const std::string &message, ObjectInstanceID currObj);
|
||||||
bool makeBattleAction(BattleAction &ba);
|
bool makeBattleAction(BattleAction &ba);
|
||||||
bool makeAutomaticAction(const CStack *stack, BattleAction &ba); //used when action is taken by stack without volition of player (eg. unguided catapult attack)
|
bool makeAutomaticAction(const CStack *stack, BattleAction &ba); //used when action is taken by stack without volition of player (eg. unguided catapult attack)
|
||||||
void handleSpellCasting(SpellID spellID, int spellLvl, BattleHex destination, ui8 casterSide, PlayerColor casterColor, const CGHeroInstance * caster, const CGHeroInstance * secHero,
|
void handleSpellCasting(SpellID spellID, int spellLvl, BattleHex destination, ui8 casterSide, PlayerColor casterColor, const CGHeroInstance * caster, const CGHeroInstance * secHero,
|
||||||
|
@ -285,6 +285,6 @@ bool PlayerMessage::applyGh( CGameHandler *gh )
|
|||||||
{
|
{
|
||||||
ERROR_IF_NOT(player);
|
ERROR_IF_NOT(player);
|
||||||
if(gh->getPlayerAt(c) != player) ERROR_AND_RETURN;
|
if(gh->getPlayerAt(c) != player) ERROR_AND_RETURN;
|
||||||
gh->playerMessage(player,text);
|
gh->playerMessage(player,text, currObj);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user