Skip to content

Commit d225050

Browse files
committed
Merge of 1.15 code
2 parents 7ffed3a + dc5dcb3 commit d225050

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+848
-896
lines changed

CMakeLists.txt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ include(GNUInstallDirs)
5252
option(ENABLE_TFE "Enable building “The Force Engine”" ON)
5353
option(ENABLE_SYSMIDI "Enable System-MIDI Output if RTMidi is available" ON)
5454
option(ENABLE_EDITOR "Enable TFE Editor" OFF)
55-
option(ENABLE_FORCE_SCRIPT "Enable Force Script" OFF)
5655
option(ENABLE_ADJUSTABLEHUD_MOD "Install the build‑in “AdjustableHud mod” with TFE" ON)
5756

5857
if(ENABLE_TFE)
@@ -108,15 +107,11 @@ if(ENABLE_TFE)
108107
if(ENABLE_EDITOR)
109108
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBUILD_EDITOR")
110109
endif()
111-
if(ENABLE_FORCE_SCRIPT)
112-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBUILD_FORCE_SCRIPT")
113-
endif()
110+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBUILD_FORCE_SCRIPT")
114111

115112

116-
if(ENABLE_FORCE_SCRIPT)
117-
target_include_directories(tfe PRIVATE "TheForceEngine/TFE_ForceScript/Angelscript/angelscript/include")
118-
target_include_directories(tfe PRIVATE "TheForceEngine/TFE_ForceScript/Angelscript/add_on")
119-
endif()
113+
target_include_directories(tfe PRIVATE "TheForceEngine/TFE_ForceScript/Angelscript/angelscript/include")
114+
target_include_directories(tfe PRIVATE "TheForceEngine/TFE_ForceScript/Angelscript/add_on")
120115
target_include_directories(tfe PRIVATE TheForceEngine)
121116

122117
add_subdirectory(TheForceEngine/)

TheForceEngine/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,5 @@ add_subdirectory(TFE_Ui/)
2121
if(ENABLE_EDITOR)
2222
add_subdirectory(TFE_Editor/)
2323
endif()
24-
if(ENABLE_FORCE_SCRIPT)
25-
add_subdirectory(TFE_ForceScript/)
26-
endif()
24+
add_subdirectory(TFE_ForceScript/)
2725
target_sources(tfe PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp")

TheForceEngine/TFE_Archive/zipArchive.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,17 @@ ZipArchive::~ZipArchive()
3030

3131
bool ZipArchive::create(const char *archivePath)
3232
{
33-
return false;
33+
m_curFile = INVALID_FILE;
34+
m_entryCount = 0;
35+
m_fileOffset = 0;
36+
m_tempBuffer = nullptr;
37+
m_tempBufferSize = 0;
38+
m_newFiles.clear();
39+
40+
strcpy(m_archivePath, archivePath);
41+
m_fileHandle = nullptr;
42+
43+
return true;
3444
}
3545

3646
bool ZipArchive::open(const char *archivePath)
@@ -82,6 +92,19 @@ bool ZipArchive::open(const char *archivePath)
8292

8393
void ZipArchive::close()
8494
{
95+
// Flush new files.
96+
if (!m_newFiles.empty())
97+
{
98+
const size_t fileCount = m_newFiles.size();
99+
std::vector<const char*> filePaths;
100+
for (size_t i = 0; i < fileCount; i++)
101+
{
102+
filePaths.push_back(m_newFiles[i].path.c_str());
103+
}
104+
zip_create(m_archivePath, filePaths.data(), fileCount);
105+
m_newFiles.clear();
106+
}
107+
85108
closeFile();
86109

87110
delete[] m_entries;
@@ -280,4 +303,5 @@ size_t ZipArchive::getFileLength(u32 index)
280303
// Edit
281304
void ZipArchive::addFile(const char* fileName, const char* filePath)
282305
{
306+
m_newFiles.push_back({fileName, filePath, false});
283307
}

TheForceEngine/TFE_Archive/zipArchive.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,12 @@ class ZipArchive : public Archive
5151
u8* m_tempBuffer = nullptr;
5252
size_t m_tempBufferSize = 0;
5353
bool m_entryRead;
54+
55+
struct ZipNewFile
56+
{
57+
std::string name;
58+
std::string path;
59+
bool isDir;
60+
};
61+
std::vector<ZipNewFile> m_newFiles;
5462
};

TheForceEngine/TFE_DarkForces/Actor/actor.cpp

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,8 @@ namespace TFE_DarkForces
581581
return (ActorDispatch*)s_actorState.curLogic;
582582
}
583583

