Files
source/Strategic/Scheduling.h
T
00fb898600 Delete builddefines.h
Nothing was left in it but the include of profiler.h, and 132 translation units
were including it for that alone. Fifteen files were leaning on profiler.h to
drag in <set>, <vector> and <ostream> for them; those now include what they use.

This is the commit that moves line numbers. Removing an include line shifts
__LINE__ by one for everything below it, and __LINE__ is an immediate operand in
every Assert() and DebugMsg() call, so the four game executables differ from
their predecessors by roughly a thousand 32-bit constants each. Every one of
those is accounted for: each is a single immediate that moved by -1 where the
builddefines.h include went away, or +1 where a <set>/<vector> include was
added. Nothing else in .text, .rdata or .data moves, no object file's section
sizes change, and symbolize_crash and Ja2Export stay bit-identical.

The one non-immediate difference is that the 24 Editor translation units of the
non-editor apps stop emitting __Avx2WmemEnabledWeakValue, a 4-byte weak COMDAT
they only ever instantiated through profiler.h's <vector>. It is a UCRT weak
default that other translation units still provide.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-22 01:07:26 -03:00

143 lines
5.4 KiB
C++

#ifndef __SCHEDULING_H
#define __SCHEDULING_H
#include "Soldier Init List.h"
//Merc scheduling actions
//NOTE: Any modifications to this enumeration also require updating the text in EditorMercs.c used
// in the editor for merc schedule purposes.
enum
{
SCHEDULE_ACTION_NONE,
SCHEDULE_ACTION_LOCKDOOR,
SCHEDULE_ACTION_UNLOCKDOOR,
SCHEDULE_ACTION_OPENDOOR,
SCHEDULE_ACTION_CLOSEDOOR,
SCHEDULE_ACTION_GRIDNO,
SCHEDULE_ACTION_LEAVESECTOR,
SCHEDULE_ACTION_ENTERSECTOR,
SCHEDULE_ACTION_STAYINSECTOR,
SCHEDULE_ACTION_SLEEP,
SCHEDULE_ACTION_WAKE,
NUM_SCHEDULE_ACTIONS
};
#define SCHEDULE_FLAGS_VARIANCE1 0x0001
#define SCHEDULE_FLAGS_VARIANCE2 0x0002
#define SCHEDULE_FLAGS_VARIANCE3 0x0004
#define SCHEDULE_FLAGS_VARIANCE4 0x0008
#define SCHEDULE_FLAGS_ACTIVE1 0x0010
#define SCHEDULE_FLAGS_ACTIVE2 0x0020
#define SCHEDULE_FLAGS_ACTIVE3 0x0040
#define SCHEDULE_FLAGS_ACTIVE4 0x0080
#define SCHEDULE_FLAGS_TEMPORARY 0x0100 //for default schedules -- not saved.
#define SCHEDULE_FLAGS_SLEEP_CONVERTED 0x0200 //converted (needs to be uncoverted before saving)
#define SCHEDULE_FLAGS_NPC_SLEEPING 0x0400 //if processing a sleep command, this flag will be set.
// combo flag for turning active flags off
#define SCHEDULE_FLAGS_ACTIVE_ALL 0x00F0
//dnl ch42 260909
#define MAX_SCHEDULE_ACTIONS 4//dnl Now is possible to extend beyond 4 and old maps should be correctly load, but didn't test behaviour in game
#define OLD_MAX_SCHEDULE_ACTIONS 4
// WANNE - BMP: DONE!
typedef struct _OLD_SCHEDULENODE
{
struct _OLD_SCHEDULENODE *next;
UINT16 usTime[OLD_MAX_SCHEDULE_ACTIONS]; //converted to minutes 12:30PM would be 12*60 + 30 = 750
UINT16 usData1[OLD_MAX_SCHEDULE_ACTIONS]; //typically the gridno, but depends on the action
UINT16 usData2[OLD_MAX_SCHEDULE_ACTIONS]; //secondary information, not used by most actions
UINT8 ubAction[OLD_MAX_SCHEDULE_ACTIONS];
UINT8 ubScheduleID;
UINT8 ubSoldierID;
UINT16 usFlags;
}_OLD_SCHEDULENODE;
typedef struct _OLD_SCHEDULENODE_PRE_ITS
{
struct _OLD_SCHEDULENODE_PRE_ITS* next;
UINT16 usTime[MAX_SCHEDULE_ACTIONS]; // Converted to minutes 12:30PM would be 12*60 + 30 = 750
UINT32 usData1[MAX_SCHEDULE_ACTIONS]; // Typically the gridno, but depends on the action
UINT32 usData2[MAX_SCHEDULE_ACTIONS]; // Secondary information, not used by most actions
UINT8 ubAction[MAX_SCHEDULE_ACTIONS];
UINT8 ubScheduleID;
UINT8 ubSoldierID;
UINT16 usFlags;
}_OLD_SCHEDULENODE_PRE_ITS;
class SCHEDULENODE
{
public:
SCHEDULENODE *next;
UINT16 usTime[MAX_SCHEDULE_ACTIONS]; // Converted to minutes 12:30PM would be 12*60 + 30 = 750
UINT32 usData1[MAX_SCHEDULE_ACTIONS]; // Typically the gridno, but depends on the action
UINT32 usData2[MAX_SCHEDULE_ACTIONS]; // Secondary information, not used by most actions
UINT8 ubAction[MAX_SCHEDULE_ACTIONS];
UINT8 ubScheduleID;
SoldierID ubSoldierID;
UINT16 usFlags;
public:
SCHEDULENODE& operator=(const _OLD_SCHEDULENODE& src);
SCHEDULENODE& operator=(const _OLD_SCHEDULENODE_PRE_ITS& src);
BOOLEAN Load(INT8** hBuffer, FLOAT dMajorMapVersion);
BOOLEAN Save(HWFILE hFile, FLOAT dMajorMapVersion, UINT8 ubMinorMapVersion);
};
extern UINT8 gubScheduleID;
extern SCHEDULENODE *gpScheduleList;
//Access functions
SCHEDULENODE* GetSchedule( UINT8 ubScheduleID );
//Removes all schedules from the event list, and cleans out the list.
void DestroyAllSchedules();
void DestroyAllSchedulesWithoutDestroyingEvents();
//This is the callback whenever a schedule is processed
void ProcessTacticalSchedule( UINT8 ubScheduleID );
void DeleteSchedule( UINT8 ubScheduleID );
void LoadSchedules( INT8 **hBuffer, FLOAT dMajorMapVersion );
BOOLEAN LoadSchedulesFromSave( HWFILE hFile );
BOOLEAN SaveSchedules(HWFILE hFile, FLOAT dMajorMapVersion=MAJOR_MAP_VERSION, UINT8 ubMinorMapVersion=MINOR_MAP_VERSION);//dnl ch33 240909
void PostSchedule( SOLDIERTYPE *pSoldier );
void PostDefaultSchedule( SOLDIERTYPE *pSoldier );
void PostNextSchedule( SOLDIERTYPE *pSoldier );
//After the world is loaded and the temp modifications have been applied,
//we then need to post the events and process schedules for the time that we have been gone.
void PostSchedules();
//Sorts the schedule in chronological order. Returns TRUE if any sorting took place.
BOOLEAN SortSchedule( SCHEDULENODE *pSchedule );
//Adds a schedule to the list. COPIES THE DATA OVER (ALLOCATES NEW NODE!)
void CopyScheduleToList( SCHEDULENODE *pSchedule, SOLDIERINITNODE *pNode );
//Entering the editor automatically removes all events posted.
void PrepareSchedulesForEditorEntry();
//Leaving the editor and entering the game posts the events.
void PrepareSchedulesForEditorExit();
//Packs all of the scheduleIDs, and updates the links. This is done whenever necessary and
//before saving the map, as this forces the IDs to align with the SOLDIERINITNODE->ubScheduleID's.
void OptimizeSchedules();
void PerformActionOnDoorAdjacentToGridNo( UINT8 ubScheduleAction, INT32 usMapIndex );
BOOLEAN ExtractScheduleEntryAndExitInfo( SOLDIERTYPE * pSoldier, UINT32 * puiEntryTime, UINT32 * puiExitTime );
BOOLEAN ExtractScheduleDoorLockAndUnlockInfo( SOLDIERTYPE * pSoldier, UINT32 * puiOpeningTime, UINT32 * puiClosingTime );
void ReconnectSchedules( void );
void SecureSleepSpot( SOLDIERTYPE * pSoldier, UINT32 usSleepSpot );
BOOLEAN BumpAnyExistingMerc( INT32 sGridNo );
#endif