|
|
@ -41,6 +41,7 @@
|
|
|
|
#include <string>
|
|
|
|
#include <string>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <unordered_set>
|
|
|
|
#include <unordered_set>
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace std;
|
|
|
|
using namespace DFHack;
|
|
|
|
using namespace DFHack;
|
|
|
@ -140,24 +141,58 @@ static void manageInteractionEvent(color_ostream& out);
|
|
|
|
|
|
|
|
|
|
|
|
typedef void (*eventManager_t)(color_ostream&);
|
|
|
|
typedef void (*eventManager_t)(color_ostream&);
|
|
|
|
|
|
|
|
|
|
|
|
static const eventManager_t eventManager[] = {
|
|
|
|
// integrate new events into this function, and no longer worry about syncing the enum list with the `eventManager` array
|
|
|
|
manageTickEvent,
|
|
|
|
eventManager_t getManager(EventType::EventType t) {
|
|
|
|
manageJobInitiatedEvent,
|
|
|
|
switch (t) {
|
|
|
|
manageJobStartedEvent,
|
|
|
|
case EventType::TICK:
|
|
|
|
manageJobCompletedEvent,
|
|
|
|
return manageTickEvent;
|
|
|
|
manageNewUnitActiveEvent,
|
|
|
|
case EventType::JOB_INITIATED:
|
|
|
|
manageUnitDeathEvent,
|
|
|
|
return manageJobInitiatedEvent;
|
|
|
|
manageItemCreationEvent,
|
|
|
|
case EventType::JOB_STARTED:
|
|
|
|
manageBuildingEvent,
|
|
|
|
return manageJobStartedEvent;
|
|
|
|
manageConstructionEvent,
|
|
|
|
case EventType::JOB_COMPLETED:
|
|
|
|
manageSyndromeEvent,
|
|
|
|
return manageJobCompletedEvent;
|
|
|
|
manageInvasionEvent,
|
|
|
|
case EventType::UNIT_NEW_ACTIVE:
|
|
|
|
manageEquipmentEvent,
|
|
|
|
return manageNewUnitActiveEvent;
|
|
|
|
manageReportEvent,
|
|
|
|
case EventType::UNIT_DEATH:
|
|
|
|
manageUnitAttackEvent,
|
|
|
|
return manageUnitDeathEvent;
|
|
|
|
manageUnloadEvent,
|
|
|
|
case EventType::ITEM_CREATED:
|
|
|
|
manageInteractionEvent,
|
|
|
|
return manageItemCreationEvent;
|
|
|
|
};
|
|
|
|
case EventType::BUILDING:
|
|
|
|
|
|
|
|
return manageBuildingEvent;
|
|
|
|
|
|
|
|
case EventType::CONSTRUCTION:
|
|
|
|
|
|
|
|
return manageConstructionEvent;
|
|
|
|
|
|
|
|
case EventType::SYNDROME:
|
|
|
|
|
|
|
|
return manageSyndromeEvent;
|
|
|
|
|
|
|
|
case EventType::INVASION:
|
|
|
|
|
|
|
|
return manageInvasionEvent;
|
|
|
|
|
|
|
|
case EventType::INVENTORY_CHANGE:
|
|
|
|
|
|
|
|
return manageEquipmentEvent;
|
|
|
|
|
|
|
|
case EventType::REPORT:
|
|
|
|
|
|
|
|
return manageReportEvent;
|
|
|
|
|
|
|
|
case EventType::UNIT_ATTACK:
|
|
|
|
|
|
|
|
return manageUnitAttackEvent;
|
|
|
|
|
|
|
|
case EventType::UNLOAD:
|
|
|
|
|
|
|
|
return manageUnloadEvent;
|
|
|
|
|
|
|
|
case EventType::INTERACTION:
|
|
|
|
|
|
|
|
return manageInteractionEvent;
|
|
|
|
|
|
|
|
case EventType::EVENT_MAX:
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
//default:
|
|
|
|
|
|
|
|
//we don't do this... because then the compiler wouldn't error for missing cases in the enum
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::array<eventManager_t,EventType::EVENT_MAX> compileManagerArray() {
|
|
|
|
|
|
|
|
std::array<eventManager_t, EventType::EVENT_MAX> managers{};
|
|
|
|
|
|
|
|
auto t = (EventType::EventType) 0;
|
|
|
|
|
|
|
|
while (t < EventType::EVENT_MAX) {
|
|
|
|
|
|
|
|
managers[t] = getManager(t);
|
|
|
|
|
|
|
|
t = (EventType::EventType) int(t + 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return managers;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//job initiated
|
|
|
|
//job initiated
|
|
|
|
static int32_t lastJobId = -1;
|
|
|
|
static int32_t lastJobId = -1;
|
|
|
@ -312,6 +347,7 @@ void DFHack::EventManager::onStateChange(color_ostream& out, state_change_event
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DFHack::EventManager::manageEvents(color_ostream& out) {
|
|
|
|
void DFHack::EventManager::manageEvents(color_ostream& out) {
|
|
|
|
|
|
|
|
static const std::array<eventManager_t, EventType::EVENT_MAX> eventManager = compileManagerArray();
|
|
|
|
if ( !gameLoaded ) {
|
|
|
|
if ( !gameLoaded ) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|