584-
JBool defaultDamageFunc(ActorModule* module, MovementModule* moveMod)
584+
// Default damage module function for "dispatch" actors
585+
Tick defaultDamageFunc(ActorModule* module, MovementModule* moveMod)
585586
{
586587
DamageModule* damageMod = (DamageModule*)module;
587588
AttackModule* attackMod = &damageMod->attackMod;
@@ -595,7 +596,7 @@ namespace TFE_DarkForces
595596
actor_setCurAnimation(&attackMod->anim);
596597
}
597598
moveMod->updateTargetFunc(moveMod, &attackMod->target);
598-
return JFALSE;
599+
return 0;
599600
}
600601

601602
if (damageMod->hp <= 0)
@@ -607,7 +608,7 @@ namespace TFE_DarkForces
607608
actor_setCurAnimation(&attackMod->anim);
608609
}
609610
moveMod->updateTargetFunc(moveMod, &attackMod->target);
610-
return JFALSE;
611+
return 0;
611612
}
612613
spawnHitEffect(damageMod->dieEffect, sector, obj->posWS, obj);
613614

@@ -665,7 +666,9 @@ namespace TFE_DarkForces
665666
return 0xffffffff;
666667
}
667668

668-
JBool defaultDamageMsgFunc(s32 msg, ActorModule* module, MovementModule* moveMod)
669+
// Default damage module message function for "dispatch" actors
670+
// Delivers a message to the damage module
671+
Tick defaultDamageMsgFunc(s32 msg, ActorModule* module, MovementModule* moveMod)
669672
{
670673
DamageModule* damageMod = (DamageModule*)module;
671674
AttackModule* attackMod = &damageMod->attackMod;
@@ -738,7 +741,7 @@ namespace TFE_DarkForces
738741
actor_setCurAnimation(&attackMod->anim);
739742
}
740743
moveMod->updateTargetFunc(moveMod, &attackMod->target);
741-
return JFALSE;
744+
return 0;
742745
}
743746
else if (msg == MSG_EXPLOSION)
744747
{
@@ -787,7 +790,7 @@ namespace TFE_DarkForces
787790
actor_setCurAnimation(&attackMod->anim);
788791
}
789792
moveMod->updateTargetFunc(moveMod, &attackMod->target);
790-
return JFALSE;
793+
return 0;
791794
}
792795
else if (msg == MSG_TERMINAL_VEL || msg == MSG_CRUSH)
793796
{
@@ -810,7 +813,7 @@ namespace TFE_DarkForces
810813
}
811814
}
812815

813-
return JFALSE;
816+
return 0;
814817
}
815818

816819
DamageModule* actor_createDamageModule(ActorDispatch* dispatch)
@@ -837,8 +840,12 @@ namespace TFE_DarkForces
837840
return damageMod;
838841
}
839842

840-
JBool defaultAttackFunc(ActorModule* module, MovementModule* moveMod)
843+
// Default attack module function for "dispatch" actors
844+
// The returned value is set to the module's nextTick
845+
Tick defaultAttackFunc(ActorModule* module, MovementModule* moveMod)
841846
{
847+
// Note: the module passed into this function is an AttackModule*, not a DamageModule*, and should be cast directly to an AttackModule*
848+
// however, the code casts it to a DamageModule* first (why?)
842849
DamageModule* damageMod = (DamageModule*)module;
843850
AttackModule* attackMod = &damageMod->attackMod;
844851
ActorDispatch* logic = (ActorDispatch*)s_actorState.curLogic;
@@ -1140,8 +1147,12 @@ namespace TFE_DarkForces
11401147
return attackMod->timing.delay;
11411148
}
11421149

