Forgot to commit the source changes in the last commit. Sorry. So, here they are.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5999 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
feynman
2013-04-14 15:54:56 +00:00
parent 25de719d79
commit 8f3bff764b
26 changed files with 11543 additions and 9871 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,221 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="ModularizedTacticalAI"
ProjectGUID="{FF0A809E-A370-4640-A301-17B76D7A5B4E}"
RootNamespace="ModularizedTacticalAI"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="..\ja2.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
InheritedPropertySheets="..\ja2_VS2008.vsprops"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="&quot;C:\Documents and Settings\jcd\Desktop\ja2_v1.13\Build\ext\VFS\include&quot;"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\src\LegacyAIPlan.cpp"
>
</File>
<File
RelativePath=".\src\LegacyAIPlanFactory.cpp"
>
</File>
<File
RelativePath=".\src\NullPlan.cpp"
>
</File>
<File
RelativePath=".\src\NullPlanFactory.cpp"
>
</File>
<File
RelativePath=".\src\PlanFactoryLibrary.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\include\AbstractPlanFactory.h"
>
</File>
<File
RelativePath=".\include\LegacyAIPlan.h"
>
</File>
<File
RelativePath=".\include\LegacyAIPlanFactory.h"
>
</File>
<File
RelativePath=".\include\NullPlan.h"
>
</File>
<File
RelativePath=".\include\NullPlanFactory.h"
>
</File>
<File
RelativePath=".\include\Plan.h"
>
</File>
<File
RelativePath=".\include\PlanFactoryLibrary.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
@@ -0,0 +1,77 @@
/**
* @file
* @author feynman (bears-pit.com)
*/
#ifndef ABSTRACT_PLAN_FACTORY_H_
#define ABSTRACT_PLAN_FACTORY_H_
class SOLDIERTYPE;
namespace AI
{
namespace tactical
{
/**@class AIInputData
* @brief Wrapper class around the environmental data required to build an AI plan
*
* At the moment, simply a wrapper around SOLDIERTYPE. Future versions might require more data; without the
* wrapper, *every* Concrete Factory ever created would need to be changed in this event. With the wrapper, no
* change is required at all.
*/
struct AIInputData
{
SOLDIERTYPE* npc_to_plan_for_;
};
class Plan;
/**@class AbstractPlanFactory
* @brief Abstract Factory. Base class for all plan factories.
*
* The Abstract Factory design pattern is used to create instances of Plan object hierarchies. The concrete
* factories differ not necessarily in the concrete product they produce (as is otherwise the case when using
* this design pattern), but in the structure of the compositions (plans are Composites) instead. Public
* inheritance is required for two reasons: (a) several sub-class instances are packed in a container, and this
* abstract class serves as the container's data type. And (b) implementation of create_plan() and update_plan()
* is forced for concrete subclasses.
*/
class AbstractPlanFactory
{
private:
bool initialize_called_;
public:
AbstractPlanFactory() : initialize_called_(false) { }
bool initialize_called() const { return initialize_called_; }
/**@brief Used for delayed initialization of ressource-intensive initialization tasks
*
* Due to the design of the modularized AI, each factory's constructor must be called, even if the
* factory is not used. Therefore, memory- and cpu intensive tasks should not be performed in the
* constructor, but in this function instead. It will only be called if the factory is actually
* referenced in the AI.ini file.
*/
virtual void initialize() { };
/**@brief Abstract Plan object hierarchy creation function
*
* The subclasses (i.e., Concrete Factories) implpmenting this routine contain
* the decision-making AI core.
*
* @param input A pointer to a structure containing all required input data in order for the AI
* algorithms to perform their task. At the moment, simply a wrapper around SOLDIERTYPE. Future versions
* might require other datatypes; without the wrapper, *every* Concrete Factory ever created would need
* to be changed in this event.
* @return A Plan object tree representing the produced strategy
*/
virtual Plan* create_plan(const AIInputData& input) = 0;
/**@brief Abstract Plan object hierarchy update function, called in order to update an already created
* plan
*
* @param input A pointer to a structure containing all required input data in order for the AI
* algorithms to perform their task
* @param plan_to_change The Plan object hierarchy that is to be updated
*/
virtual void update_plan(const AIInputData& input, Plan* plan_to_change) = 0;
};
}
}
#endif
@@ -0,0 +1,32 @@
/**
* @file
* @author feynman (bears-pit.com)
*/
#ifndef LEGACY_AI_PLAN_H_
#define LEGACY_AI_PLAN_H_
#include "Plan.h"
namespace AI
{
namespace tactical
{
/**@class LegacyAIPlan
* @brief Component/Concrete Product. Generates a Plan that executes the AI as it was before modularization.
*
* A simple encapsulation of the functions TurnBasedHandleNPCAI() and RTHandleAI(), defined in
* TacticalAI/AIMain.cpp and TacticalAI/Realtime.cpp, respectively. The AI handles decisions for all kinds of
* NPCs (enemies, zombies, civilians, ...)
*/
class LegacyAIPlan: public Plan
{
private:
public:
virtual void execute(bool turn_based, PlanInputData& manipulated_object);
};
}
}
#endif
@@ -0,0 +1,32 @@
/**
* @file
* @author feynman (bears-pit.com)
*/
#ifndef LEGACY_AI_PLAN_FACTORY_H_
#define LEGACY_AI_PLAN_FACTORY_H_
#include "AbstractPlanFactory.h"
#include <string>
namespace AI
{
namespace tactical
{
/**@class LegacyAIPlanFactory
* @brief Concrete Factory. Generates the LegacyAIPlan, making NPCs do exactly what it did before this AI
* modularization/re-write.
*/
class LegacyAIPlanFactory : public AbstractPlanFactory
{
private:
public:
static std::string get_name() {return "LegacyAIPlanFactory";}
virtual Plan* create_plan(const AIInputData& input);
virtual void update_plan(const AIInputData& input, Plan* plan_to_change);
};
}
}
#endif
+41
View File
@@ -0,0 +1,41 @@
/**
* @file
* @author feynman (bears-pit.com)
*/
#ifndef NULL_PLAN_H_
#define NULL_PLAN_H_
#include "Plan.h"
namespace AI
{
namespace tactical
{
/**@class NullPlan
* @brief Component/Concrete Product. The NullPlan lets makes the NPC executing it do absolutely nothing.
*
* The purpose of this plan is two-fold. Firstly, it is a good starting point for new plans; to use it
* as such, perform a
* - \c svn copy include/NullPlan.h include/YourPlan.h
* - \c svn copy src/NullPlan.cpp src/YourPlan.cpp
*
* Remember to
*
* - Adjust the include guards
* - A concrete factory using this plan is required in order for it to be used
*
* And secondly, it is a debugging tool (cf. NullPlanFactory)
*/
class NullPlan: public Plan
{
private:
public:
virtual void execute(bool turn_based, PlanInputData& manipulated_object);
};
}
}
#endif
@@ -0,0 +1,46 @@
/**
* @file
* @author feynman (bears-pit.com)
*/
#ifndef NULL_PLAN_FACTORY_H_
#define NULL_PLAN_FACTORY_H_
#include "AbstractPlanFactory.h"
#include <string>
namespace AI
{
namespace tactical
{
/**@class NullPlanFactory
* @brief Concrete Factory. Generates the NullPlan, making a NPC do absolutely nothing.
*
* The purpose of this factory is two-fold. Firstly, it is a good starting point for new plan factories; to use
* it as such, perform a
* \c svn copy include/NullPlanFactory.h include/YourPlanFactory.h\n
* \c svn copy src/NullPlanFactory.cpp src/YourPlanFactory.cpp
*
* Remember to
* - Adjust the include guards
* - Adjust the string returned by get_name()
* - Add a line in PlanFactoryLibrary.cpp to create an instance of the new factory in the library's
* constructor; otherwise, it won't be accessible via the configuration file.
*
* And secondly, it is a debugging tool. Change the configuration file to use this AI factory for a certain
* AI_INDEX to have said group do... nothing (e.g. to measure performance differences).
*/
class NullPlanFactory : public AbstractPlanFactory
{
private:
public:
static std::string get_name() {return "NullPlanFactory";}
virtual Plan* create_plan(const AIInputData& input);
virtual void update_plan(const AIInputData& input, Plan* plan_to_change);
};
}
}
#endif
+52
View File
@@ -0,0 +1,52 @@
/**
* @file
* @author feynman (bears-pit.com)
*/
#ifndef PLAN_H_
#define PLAN_H_
class SOLDIERTYPE;
namespace AI
{
namespace tactical
{
/**@class PlanInputData
* @brief Wrapper class around the entity manipulated through plan execution
*
* At the moment, simply a wrapper around SOLDIERTYPE. Future versions might require other datatypes; without
* the wrapper, *every* Plan subclass ever created would need to be changed in this event. With the wrapper, no
* change is required at all.
*/
struct PlanInputData
{
SOLDIERTYPE* controlled_npc_;
};
/**@class Plan
* @brief Composite/Abstract Product. Base class for all plan compositions and components.
*
* The Plan class provides a common interface for both plan compositions and plan components.
*/
class Plan
{
private:
public:
/** @brief Plan execution is the encapsulation of an action sequence, making up higher-level building blocks
*
* Each plan objects represents a high-level action, implemented by means of lower-level actions. These
* lower level actions can be other Plans subtypes; at some point, a Plan object has no further
* sub-plans, i.e., the objet is no composition, but a component, forming a leaf in the Plan hierarchy.
* The components' lower level actions are formed by the fundamental npc actions made available outside
* the AI framework.
*
* @param turn_based true if turn-based mode is active, false for real-time mode
* @param manipulated_object Encapsulation of around object(s) a plan may manipulate.
*/
virtual void execute(bool turn_based, PlanInputData& manipulated_object) = 0;
};
}
}
#endif
@@ -0,0 +1,42 @@
/**
* @file
* @author feynman (bears-pit.com)
*/
#ifndef PLAN_FACTORY_LIBRARY_H_
#define PLAN_FACTORY_LIBRARY_H_
#include <string>
#include <map>
#include <deque>
namespace AI
{
namespace tactical
{
// forward declarations
class AbstractPlanFactory;
class Plan;
struct AIInputData;
/**@class PlanFactoryLibrary
* @brief Singleton. A "library" containing all available PlanFactories, accessible via the strings returned by
* their get_name() function.
*
*/
class PlanFactoryLibrary
{
private:
static PlanFactoryLibrary* instance_;
std::map<std::string, AbstractPlanFactory*> registred_factories_;
std::deque<AbstractPlanFactory*> ai_index_to_factory_mapping_;
PlanFactoryLibrary();
public:
static PlanFactoryLibrary* instance();
Plan* create_plan(size_t index, AIInputData& input) const;
};
}
}
#endif
+27
View File
@@ -0,0 +1,27 @@
API Documentation
=================
The API documentation is available in the source code repository under
./Developer_Docs/ModularizedAI/html/index.html
Coding style guidelines
=======================
When modifying or adding to the code in ModularizedTacticalAI, plese adhere to
the following rules in order to keep the place tidy.
- Do indent code blocks by 4 spaces
- Do not use tabs; they are interpreted differently on each platform, messing up the indention
- Do not #include compilation units (cpp files). Doing so will lead to you facing the firing squad.
- Do try to limit the number of include files to what is really needed. If a lot is needed, consider using the Pimpl
idiom.
- Do not use leading underscores or double underscores. They are reserved for compiler implementation.
- Do document your code using Doxygen-style comments, and update the doxygen documentation by running doxygen in the
ModularizedTacticalAI directory.
- Do use identifier names that reflect what you are doing.
- Do use CamelCase for classes, and all_lowercase_characters() for function names and attributes
- Do use one trailing underscore for class_members_
- Do not event think about adding a global variable, goto, macros (unless absolutely needed) or other BS.
- Do follow the C++ specifications, as in ISO 14882
- Do, if you feel that these guidelines are an impediment for your work, discuss alternatives at bears-pit.com
@@ -0,0 +1,28 @@
/**
* @file
* @author feynman (bears-pit.com)
*/
#include "../include/LegacyAIPlan.h"
#include "../../TacticalAI/ai.h" // for EndAIGuysTurn
// Forward declarations for the two legacy functions called here
void RTHandleAI( SOLDIERTYPE * pSoldier ); // defined in TacticalAI/Realtime.cpp
void TurnBasedHandleNPCAI(SOLDIERTYPE *pSoldier); // defined in TacticalAI/AIMain.cpp
namespace AI
{
namespace tactical
{
void LegacyAIPlan::execute(bool turn_based, PlanInputData& manipulated_object)
{
if(turn_based)
TurnBasedHandleNPCAI(manipulated_object.controlled_npc_);
else
RTHandleAI(manipulated_object.controlled_npc_);
}
}
}
@@ -0,0 +1,25 @@
/**
* @file
* @author feynman (bears-pit.com)
*/
#include "../include/LegacyAIPlanFactory.h"
#include "../include/LegacyAIPlan.h"
namespace AI
{
namespace tactical
{
Plan* LegacyAIPlanFactory::create_plan(const AIInputData& input)
{
return new LegacyAIPlan();
}
void LegacyAIPlanFactory::update_plan(const AIInputData& input, Plan* plan_to_change)
{
// TODO: currently, everything is handled in the LegacyAIPlan. The goal is to modularize the AI, so that in
// the end, the LegacyAIPlan is split into so many "new" AI Plan subclasses, that every case is covered.
// Then the behavior of the old AI would be implemented here.
}
}
}
+21
View File
@@ -0,0 +1,21 @@
/**
* @file
* @author feynman (bears-pit.com)
*/
#include "../include/NullPlan.h"
#include "../../TacticalAI/ai.h" // for EndAIGuysTurn
namespace AI
{
namespace tactical
{
/// Simply end the turn for the npc passed in the manipulated_object wrapper, then return.
void NullPlan::execute(bool turn_based, PlanInputData& manipulated_object)
{
EndAIGuysTurn(manipulated_object.controlled_npc_);
}
}
}
@@ -0,0 +1,25 @@
/**
* @file
* @author feynman (bears-pit.com)
*/
#include "../include/NullPlanFactory.h"
#include "../include/NullPlan.h"
#include "../Tactical/Soldier Control.h"
namespace AI
{
namespace tactical
{
Plan* NullPlanFactory::create_plan(const AIInputData& input)
{
return new NullPlan();
}
void NullPlanFactory::update_plan(const AIInputData& input, Plan* plan_to_change)
{
// the idea is to do nothing, so let's do it...
}
}
}
@@ -0,0 +1,84 @@
/**
* @file
* @author feynman (bears-pit.com)
*/
#include "../include/PlanFactoryLibrary.h"
#include "../include/NullPlanFactory.h"
#include "../include/LegacyAIPlanFactory.h"
// XXX Add includes for new factories here XXX
#include "../../Utils/INIReader.h"
#undef max // Who the fuck writes MACROS not using CAPITAL LETTERS??? You, sir, have lost your coding license. Please hand over your compiler and leave. Now.
#include <stdexcept>
#include <limits>
#include <string>
#include <sstream>
namespace AI
{
namespace tactical
{
PlanFactoryLibrary* PlanFactoryLibrary::instance_ = 0;
/*@brief Initialize all PlanFactories and map them to the slots defined by the configuration file
*
* This is the place where new factories need to be "registred" in order for them to be available using the
* settings in AI.ini
*/
PlanFactoryLibrary::PlanFactoryLibrary()
{
// ================================================================================
// XXX vv Add new factory registrations here vv XXX
registred_factories_[NullPlanFactory::get_name()] = new NullPlanFactory();
registred_factories_[LegacyAIPlanFactory::get_name()] = new LegacyAIPlanFactory();
// XXX ^^ Add new factory registrations here ^^ XXX
// ================================================================================
CIniReader ini_reader("AI.ini", true);
size_t num_slots = ini_reader.ReadInteger("Modularized Tactical AI", "NumFactories", 0, 0, std::numeric_limits<int>::max());
for(size_t i(0); i<num_slots; ++i)
{
std::stringstream slot_index;
slot_index<<"Factory_"<<i;
std::string factory_name = ini_reader.ReadString("Modularized Tactical AI", const_cast<char*>(slot_index.str().c_str()), "LegacyAIFactory");
ai_index_to_factory_mapping_.push_back(registred_factories_[factory_name]);
if(!ai_index_to_factory_mapping_.back()->initialize_called())
ai_index_to_factory_mapping_.back()->initialize();
}
}
/** @brief If no instance exists yet, create it. Return a pointer to the only existing instance of this library.
* @return Pointer to the only instance of the PlanFactoryLibrary
*/
PlanFactoryLibrary* PlanFactoryLibrary::instance()
{
if(instance_ == 0)
instance_ = new PlanFactoryLibrary();
return instance_;
}
/**@brief Create a plan for the given input using the factory at the given index
* @param index Index of the concrete plan factory to use, set in the constructor via ini settings
* @param input The environmental data required for a factory to plan
* @throws std::out_of_range for invalid index
* @throws std::logic_error for valid index, but undefined factory (most likely due to typo in AI.ini)
* @return Pointer to the only instance of the PlanFactoryLibrary
*/
Plan* PlanFactoryLibrary::create_plan(size_t index, AIInputData& input) const
{
if(index >= ai_index_to_factory_mapping_.size())
throw std::out_of_range("PlanFactoryLibrary detected invalid factory index");
if(!ai_index_to_factory_mapping_[index])
throw std::logic_error("PlanFactoryLibrary encountered a nullptr for a valid index (typo in AI.ini?)");
return ai_index_to_factory_mapping_[index]->create_plan(input);
}
}
}
+2
View File
@@ -2029,6 +2029,7 @@ BOOLEAN SOLDIERTYPE::Load(HWFILE hFile)
numBytesRead = ReadFieldByField(hFile, &this->bOverTurnAPS, sizeof(bOverTurnAPS), sizeof(INT16), numBytesRead);
numBytesRead = ReadFieldByField(hFile, &this->sMTActionGridNo, sizeof(sMTActionGridNo), sizeof(INT32), numBytesRead);
numBytesRead = ReadFieldByField(hFile, &this->usMultiTurnAction, sizeof(usMultiTurnAction), sizeof(UINT8), numBytesRead);
numBytesRead = ReadFieldByField(hFile, &this->bAIIndex, sizeof(bAIIndex), sizeof(UINT16), numBytesRead);
numBytesRead = ReadFieldByField(hFile, &this->ubFiller, sizeof(ubFiller), sizeof(UINT8), numBytesRead);
}
@@ -2037,6 +2038,7 @@ BOOLEAN SOLDIERTYPE::Load(HWFILE hFile)
this->bOverTurnAPS = 0;
this->sMTActionGridNo = NOWHERE;
this->usMultiTurnAction = 0;
this->bAIIndex = 0;
// as we added new variables, fillersize was reduced, here we account for that. We have to also read the existing fillers that now do not exist anymore
const UINT8 tmp = sizeof(bOverTurnAPS) + sizeof(this->sMTActionGridNo) + sizeof(usMultiTurnAction);
+1 -1
View File
@@ -73,4 +73,4 @@ Screens GameScreens[MAX_SCREENS] =
#endif
{ QuestDebugScreenInit, QuestDebugScreenHandle, QuestDebugScreenShutdown }
};
};
View File
-2
View File
@@ -12,8 +12,6 @@
#include "MemMan.h"
#include "Debug Control.h"
#include "mapscreen.h"
#include "Soldier Create.cpp"
#endif
#define MAX_CHAR_DATA_LENGTH 500
+8056 -8240
View File
File diff suppressed because it is too large Load Diff
+176 -226
View File
@@ -6,215 +6,193 @@
#include "Soldier Control.h"
#include "overhead types.h"
#include "soldier find.h"
#define ADD_SOLDIER_NO_PROFILE_ID 200
#define ADD_SOLDIER_NO_PROFILE_ID 200
#define MAX_REALTIME_SPEED_VAL 10
/*
enum
{
TOPTION_SUBTITLES,
TOPTION_SPEECH,
TOPTION_KEY_ADVANCE_SPEECH,
TOPTION_RTCONFIRM,
TOPTION_HIDE_BULLETS,
TOPTION_TRACKING_MODE,
TOPTION_CONFIRM_MOVE,
TOPTION_MUTE_CONFIRMATIONS,
TOPTION_SHADOWS,
TOPTION_BLOOD_N_GORE,
NUM_TOPTIONS
};
*/
#define MAX_REALTIME_SPEED_VAL 10
// Enums for waiting for mercs to finish codes
enum
{
NO_WAIT_EVENT = 0,
WAIT_FOR_MERCS_TO_WALKOFF_SCREEN,
WAIT_FOR_MERCS_TO_WALKON_SCREEN,
WAIT_FOR_MERCS_TO_WALK_TO_GRIDNO
{
NO_WAIT_EVENT = 0,
WAIT_FOR_MERCS_TO_WALKOFF_SCREEN,
WAIT_FOR_MERCS_TO_WALKON_SCREEN,
WAIT_FOR_MERCS_TO_WALK_TO_GRIDNO
};
// TACTICAL ENGINE STATUS FLAGS
typedef struct
{
UINT8 bFirstID;
UINT8 bLastID;
COLORVAL RadarColor;
INT8 bSide;
INT8 bMenInSector;
UINT8 ubLastMercToRadio;
INT8 bTeamActive;
INT8 bAwareOfOpposition;
INT8 bHuman;
UINT8 bFirstID;
UINT8 bLastID;
COLORVAL RadarColor;
INT8 bSide;
INT8 bMenInSector;
UINT8 ubLastMercToRadio;
INT8 bTeamActive;
INT8 bAwareOfOpposition;
INT8 bHuman;
} TacticalTeamType;
//for use with TacticalStatusType.ubEnemyIntention
enum
{
INTENTION_SCOUTING,
INTENTION_PATROLLING,
INTENTION_ATTACKING,
INTENTION_DEFENDING,
INTENTION_RETREATING
INTENTION_SCOUTING,
INTENTION_PATROLLING,
INTENTION_ATTACKING,
INTENTION_DEFENDING,
INTENTION_RETREATING
};
//for use with TacticalStatusType.ubEnemyIntendedRetreatDirection
enum
{
RETREAT_NORTH,
RETREAT_EAST,
RETREAT_SOUTH,
RETREAT_WEST
RETREAT_NORTH,
RETREAT_EAST,
RETREAT_SOUTH,
RETREAT_WEST
};
#define PANIC_BOMBS_HERE 0x01
#define PANIC_TRIGGERS_HERE 0x02
#define NUM_PANIC_TRIGGERS 3
#define PANIC_BOMBS_HERE 0x01
#define PANIC_TRIGGERS_HERE 0x02
#define NUM_PANIC_TRIGGERS 3
#define ENEMY_OFFERED_SURRENDER 0x01
typedef struct
{
UINT32 uiFlags;
TacticalTeamType Team[ MAXTEAMS ];
UINT8 ubCurrentTeam;
INT32 sSlideTarget;
INT16 sSlideReason;
UINT32 uiTimeSinceMercAIStart;
INT8 fPanicFlags;
INT32 sPanicTriggerGridNoUnused;
INT16 sHandGrid;
UINT8 ubSpottersCalledForBy;
UINT8 ubTheChosenOne;
UINT32 uiTimeOfLastInput;
UINT32 uiTimeSinceDemoOn;
UINT32 uiCountdownToRestart;
BOOLEAN fGoingToEnterDemo;
BOOLEAN fNOTDOLASTDEMO;
BOOLEAN fMultiplayer;
BOOLEAN fCivGroupHostile[ NUM_CIV_GROUPS ];
UINT8 ubLastBattleSectorX;
UINT8 ubLastBattleSectorY;
BOOLEAN fLastBattleWon;
INT8 bOriginalSizeOfEnemyForce;
INT8 bPanicTriggerIsAlarmUnused;
BOOLEAN fVirginSector;
BOOLEAN fEnemyInSector;
BOOLEAN fInterruptOccurred;
INT8 bRealtimeSpeed;
UINT8 ubEnemyIntention;
UINT8 ubEnemyIntendedRetreatDirection;
UINT8 ubEnemySightingOnTheirTurnEnemyID;
UINT8 ubEnemySightingOnTheirTurnPlayerID;
BOOLEAN fEnemySightingOnTheirTurn;
BOOLEAN fAutoBandageMode;
UINT8 ubAttackBusyCount;
INT8 bNumEnemiesFoughtInBattleUnused;
UINT8 ubEngagedInConvFromActionMercID;
UINT16 usTactialTurnLimitCounter;
BOOLEAN fInTopMessage;
UINT8 ubTopMessageType;
CHAR16 zTopMessageString[20];
UINT16 usTactialTurnLimitMax;
UINT32 uiTactialTurnLimitClock;
BOOLEAN fTactialTurnLimitStartedBeep;
INT8 bBoxingState;
INT8 bConsNumTurnsNotSeen;
UINT8 ubArmyGuysKilled;
UINT32 uiFlags;
TacticalTeamType Team[ MAXTEAMS ];
UINT8 ubCurrentTeam;
INT32 sSlideTarget;
INT16 sSlideReason;
UINT32 uiTimeSinceMercAIStart;
INT8 fPanicFlags;
INT32 sPanicTriggerGridNoUnused;
INT16 sHandGrid;
UINT8 ubSpottersCalledForBy;
UINT8 ubTheChosenOne;
UINT32 uiTimeOfLastInput;
UINT32 uiTimeSinceDemoOn;
UINT32 uiCountdownToRestart;
BOOLEAN fGoingToEnterDemo;
BOOLEAN fNOTDOLASTDEMO;
BOOLEAN fMultiplayer;
BOOLEAN fCivGroupHostile[ NUM_CIV_GROUPS ];
UINT8 ubLastBattleSectorX;
UINT8 ubLastBattleSectorY;
BOOLEAN fLastBattleWon;
INT8 bOriginalSizeOfEnemyForce;
INT8 bPanicTriggerIsAlarmUnused;
BOOLEAN fVirginSector;
BOOLEAN fEnemyInSector;
BOOLEAN fInterruptOccurred;
INT8 bRealtimeSpeed;
UINT8 ubEnemyIntention;
UINT8 ubEnemyIntendedRetreatDirection;
UINT8 ubEnemySightingOnTheirTurnEnemyID;
UINT8 ubEnemySightingOnTheirTurnPlayerID;
BOOLEAN fEnemySightingOnTheirTurn;
BOOLEAN fAutoBandageMode;
UINT8 ubAttackBusyCount;
INT8 bNumEnemiesFoughtInBattleUnused;
UINT8 ubEngagedInConvFromActionMercID;
UINT16 usTactialTurnLimitCounter;
BOOLEAN fInTopMessage;
UINT8 ubTopMessageType;
CHAR16 zTopMessageString[20];
UINT16 usTactialTurnLimitMax;
UINT32 uiTactialTurnLimitClock;
BOOLEAN fTactialTurnLimitStartedBeep;
INT8 bBoxingState;
INT8 bConsNumTurnsNotSeen;
UINT8 ubArmyGuysKilled;
INT32 sPanicTriggerGridNo[ NUM_PANIC_TRIGGERS ];
INT8 bPanicTriggerIsAlarm[ NUM_PANIC_TRIGGERS ];
UINT8 ubPanicTolerance[ NUM_PANIC_TRIGGERS ];
BOOLEAN fAtLeastOneGuyOnMultiSelect;
BOOLEAN fSaidCreatureFlavourQuote;
BOOLEAN fHaveSeenCreature;
BOOLEAN fKilledEnemyOnAttack;
UINT8 ubEnemyKilledOnAttack;
INT8 bEnemyKilledOnAttackLevel;
UINT16 ubEnemyKilledOnAttackLocation;
BOOLEAN fItemsSeenOnAttack;
BOOLEAN ubItemsSeenOnAttackSoldier;
BOOLEAN fBeenInCombatOnce;
BOOLEAN fSaidCreatureSmellQuote;
UINT32 usItemsSeenOnAttackGridNo;
BOOLEAN fLockItemLocators;
UINT8 ubLastQuoteSaid;
UINT8 ubLastQuoteProfileNUm;
BOOLEAN fCantGetThrough;
INT32 sCantGetThroughGridNo;
INT32 sCantGetThroughSoldierGridNo;
UINT8 ubCantGetThroughID;
BOOLEAN fDidGameJustStart;
BOOLEAN fStatChangeCheatOn;
UINT8 ubLastRequesterTargetID;
BOOLEAN fGoodToAllowCrows;
UINT8 ubNumCrowsPossible;
UINT32 uiTimeCounterForGiveItemSrc;
BOOLEAN fUnLockUIAfterHiddenInterrupt;
INT8 bNumFoughtInBattle[ MAXTEAMS ];
UINT32 uiDecayBloodLastUpdate;
UINT32 uiTimeSinceLastInTactical;
BOOLEAN fHasAGameBeenStarted;
INT8 bConsNumTurnsWeHaventSeenButEnemyDoes;
BOOLEAN fSomeoneHit;
UINT8 ubPaddingSmall;
UINT32 uiTimeSinceLastOpplistDecay;
INT8 bMercArrivingQuoteBeingUsed;
UINT8 ubEnemyKilledOnAttackKiller;
BOOLEAN fCountingDownForGuideDescription;
INT8 bGuideDescriptionCountDown;
UINT8 ubGuideDescriptionToUse;
INT8 bGuideDescriptionSectorX;
INT8 bGuideDescriptionSectorY;
INT8 fEnemyFlags;
BOOLEAN fAutoBandagePending;
BOOLEAN fHasEnteredCombatModeSinceEntering;
BOOLEAN fDontAddNewCrows;
UINT8 ubMorePadding;
UINT16 sCreatureTenseQuoteDelay;
UINT32 uiCreatureTenseQuoteLastUpdate;
// SANDRO - added these
UINT8 ubLastRequesterSurgeryTargetID;
UINT8 ubInterruptPending;
INT32 sPanicTriggerGridNo[ NUM_PANIC_TRIGGERS ];
INT8 bPanicTriggerIsAlarm[ NUM_PANIC_TRIGGERS ];
UINT8 ubPanicTolerance[ NUM_PANIC_TRIGGERS ];
BOOLEAN fAtLeastOneGuyOnMultiSelect;
BOOLEAN fSaidCreatureFlavourQuote;
BOOLEAN fHaveSeenCreature;
BOOLEAN fKilledEnemyOnAttack;
UINT8 ubEnemyKilledOnAttack;
INT8 bEnemyKilledOnAttackLevel;
UINT16 ubEnemyKilledOnAttackLocation;
BOOLEAN fItemsSeenOnAttack;
BOOLEAN ubItemsSeenOnAttackSoldier;
BOOLEAN fBeenInCombatOnce;
BOOLEAN fSaidCreatureSmellQuote;
UINT32 usItemsSeenOnAttackGridNo;
BOOLEAN fLockItemLocators;
UINT8 ubLastQuoteSaid;
UINT8 ubLastQuoteProfileNUm;
BOOLEAN fCantGetThrough;
INT32 sCantGetThroughGridNo;
INT32 sCantGetThroughSoldierGridNo;
UINT8 ubCantGetThroughID;
BOOLEAN fDidGameJustStart;
BOOLEAN fStatChangeCheatOn;
UINT8 ubLastRequesterTargetID;
BOOLEAN fGoodToAllowCrows;
UINT8 ubNumCrowsPossible;
UINT32 uiTimeCounterForGiveItemSrc;
BOOLEAN fUnLockUIAfterHiddenInterrupt;
INT8 bNumFoughtInBattle[ MAXTEAMS ];
UINT32 uiDecayBloodLastUpdate;
UINT32 uiTimeSinceLastInTactical;
BOOLEAN fHasAGameBeenStarted;
INT8 bConsNumTurnsWeHaventSeenButEnemyDoes;
BOOLEAN fSomeoneHit;
UINT8 ubPaddingSmall;
UINT32 uiTimeSinceLastOpplistDecay;
INT8 bMercArrivingQuoteBeingUsed;
UINT8 ubEnemyKilledOnAttackKiller;
BOOLEAN fCountingDownForGuideDescription;
INT8 bGuideDescriptionCountDown;
UINT8 ubGuideDescriptionToUse;
INT8 bGuideDescriptionSectorX;
INT8 bGuideDescriptionSectorY;
INT8 fEnemyFlags;
BOOLEAN fAutoBandagePending;
BOOLEAN fHasEnteredCombatModeSinceEntering;
BOOLEAN fDontAddNewCrows;
UINT8 ubMorePadding;
UINT16 sCreatureTenseQuoteDelay;
UINT32 uiCreatureTenseQuoteLastUpdate;
// SANDRO - added these
UINT8 ubLastRequesterSurgeryTargetID;
UINT8 ubInterruptPending;
// PADDING GONE!!!!!
// PADDING GONE!!!!!
} TacticalStatusType;
extern UINT8 gbPlayerNum;
extern INT8 gbShowEnemies;
extern UINT8 gbPlayerNum;
extern INT8 gbShowEnemies;
extern UINT16 gusSelectedSoldier;
extern UINT16 gusOldSelectedSoldier;
extern UINT16 gusSelectedSoldier;
extern UINT16 gusOldSelectedSoldier;
extern CHAR8 gzAlertStr[][ 30 ];
extern CHAR8 gzActionStr[][ 30 ];
extern CHAR8 gzDirectionStr[][ 30 ];
extern CHAR8 gzAlertStr[][ 30 ];
extern CHAR8 gzActionStr[][ 30 ];
extern CHAR8 gzDirectionStr[][ 30 ];
// TEMP FOR E3
extern UINT8 gubCurrentScene;
extern CHAR8 *GetSceneFilename( );
extern INT8 ubLevelMoveLink[ 10 ];
extern UINT8 gubCurrentScene;
extern CHAR8 *GetSceneFilename( );
extern INT8 ubLevelMoveLink[ 10 ];
// Soldier List used for all soldier overhead interaction
extern SOLDIERTYPE Menptr[ TOTAL_SOLDIERS ];
extern SOLDIERTYPE *MercPtrs[ TOTAL_SOLDIERS ];
extern SOLDIERTYPE Menptr[ TOTAL_SOLDIERS ];
extern SOLDIERTYPE *MercPtrs[ TOTAL_SOLDIERS ];
// MERC SLOTS - A LIST OF ALL ACTIVE MERCS
extern SOLDIERTYPE *MercSlots[ TOTAL_SOLDIERS ];
extern UINT32 guiNumMercSlots;
extern SOLDIERTYPE *MercSlots[ TOTAL_SOLDIERS ];
extern UINT32 guiNumMercSlots;
extern BOOLEAN gfMovingAnimation;
extern BOOLEAN gfMovingAnimation;
extern TacticalStatusType gTacticalStatus;
extern TacticalStatusType gTacticalStatus;
@@ -226,7 +204,7 @@ BOOLEAN InitOverhead( );
BOOLEAN ShutdownOverhead( );
BOOLEAN GetSoldier( SOLDIERTYPE **ppSoldier, UINT16 usSoldierIndex );
UINT32 CountNonVehiclesOnPlayerTeam( void );
UINT32 CountNonVehiclesOnPlayerTeam( );
INT16 NewOKDestination( SOLDIERTYPE * pCurrSoldier, INT32 sGridNo, BOOLEAN fPeopleToo, INT8 bLevel );
@@ -237,7 +215,7 @@ extern BOOLEAN FlatRoofAboveGridNo( INT32 iMapIndex );
BOOLEAN ExecuteOverhead( );
BOOLEAN ResetAllAnimationCache( );
BOOLEAN ResetAllAnimationCache( );
void EndTurn( );
void EndTurn( UINT8 ubNextTeam );
@@ -245,7 +223,7 @@ void EndTurn( UINT8 ubNextTeam );
void StartPlayerTeamTurn( BOOLEAN fDoBattleSnd, BOOLEAN fEnteringCombatMode );
void EndTacticalDemo( );
void SelectSoldier( UINT16 usSoldierID, BOOLEAN fAcknowledge, BOOLEAN fForceReselect );
void SelectSoldier( UINT16 usSoldierID, BOOLEAN fAcknowledge, BOOLEAN fForceReselect );
//Kaiden: Function declaration from UB to reveal all items after combat.
void RevealAllDroppedEnemyItems();
@@ -282,93 +260,66 @@ void SelectNextAvailSoldier( SOLDIERTYPE *pSoldier );
BOOLEAN TeamMemberNear(INT8 bTeam, INT32 sGridNo, INT32 iRange);
BOOLEAN IsValidTargetMerc( UINT8 ubSoldierID );
// FUNCTIONS FOR MANIPULATING MERC SLOTS - A LIST OF ALL ACTIVE MERCS
INT32 GetFreeMercSlot(void);
void RecountMercSlots(void);
INT32 AddMercSlot( SOLDIERTYPE *pSoldier );
BOOLEAN RemoveMercSlot( SOLDIERTYPE *pSoldier );
INT32 GetFreeMercSlot( );
INT32 AddMercSlot( SOLDIERTYPE *pSoldier );
BOOLEAN RemoveMercSlot( SOLDIERTYPE *pSoldier );
INT32 AddAwaySlot( SOLDIERTYPE *pSoldier );
INT32 AddAwaySlot( SOLDIERTYPE *pSoldier );
BOOLEAN RemoveAwaySlot( SOLDIERTYPE *pSoldier );
INT32 MoveSoldierFromMercToAwaySlot( SOLDIERTYPE * pSoldier );
INT32 MoveSoldierFromAwayToMercSlot( SOLDIERTYPE * pSoldier );
INT32 MoveSoldierFromMercToAwaySlot( SOLDIERTYPE * pSoldier );
INT32 MoveSoldierFromAwayToMercSlot( SOLDIERTYPE * pSoldier );
void EnterCombatMode( UINT8 ubStartingTeam );
void ExitCombatMode( );
void HandleTeamServices( UINT8 ubTeamNum );
void HandlePlayerServices( SOLDIERTYPE *pTeamSoldier );
void SetEnemyPresence( );
void CycleThroughKnownEnemies( );
BOOLEAN CheckForEndOfCombatMode( BOOLEAN fIncrementTurnsNotSeen );
SOLDIERTYPE * FreeUpAttacker( );
BOOLEAN PlayerTeamFull( );
void SetActionToDoOnceMercsGetToLocation( UINT8 ubActionCode, INT8 bNumMercsWaiting, UINT32 uiData1, UINT32 uiData2, UINT32 uiData3 );
void SetActionToDoOnceMercsGetToLocation( UINT8 ubActionCode, INT8 bNumMercsWaiting, UINT32 uiData1, UINT32 uiData2, UINT32 uiData3 );
void ResetAllMercSpeeds( );
BOOLEAN HandleGotoNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving, BOOLEAN fInitialMove, UINT16 usAnimState );
SOLDIERTYPE * ReduceAttackBusyCount( );
// HEADROCK HAM B2.6: Made this public so it can be used elsewhere.
INT8 CalcSuppressionTolerance( SOLDIERTYPE * pSoldier );
// HEADROCK HAM 3.2: A new function for checking the condition of nearby friendlies and returning a modifier.
INT8 CheckStatusNearbyFriendlies( SOLDIERTYPE *pSoldier );
void CommonEnterCombatModeCode( );
void CheckForPotentialAddToBattleIncrement( SOLDIERTYPE *pSoldier );
void CencelAllActionsForTimeCompression( void );
void CencelAllActionsForTimeCompression( );
BOOLEAN CheckForEndOfBattle( BOOLEAN fAnEnemyRetreated );
void AddManToTeam( INT8 bTeam );
void RemoveManFromTeam( INT8 bTeam );
void RemoveSoldierFromTacticalSector( SOLDIERTYPE *pSoldier, BOOLEAN fAdjustSelected );
void MakeCivHostile( SOLDIERTYPE *pSoldier, INT8 bNewSide );
#define REASON_NORMAL_ATTACK 1
#define REASON_EXPLOSION 2
#define REASON_NORMAL_ATTACK 1
#define REASON_EXPLOSION 2
BOOLEAN ProcessImplicationsOfPCAttack( SOLDIERTYPE * pSoldier, SOLDIERTYPE ** ppTarget, INT8 bReason );
INT32 FindAdjacentPunchTarget( SOLDIERTYPE * pSoldier, SOLDIERTYPE * pTargetSoldier, INT32 * psAdjustedTargetGridNo, UINT8 * pubDirection );
SOLDIERTYPE * CivilianGroupMemberChangesSides( SOLDIERTYPE * pAttacked );
void CivilianGroupChangesSides( UINT8 ubCivilianGroup );
void CycleVisibleEnemies( SOLDIERTYPE *pSrcSoldier );
UINT8 CivilianGroupMembersChangeSidesWithinProximity( SOLDIERTYPE * pAttacked );
void PauseAITemporarily( void );
void PauseAIUntilManuallyUnpaused( void );
void UnPauseAI( void );
void DoPOWPathChecks( void );
BOOLEAN HostileCiviliansWithGunsPresent( void );
BOOLEAN HostileCiviliansPresent( void );
BOOLEAN HostileBloodcatsPresent( void );
void PauseAITemporarily( );
void PauseAIUntilManuallyUnpaused( );
void UnPauseAI( );
void DoPOWPathChecks( );
BOOLEAN HostileCiviliansWithGunsPresent( );
BOOLEAN HostileCiviliansPresent( );
BOOLEAN HostileBloodcatsPresent( );
#ifdef ENABLE_ZOMBIES
BOOLEAN HostileZombiesPresent( void );
BOOLEAN HostileZombiesPresent( );
#endif
UINT8 NumPCsInSector( void );
UINT8 NumPCsInSector( );
void SetSoldierNonNeutral( SOLDIERTYPE * pSoldier );
void SetSoldierNeutral( SOLDIERTYPE * pSoldier );
@@ -376,13 +327,13 @@ void SetSoldierNeutral( SOLDIERTYPE * pSoldier );
void HandleThePlayerBeNotifiedOfSomeoneElseInSector();
void SetMsgBoxForPlayerBeNotifiedOfSomeoneElseInSector();
void HandleDisplayingOfPlayerLostDialogue( void );
void HandleDisplayingOfPlayerLostDialogue( );
// UTILITY FUNCTIONS
INT8 NumActiveAndConsciousTeamMembers( UINT8 ubTeam );
INT8 NumActiveAndConsciousTeamMembers( UINT8 ubTeam );
UINT8 NumEnemyInSector( );
UINT8 NumCapableEnemyInSector( );
INT8 NumMercsOnPlayerTeam( );
INT8 NumMercsOnPlayerTeam( );
#endif
extern BOOLEAN sniperwarning;
@@ -395,18 +346,17 @@ extern BOOLEAN gogglewarning;
// will a sam site under the players control shoot down an airraid?
BOOLEAN WillAirRaidBeStopped( INT16 sSectorX, INT16 sSectorY );
// HEADROCK HAM 3.5: Externalized for First Arrival enemy check
extern UINT8 NumEnemyInSector();
#ifdef ENABLE_ZOMBIES
// Flugente
extern UINT8 NumZombiesInSector();
// Flugente
extern UINT8 NumZombiesInSector();
#endif
void HandleSurrenderOffer( SOLDIERTYPE* pSoldier ); // Flugente: offer the enemy the chance to surrender
void HandleSurrenderOffer( SOLDIERTYPE* pSoldier ); // Flugente: offer the enemy the chance to surrender
// setting fForce to TRUE allows dropping of gear in combat (used in auto-resolve instances)
void TeamDropAll(UINT8 bTeam, BOOLEAN fForce = FALSE);
#endif
#endif
+10 -34
View File
@@ -100,6 +100,7 @@
#endif
#include "ub_config.h"
#include "../ModularizedTacticalAI/include/Plan.h" // for plan destructor call
#ifdef JA2UB
#include "Ja25_Tactical.h"
@@ -1023,11 +1024,16 @@ SOLDIERTYPE& SOLDIERTYPE::operator=(const OLDSOLDIERTYPE_101& src)
this->bDrinkLevel = 0;
this->usStarveDamageHealth = 0;
this->usStarveDamageStrength = 0;
this->bAIIndex = 0;
}
return *this;
}
SOLDIERTYPE::~SOLDIERTYPE() {}
SOLDIERTYPE::~SOLDIERTYPE()
{
if(ai_masterplan_)
delete ai_masterplan_;
}
SOLDIERTYPE::SOLDIERTYPE() {
initialize();
@@ -1061,38 +1067,6 @@ UINT32 SOLDIERTYPE::GetChecksum( )
return( uiChecksum );
}
// Copy Constructor
SOLDIERTYPE::SOLDIERTYPE(const SOLDIERTYPE& src)
{
memcpy(this, &src, SIZEOF_SOLDIERTYPE_POD);
inv = src.inv;
aiData = src.aiData;
flags = src.flags;
timeChanges = src.timeChanges;
timeCounters = src.timeCounters;
drugs = src.drugs;
stats = src.stats;
pathing = src.pathing;
}
// Assignment operator
SOLDIERTYPE& SOLDIERTYPE::operator=(const SOLDIERTYPE& src)
{
if (this != &src) {
memcpy(this, &src, SIZEOF_SOLDIERTYPE_POD);
aiData = src.aiData;
flags = src.flags;
timeChanges = src.timeChanges;
timeCounters = src.timeCounters;
drugs = src.drugs;
stats = src.stats;
pathing = src.pathing;
inv = src.inv;
}
return *this;
}
// Initialize the soldier.
// Use this instead of the old method of calling memset!
// Note that the constructor does this automatically.
@@ -1100,6 +1074,7 @@ void SOLDIERTYPE::initialize()
{
memset( this, 0, SIZEOF_SOLDIERTYPE_POD);
inv.clear();
ai_masterplan_ = 0;
memset( &aiData, 0, sizeof(STRUCT_AIData) );
memset( &flags, 0, sizeof(STRUCT_Flags) );
@@ -19270,4 +19245,5 @@ BOOLEAN DecideAltAnimForBigMerc( SOLDIERTYPE * pSoldier )
BOOLEAN TwoStagedTrait( UINT8 uiSkillTraitNumber )
{
return( uiSkillTraitNumber > 0 && (uiSkillTraitNumber <= NUM_ORIGINAL_MAJOR_TRAITS || uiSkillTraitNumber == COVERT_NT) );
}
}
+12 -5
View File
@@ -723,6 +723,15 @@ public:
TIMECOUNTER NextTileCounter;
};
// forward declaration for modularized tactical ai
namespace AI
{
namespace tactical
{
class Plan;
}
}
class STRUCT_Statistics//last edited at version 102
{
public:
@@ -775,10 +784,6 @@ public:
// Constructor
SOLDIERTYPE();
// Copy Constructor
SOLDIERTYPE(const SOLDIERTYPE&);
// Assignment operator
SOLDIERTYPE& operator=(const SOLDIERTYPE&);
// Destructor
~SOLDIERTYPE();
@@ -1265,8 +1270,9 @@ public:
INT32 sMTActionGridNo; // gridno on which we perfrom our multi-turn action
UINT8 usMultiTurnAction; // specifies which multi-turn action we are currently performing, 0: none
INT16 bAIIndex; // PlanFactory from the modularized tactical AI that shall be used
// Flugente: Decrease this filler by 1 for each new UINT8 / BOOLEAN variable, so we can maintain savegame compatibility!!
UINT8 ubFiller[13];
UINT8 ubFiller[11];
#ifdef JA2UB
//ja25
@@ -1285,6 +1291,7 @@ public:
// properly until it is all fixed and the files updated.
Inventory inv;
AI::tactical::Plan* ai_masterplan_; // Interface object for ModularizedTacticalAI
//data from version 101 wrapped into structs
STRUCT_AIData aiData;
+150 -220
View File
@@ -1,272 +1,202 @@
#ifdef PRECOMPILEDHEADERS
#include "Tactical All.h"
#include "Tactical All.h"
#else
#include "sgp.h"
#include "overhead types.h"
#include "Sound Control.h"
#include "overhead.h"
#include "Event Pump.h"
#include "weapons.h"
#include "Animation Control.h"
#include "sys globals.h"
#include "Handle UI.h"
#include "Isometric Utils.h"
#include "worldman.h"
#include "math.h"
#include "points.h"
#include "ai.h"
#include "los.h"
#include "renderworld.h"
#include "opplist.h"
#include "interface.h"
#include "message.h"
#include "campaign.h"
#include "items.h"
#include "text.h"
#include "Soldier Profile.h"
#include "tile animation.h"
#include "Dialogue Control.h"
#include "SkillCheck.h"
#include "explosion control.h"
#include "Quests.h"
#include "Physics.h"
#include "Random.h"
#include "Vehicles.h"
#include "bullets.h"
#include "morale.h"
#include "meanwhile.h"
#include "SkillCheck.h"
#include "gamesettings.h"
#include "SaveLoadMap.h"
#include "Debug Control.h"
#include "expat.h"
#include "XML.h"
#include <string.h>
#include "sgp.h"
#include "Sound Control.h"
#include "Debug Control.h"
#include "expat.h"
#include "XML.h"
#endif
extern char szSoundEffects[MAX_SAMPLES][255];
struct
{
PARSE_STAGE curElement;
CHAR8 szCharData[MAX_CHAR_DATA_LENGTH+1];
UINT32 maxArraySize;
UINT32 curIndex;
UINT32 currentDepth;
UINT32 maxReadDepth;
PARSE_STAGE curElement;
CHAR8 szCharData[MAX_CHAR_DATA_LENGTH+1];
UINT32 maxArraySize;
UINT32 curIndex;
UINT32 currentDepth;
UINT32 maxReadDepth;
}
typedef soundParseData;
static void XMLCALL
soundStartElementHandle(void *userData, const XML_Char *name, const XML_Char **atts)
{
soundParseData * pData = (soundParseData *)userData;
soundParseData * pData = (soundParseData *)userData;
if(pData->currentDepth <= pData->maxReadDepth) //are we reading this element?
{
if(strcmp(name, "SOUNDLIST") == 0 && pData->curElement == ELEMENT_NONE)
{
pData->curElement = ELEMENT_LIST;
if(pData->currentDepth <= pData->maxReadDepth) //are we reading this element?
{
if(strcmp(name, "SOUNDLIST") == 0 && pData->curElement == ELEMENT_NONE)
{
pData->curElement = ELEMENT_LIST;
pData->maxReadDepth++; //we are not skipping this element
}
else if(strcmp(name, "SOUND") == 0 && pData->curElement == ELEMENT_LIST)
{
pData->curElement = ELEMENT;
pData->maxReadDepth++; //we are not skipping this element
}
else if(strcmp(name, "SOUND") == 0 && pData->curElement == ELEMENT_LIST)
{
pData->curElement = ELEMENT;
pData->maxReadDepth++; //we are not skipping this element
pData->curIndex++;
}
pData->maxReadDepth++; //we are not skipping this element
pData->curIndex++;
}
pData->szCharData[0] = '\0';
}
pData->szCharData[0] = '\0';
}
pData->currentDepth++;
pData->currentDepth++;
}
static void XMLCALL
soundCharacterDataHandle(void *userData, const XML_Char *str, int len)
{
soundParseData * pData = (soundParseData *)userData;
soundParseData * pData = (soundParseData *)userData;
if( (pData->currentDepth <= pData->maxReadDepth) &&
(strlen(pData->szCharData) < MAX_CHAR_DATA_LENGTH)
){
strncat(pData->szCharData,str,__min((unsigned int)len,MAX_CHAR_DATA_LENGTH-strlen(pData->szCharData)));
}
if((pData->currentDepth <= pData->maxReadDepth) && (strlen(pData->szCharData) < MAX_CHAR_DATA_LENGTH))
{
strncat(pData->szCharData,str,__min((unsigned int)len,MAX_CHAR_DATA_LENGTH-strlen(pData->szCharData)));
}
}
static void XMLCALL
soundEndElementHandle(void *userData, const XML_Char *name)
{
soundParseData * pData = (soundParseData *)userData;
soundParseData * pData = (soundParseData *)userData;
if(pData->currentDepth <= pData->maxReadDepth) //we're at the end of an element that we've been reading
{
if(strcmp(name, "SOUNDLIST") == 0)
{
pData->curElement = ELEMENT_NONE;
}
else if(strcmp(name, "SOUND") == 0)
{
pData->curElement = ELEMENT_LIST;
if(pData->currentDepth <= pData->maxReadDepth) //we're at the end of an element that we've been reading
{
if(strcmp(name, "SOUNDLIST") == 0)
{
pData->curElement = ELEMENT_NONE;
}
else if(strcmp(name, "SOUND") == 0)
{
pData->curElement = ELEMENT_LIST;
if(pData->curIndex < pData->maxArraySize)
{
char temp;
for(int i=0;i<min((int)strlen(pData->szCharData),255);i++)
{
temp = pData->szCharData[i];
szSoundEffects[pData->curIndex][i] = temp;
}
}
}
pData->maxReadDepth--;
}
pData->currentDepth--;
if(pData->curIndex < pData->maxArraySize)
{
char temp;
for(int i=0;i<min((int)strlen(pData->szCharData),255);i++)
{
temp = pData->szCharData[i];
szSoundEffects[pData->curIndex][i] = temp;
}
}
}
pData->maxReadDepth--;
}
pData->currentDepth--;
}
BOOLEAN ReadInSoundArray(STR fileName)
{
HWFILE hFile;
UINT32 uiBytesRead;
UINT32 uiFSize;
CHAR8 * lpcBuffer;
XML_Parser parser = XML_ParserCreate(NULL);
HWFILE hFile;
UINT32 uiBytesRead;
UINT32 uiFSize;
CHAR8 * lpcBuffer;
XML_Parser parser = XML_ParserCreate(NULL);
soundParseData pData;
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("Loading %s",SOUNDSFILENAME ) );
soundParseData pData;
// Open sounds file
hFile = FileOpen( fileName, FILE_ACCESS_READ, FALSE );
if ( !hFile )
return( FALSE );
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("Loading %s",SOUNDSFILENAME ) );
uiFSize = FileGetSize(hFile);
lpcBuffer = (CHAR8 *) MemAlloc(uiFSize+1);
//Read in block
if ( !FileRead( hFile, lpcBuffer, uiFSize, &uiBytesRead ) )
{
MemFree(lpcBuffer);
return( FALSE );
}
lpcBuffer[uiFSize] = 0; //add a null terminator
FileClose( hFile );
// Open sounds file
hFile = FileOpen( fileName, FILE_ACCESS_READ, FALSE );
if ( !hFile )
return( FALSE );
uiFSize = FileGetSize(hFile);
lpcBuffer = (CHAR8 *) MemAlloc(uiFSize+1);
//Read in block
if ( !FileRead( hFile, lpcBuffer, uiFSize, &uiBytesRead ) )
{
MemFree(lpcBuffer);
return( FALSE );
}
lpcBuffer[uiFSize] = 0; //add a null terminator
FileClose( hFile );
XML_SetElementHandler(parser, soundStartElementHandle, soundEndElementHandle);
XML_SetCharacterDataHandler(parser, soundCharacterDataHandle);
memset(&pData,0,sizeof(pData));
pData.maxArraySize = MAX_SAMPLES;
pData.curIndex = -1;
XML_SetUserData(parser, &pData);
if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))
{
CHAR8 errorBuf[511];
sprintf(errorBuf, "XML Parser Error in %s.xml: %s at line %d", SOUNDSFILENAME, XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser));
LiveMessage(errorBuf);
MemFree(lpcBuffer);
return FALSE;
}
MemFree(lpcBuffer);
XML_ParserFree(parser);
return( TRUE );
XML_SetElementHandler(parser, soundStartElementHandle, soundEndElementHandle);
XML_SetCharacterDataHandler(parser, soundCharacterDataHandle);
memset(&pData,0,sizeof(pData));
pData.maxArraySize = MAX_SAMPLES;
pData.curIndex = -1;
XML_SetUserData(parser, &pData);
if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))
{
CHAR8 errorBuf[511];
sprintf(errorBuf, "XML Parser Error in %s.xml: %s at line %d", SOUNDSFILENAME, XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser));
LiveMessage(errorBuf);
MemFree(lpcBuffer);
return FALSE;
}
MemFree(lpcBuffer);
XML_ParserFree(parser);
return( TRUE );
}
BOOLEAN WriteSoundArray()
{
HWFILE hFile;
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("WriteSoundArray"));
//Debug code; make sure that what we got from the file is the same as what's there
// Open a new file
hFile = FileOpen( "TABLEDATA\\Sounds out.xml", FILE_ACCESS_WRITE | FILE_CREATE_ALWAYS, FALSE );
if ( !hFile )
return( FALSE );
HWFILE hFile;
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("WriteSoundArray"));
//Debug code; make sure that what we got from the file is the same as what's there
// Open a new file
hFile = FileOpen( "TABLEDATA\\Sounds out.xml", FILE_ACCESS_WRITE | FILE_CREATE_ALWAYS, FALSE );
if ( !hFile )
return( FALSE );
UINT32 cnt;
{
UINT32 cnt;
FilePrintf(hFile,"<SOUNDLIST>\r\n");
for(cnt = 0;cnt < NUM_SAMPLES;cnt++)
{
FilePrintf(hFile,"\t<SOUND>");
STR8 szRemainder = szSoundEffects[cnt]; //the remaining string to be output (for making valid XML)
while(szRemainder[0] != '\0')
{
UINT32 uiCharLoc = strcspn(szRemainder,"&<>\'\"\0");
char invChar = szRemainder[uiCharLoc];
FilePrintf(hFile,"<SOUNDLIST>\r\n");
for(cnt = 0;cnt < NUM_SAMPLES;cnt++)
{
FilePrintf(hFile,"\t<SOUND>");
if(uiCharLoc)
{
szRemainder[uiCharLoc] = '\0';
FilePrintf(hFile,"%s",szRemainder);
szRemainder[uiCharLoc] = invChar;
}
szRemainder += uiCharLoc;
switch(invChar)
{
case '&':
FilePrintf(hFile,"&amp;");
szRemainder++;
break;
STR8 szRemainder = szSoundEffects[cnt]; //the remaining string to be output (for making valid XML)
case '<':
FilePrintf(hFile,"&lt;");
szRemainder++;
break;
while(szRemainder[0] != '\0')
{
UINT32 uiCharLoc = strcspn(szRemainder,"&<>\'\"\0");
char invChar = szRemainder[uiCharLoc];
case '>':
FilePrintf(hFile,"&gt;");
szRemainder++;
break;
if(uiCharLoc)
{
szRemainder[uiCharLoc] = '\0';
FilePrintf(hFile,"%s",szRemainder);
szRemainder[uiCharLoc] = invChar;
}
case '\'':
FilePrintf(hFile,"&apos;");
szRemainder++;
break;
szRemainder += uiCharLoc;
switch(invChar)
{
case '&':
FilePrintf(hFile,"&amp;");
szRemainder++;
break;
case '<':
FilePrintf(hFile,"&lt;");
szRemainder++;
break;
case '>':
FilePrintf(hFile,"&gt;");
szRemainder++;
break;
case '\'':
FilePrintf(hFile,"&apos;");
szRemainder++;
break;
case '\"':
FilePrintf(hFile,"&quot;");
szRemainder++;
break;
}
}
// FilePrintf(hFile,"\t\t<SOUND>%s</SOUND>\r\n", szSoundEffects[cnt]);
FilePrintf(hFile,"</SOUND>\r\n");
}
FilePrintf(hFile,"</SOUNDLIST>\r\n");
}
FileClose( hFile );
return( TRUE );
case '\"':
FilePrintf(hFile,"&quot;");
szRemainder++;
break;
}
}
FilePrintf(hFile,"</SOUND>\r\n");
}
FilePrintf(hFile,"</SOUNDLIST>\r\n");
FileClose( hFile );
return( TRUE );
}
+572 -1136
View File
File diff suppressed because it is too large Load Diff
+19 -7
View File
@@ -1,22 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C++ Express 2008
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ja2", "ja2_VS2008.vcproj", "{B112F6BA-AF32-489C-B405-916C0F182D10}"
ProjectSection(ProjectDependencies) = postProject
{0BE7070B-C8C5-409A-82DD-0701D54A1C6C} = {0BE7070B-C8C5-409A-82DD-0701D54A1C6C}
{99341DB1-FD6E-4E87-919B-25C813F08D18} = {99341DB1-FD6E-4E87-919B-25C813F08D18}
{4D6F7570-9A1E-4DB0-8FD7-B9D14DD4E821} = {4D6F7570-9A1E-4DB0-8FD7-B9D14DD4E821}
{60D5BF89-B609-4A30-A38D-9FE417FB12B6} = {60D5BF89-B609-4A30-A38D-9FE417FB12B6}
{96FA90B1-2ABD-42E7-9CAB-14804DFD3240} = {96FA90B1-2ABD-42E7-9CAB-14804DFD3240}
{DB40B90D-13F9-4FEC-8F1D-0506CC496586} = {DB40B90D-13F9-4FEC-8F1D-0506CC496586}
{4B544F1A-6188-4255-8877-69FC312D0D2C} = {4B544F1A-6188-4255-8877-69FC312D0D2C}
{40475E2B-AD37-4A99-85A4-1E507010344C} = {40475E2B-AD37-4A99-85A4-1E507010344C}
{8E3BD72D-8791-497B-A38E-D71B255F0A66} = {8E3BD72D-8791-497B-A38E-D71B255F0A66}
{DF8C5F50-6FB1-4AFE-8EF4-6B7F360D9C28} = {DF8C5F50-6FB1-4AFE-8EF4-6B7F360D9C28}
{629F0A55-6A19-4107-8B5C-5B08B2B3949C} = {629F0A55-6A19-4107-8B5C-5B08B2B3949C}
{DB40B90D-13F9-4FEC-8F1D-0506CC496586} = {DB40B90D-13F9-4FEC-8F1D-0506CC496586}
{4B544F1A-6188-4255-8877-69FC312D0D2C} = {4B544F1A-6188-4255-8877-69FC312D0D2C}
{4D6F7570-9A1E-4DB0-8FD7-B9D14DD4E821} = {4D6F7570-9A1E-4DB0-8FD7-B9D14DD4E821}
{9AD14886-DB5C-4EFF-AE17-35F9BD684692} = {9AD14886-DB5C-4EFF-AE17-35F9BD684692}
{60D5BF89-B609-4A30-A38D-9FE417FB12B6} = {60D5BF89-B609-4A30-A38D-9FE417FB12B6}
{FF0A809E-A370-4640-A301-17B76D7A5B4E} = {FF0A809E-A370-4640-A301-17B76D7A5B4E}
{A67922A0-0A3F-497F-A724-19B513EFC078} = {A67922A0-0A3F-497F-A724-19B513EFC078}
{99341DB1-FD6E-4E87-919B-25C813F08D18} = {99341DB1-FD6E-4E87-919B-25C813F08D18}
{96FA90B1-2ABD-42E7-9CAB-14804DFD3240} = {96FA90B1-2ABD-42E7-9CAB-14804DFD3240}
{C63466D6-49B5-4C54-AA0D-864F6171FD9B} = {C63466D6-49B5-4C54-AA0D-864F6171FD9B}
EndProjectSection
EndProject
@@ -50,6 +50,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ja2export", "ext\export\ja2
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "7z", "ext\VFS\build\7z_VS2008.vcproj", "{9AD14886-DB5C-4EFF-AE17-35F9BD684692}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ModularizedTacticalAI", "ModularizedTacticalAI\ModularizedTacticalAI.vcproj", "{FF0A809E-A370-4640-A301-17B76D7A5B4E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -214,6 +216,16 @@ Global
{9AD14886-DB5C-4EFF-AE17-35F9BD684692}.Release_WithDebugInfo|Win32.Build.0 = Release_WithDebugInfo|Win32
{9AD14886-DB5C-4EFF-AE17-35F9BD684692}.Release|Win32.ActiveCfg = Release|Win32
{9AD14886-DB5C-4EFF-AE17-35F9BD684692}.Release|Win32.Build.0 = Release|Win32
{FF0A809E-A370-4640-A301-17B76D7A5B4E}.Debug|Win32.ActiveCfg = Debug|Win32
{FF0A809E-A370-4640-A301-17B76D7A5B4E}.Debug|Win32.Build.0 = Debug|Win32
{FF0A809E-A370-4640-A301-17B76D7A5B4E}.MapEditor|Win32.ActiveCfg = Release|Win32
{FF0A809E-A370-4640-A301-17B76D7A5B4E}.MapEditor|Win32.Build.0 = Release|Win32
{FF0A809E-A370-4640-A301-17B76D7A5B4E}.MapEditorD|Win32.ActiveCfg = Release|Win32
{FF0A809E-A370-4640-A301-17B76D7A5B4E}.MapEditorD|Win32.Build.0 = Release|Win32
{FF0A809E-A370-4640-A301-17B76D7A5B4E}.Release_WithDebugInfo|Win32.ActiveCfg = Release|Win32
{FF0A809E-A370-4640-A301-17B76D7A5B4E}.Release_WithDebugInfo|Win32.Build.0 = Release|Win32
{FF0A809E-A370-4640-A301-17B76D7A5B4E}.Release|Win32.ActiveCfg = Release|Win32
{FF0A809E-A370-4640-A301-17B76D7A5B4E}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE