1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-27 00:41:08 +02:00

Entities redesign and a few ERM features

* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
This commit is contained in:
AlexVinS
2018-03-17 17:58:30 +03:00
committed by AlexVinS
parent 11bb46780a
commit ecaa9f5d0b
475 changed files with 22491 additions and 7123 deletions

View File

@ -14,6 +14,8 @@
#include <boost/program_options.hpp>
#include <vcmi/scripting/Service.h>
#include "gui/SDL_Extensions.h"
#include "CGameInfo.h"
#include "mapHandler.h"
@ -46,9 +48,9 @@
#include "../lib/NetPacks.h"
#include "CMessage.h"
#include "../lib/CModHandler.h"
#include "../lib/ScriptHandler.h"
#include "../lib/CTownHandler.h"
#include "../lib/CArtHandler.h"
#include "../lib/CScriptingModule.h"
#include "../lib/GameConstants.h"
#include "gui/CGuiHandler.h"
#include "../lib/logging/CBasicLogConfigurator.h"
@ -95,14 +97,13 @@ SDL_Surface *screen = nullptr, //main screen surface
*screen2 = nullptr, //and hlp surface (used to store not-active interfaces layer)
*screenBuf = screen; //points to screen (if only advmapint is present) or screen2 (else) - should be used when updating controls which are not regularly redrawed
std::queue<SDL_Event> events;
std::queue<SDL_Event> SDLEventsQueue;
boost::mutex eventsM;
static po::variables_map vm;
//static bool setResolution = false; //set by event handling thread after resolution is adjusted
static bool ermInteractiveMode = false; //structurize when time is right
void processCommand(const std::string &message);
static void setScreenRes(int w, int h, int bpp, bool fullscreen, int displayIndex, bool resetVideo=true);
void playIntro();
@ -576,29 +577,10 @@ void processCommand(const std::string &message)
// if(LOCPLINT && LOCPLINT->cingconsole)
// LOCPLINT->cingconsole->print(message);
if(ermInteractiveMode)
{
if(cn == "exit")
{
ermInteractiveMode = false;
return;
}
else
{
if(CSH->client && CSH->client->erm)
CSH->client->erm->executeUserCommand(message);
std::cout << "erm>";
}
}
else if(message==std::string("die, fool"))
if(message==std::string("die, fool"))
{
exit(EXIT_SUCCESS);
}
else if(cn == "erm")
{
ermInteractiveMode = true;
std::cout << "erm>";
}
else if(cn==std::string("activate"))
{
int what;
@ -725,6 +707,28 @@ void processCommand(const std::string &message)
std::cout << "\rExtracting done :)\n";
std::cout << " Extracted files can be found in " << outPath << " directory\n";
}
else if(message=="get scripts")
{
std::cout << "Command accepted.\t";
const bfs::path outPath =
VCMIDirs::get().userCachePath() / "extracted" / "scripts";
bfs::create_directories(outPath);
for(auto & kv : VLC->scriptHandler->objects)
{
std::string name = kv.first;
boost::algorithm::replace_all(name,":","_");
const scripting::ScriptImpl * script = kv.second.get();
bfs::path filePath = outPath / (name + ".lua");
bfs::ofstream file(filePath);
file << script->getSource();
}
std::cout << "\rExtracting done :)\n";
std::cout << " Extracted files can be found in " << outPath << " directory\n";
}
else if(message=="get txt")
{
std::cout << "Command accepted.\t";
@ -891,7 +895,7 @@ void processCommand(const std::string &message)
{
YourTurn yt;
yt.player = player;
yt.daysWithoutCastle = CSH->client->getPlayer(player)->daysWithoutCastle;
yt.daysWithoutCastle = CSH->client->getPlayerState(player)->daysWithoutCastle;
yt.applyCl(CSH->client);
};
@ -1360,7 +1364,7 @@ static void handleEvent(SDL_Event & ev)
{
boost::unique_lock<boost::mutex> lock(eventsM);
events.push(ev);
SDLEventsQueue.push(ev);
}
}