1143-
JBool defaultAttackMsgFunc(s32 msg, ActorModule* module, MovementModule* moveMod)
1150+
// Default attack module message function for "dispatch" actors
1151+
// Delivers a message to the attack module
1152+
Tick defaultAttackMsgFunc(s32 msg, ActorModule* module, MovementModule* moveMod)
11441153
{
1154+
// Note: the module passed into this function is an AttackModule*, not a DamageModule*, and should be cast directly to an AttackModule*
1155+
// however, the code casts it to a DamageModule* first (why?)
11451156
DamageModule* damageMod = (DamageModule*)module;
11461157
AttackModule* attackMod = &damageMod->attackMod;
11471158
ActorDispatch* logic = (ActorDispatch*)s_actorState.curLogic;
@@ -1168,7 +1179,8 @@ namespace TFE_DarkForces
11681179
return attackMod;
11691180
}
11701181

1171-
JBool defaultThinkerFunc(ActorModule* module, MovementModule* moveMod)
1182+
// Default thinker module function for "dispatch" actors
1183+
Tick defaultThinkerFunc(ActorModule* module, MovementModule* moveMod)
11721184
{
11731185
ThinkerModule* thinkerMod = (ThinkerModule*)module;
11741186
SecObject* obj = thinkerMod->header.obj;
@@ -1521,7 +1533,8 @@ namespace TFE_DarkForces
15211533
}
15221534
}
15231535

1524-
JBool defaultActorFunc(ActorModule* module, MovementModule* moveMod)
1536+
// Default movement module function for "dispatch" actors
1537+
Tick defaultActorFunc(ActorModule* module, MovementModule* moveMod)
15251538
{
15261539
moveMod->physics.wall = nullptr;
15271540
moveMod->physics.u24 = 0;
@@ -1536,7 +1549,7 @@ namespace TFE_DarkForces
15361549
actor_handleMovementAndCollision(moveMod);
15371550
}
15381551
moveMod->target.flags &= ~TARGET_ALL_MOVE;
1539-
return JFALSE;
1552+
return 0;
15401553
}
15411554

15421555
// Updates the actor target with the passed in target based on the flags.
@@ -1906,11 +1919,13 @@ namespace TFE_DarkForces
19061919
actorLogic->vel.z += pushZ;
19071920
}
19081921

1909-
void actor_hitEffectMsgFunc(MessageType msg, void* logic)
1922+
void actor_messageFunc(MessageType msg, void* logic)
19101923
{
19111924
ActorDispatch* dispatch = (ActorDispatch*)logic;
19121925
s_actorState.curLogic = (Logic*)logic;
19131926
SecObject* obj = s_actorState.curLogic->obj;
1927+
1928+
// Send the message to each module via the module's message function
19141929
for (s32 i = 0; i < ACTOR_MAX_MODULES; i++)
19151930
{
19161931
ActorModule* module = dispatch->modules[ACTOR_MAX_MODULES - 1 - i];
@@ -1924,6 +1939,7 @@ namespace TFE_DarkForces
19241939
}
19251940
}
19261941

1942+
// WAKEUP, DAMAGE and EXPLOSION messages will wake (alert) the actor from an idle state
19271943
if (msg == MSG_WAKEUP)
19281944
{
19291945
if (dispatch->flags & ACTOR_IDLE)
@@ -1975,7 +1991,12 @@ namespace TFE_DarkForces
19751991

19761992
void actor_sendTerminalVelMsg(SecObject* obj)
19771993
{
1978-
message_sendToObj(obj, MSG_TERMINAL_VEL, actor_hitEffectMsgFunc);
1994+
message_sendToObj(obj, MSG_TERMINAL_VEL, actor_messageFunc);
1995+
}
1996+
1997+
void actor_sendWakeupMsg(SecObject* obj)
1998+
{
1999+
message_sendToObj(obj, MSG_WAKEUP, actor_messageFunc);
19792000
}
19802001

19812002
void actor_handlePhysics(MovementModule* moveMod, vec3_fixed* vel)
@@ -2046,6 +2067,7 @@ namespace TFE_DarkForces
20462067
if (TFE_Jedi::abs(vel->z) < ACTOR_MIN_VELOCITY) { vel->z = 0; }
20472068
}
20482069

2070+
// Local run func for actor task
20492071
void actorLogicMsgFunc(MessageType msg)
20502072
{
20512073
if (msg == MSG_FREE)
@@ -2054,7 +2076,7 @@ namespace TFE_DarkForces
20542076
}
20552077
else
20562078
{
2057-
actor_hitEffectMsgFunc(msg, s_msgTarget);
2079+
actor_messageFunc(msg, s_msgTarget);
20582080
}
20592081
}
20602082

@@ -2081,9 +2103,9 @@ namespace TFE_DarkForces
20812103
if (actor_isObjectVisible(obj, s_playerObject, dispatch->fov, dispatch->awareRange))
20822104
{
20832105
// Wake up, and alert other actors within a 150 unit range
2084-
message_sendToObj(obj, MSG_WAKEUP, actor_hitEffectMsgFunc);
2106+
message_sendToObj(obj, MSG_WAKEUP, actor_messageFunc);
20852107
gameMusic_startFight();
2086-
collision_effectObjectsInRangeXZ(obj->sector, FIXED(150), obj->posWS, hitEffectWakeupFunc, obj, ETFLAG_AI_ACTOR);
2108+
collision_effectObjectsInRangeXZ(obj->sector, FIXED(150), obj->posWS, actor_sendWakeupMsg, obj, ETFLAG_AI_ACTOR);
20872109
}
20882110
}
20892111
}

TheForceEngine/TFE_DarkForces/Actor/actor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ namespace TFE_DarkForces
162162
MovementModule* actor_createMovementModule(ActorDispatch* dispatch);
163163
void actor_addModule(ActorDispatch* dispatch, ActorModule* module);
164164

165-
void actor_hitEffectMsgFunc(MessageType msg, void* logic);
165+
void actor_messageFunc(MessageType msg, void* logic);
166+
void actor_sendWakeupMsg(SecObject* obj);
166167
void actor_kill();
167168
void actor_initModule(ActorModule* module, Logic* logic);
168169
JBool actor_canDie(PhysicsActor* phyActor);

TheForceEngine/TFE_DarkForces/Actor/actorInternal.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,24 @@ namespace TFE_DarkForces
5353
extern List* s_physicsActors; // Holds all the non-dispatch actors (bosses, mousebots, turrets...)
5454

5555
void actorLogicCleanupFunc(Logic* logic);
56-
JBool defaultActorFunc(ActorModule* module, MovementModule* moveMod);
56+
Tick defaultActorFunc(ActorModule* module, MovementModule* moveMod);
5757
JBool defaultUpdateTargetFunc(MovementModule* moveMod, ActorTarget* target);
58-
JBool defaultAttackFunc(ActorModule* module, MovementModule* moveMod);
59-
JBool defaultAttackMsgFunc(s32 msg, ActorModule* module, MovementModule* moveMod);
60-
JBool defaultDamageFunc(ActorModule* module, MovementModule* moveMod);
61-
JBool defaultDamageMsgFunc(s32 msg, ActorModule* module, MovementModule* moveMod);
62-
JBool defaultThinkerFunc(ActorModule* module, MovementModule* moveMod);
63-
JBool flyingModuleFunc(ActorModule* module, MovementModule* moveMod);
64-
JBool flyingModuleFunc_Remote(ActorModule* module, MovementModule* moveMod);
58+
Tick defaultAttackFunc(ActorModule* module, MovementModule* moveMod);
59+
Tick defaultAttackMsgFunc(s32 msg, ActorModule* module, MovementModule* moveMod);
60+
Tick defaultDamageFunc(ActorModule* module, MovementModule* moveMod);
61+
Tick defaultDamageMsgFunc(s32 msg, ActorModule* module, MovementModule* moveMod);
62+
Tick defaultThinkerFunc(ActorModule* module, MovementModule* moveMod);
63+
Tick flyingModuleFunc(ActorModule* module, MovementModule* moveMod);
64+
Tick flyingModuleFunc_Remote(ActorModule* module, MovementModule* moveMod);
6565

6666
// Alternate Damage functions
67-
JBool sceneryLogicFunc(ActorModule* module, MovementModule* moveMod);
68-
JBool sceneryMsgFunc(s32 msg, ActorModule* module, MovementModule* moveMod);
69-
JBool exploderFunc(ActorModule* module, MovementModule* moveMod);
70-
JBool exploderMsgFunc(s32 msg, ActorModule* module, MovementModule* moveMod);
71-
JBool sewerCreatureAiFunc(ActorModule* module, MovementModule* moveMod);
72-
JBool sewerCreatureAiMsgFunc(s32 msg, ActorModule* module, MovementModule* moveMod);
67+
Tick sceneryLogicFunc(ActorModule* module, MovementModule* moveMod);
68+
Tick sceneryMsgFunc(s32 msg, ActorModule* module, MovementModule* moveMod);
69+
Tick exploderFunc(ActorModule* module, MovementModule* moveMod);
70+
Tick exploderMsgFunc(s32 msg, ActorModule* module, MovementModule* moveMod);
71+
Tick sewerCreatureDamageFunc(ActorModule* module, MovementModule* moveMod);
72+
Tick sewerCreatureDamageMsgFunc(s32 msg, ActorModule* module, MovementModule* moveMod);
7373

7474
// Alternate Attack function.
75-
JBool sewerCreatureEnemyFunc(ActorModule* module, MovementModule* moveMod);
75+
Tick sewerCreatureEnemyFunc(ActorModule* module, MovementModule* moveMod);
7676
} // namespace TFE_DarkForces

TheForceEngine/TFE_DarkForces/Actor/actorModule.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ struct ActorModule
121121

122122
ActorFunc func;
123123
ActorMsgFunc msgFunc;
124-
ActorAttribFunc attribFunc;
124+
ActorAttribFunc attribFunc; // Never used?
125125
ActorFreeFunc freeFunc;
126126

127127
Tick nextTick;
@@ -198,7 +198,7 @@ struct ThinkerModule
198198

199199
struct DamageModule
200200
{
201-
AttackModule attackMod;
201+
AttackModule attackMod; // A DamageModule starts with an AttackModule, which it uses for animation but the remainder of the struct is unused.
202202
fixed16_16 hp;
203203
ItemId itemDropId;
204204

TheForceEngine/TFE_DarkForces/Actor/actorSerialization.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,15 +333,15 @@ namespace TFE_DarkForces
333333
defaultDamageFunc,
334334
sceneryLogicFunc,
335335
exploderFunc,
336-
sewerCreatureAiFunc,
336+
sewerCreatureDamageFunc,
337337
};
338338

339339
const ActorMsgFunc c_actorDamageMsgFunc[] =
340340
{
341341
defaultDamageMsgFunc,
342342
sceneryMsgFunc,
343343
exploderMsgFunc,
344-
sewerCreatureAiMsgFunc,
344+
sewerCreatureDamageMsgFunc,
345345
};
346346

347347
s32 actor_getDamageFuncIndex(ActorFunc func)

0 commit comments

Comments
 (0)