From 6b45dff0ef64b61783b43e7934c001dfced41a97 Mon Sep 17 00:00:00 2001
From: Lactozilla <jp6781615@gmail.com>
Date: Sat, 15 Feb 2025 23:15:05 -0300
Subject: [PATCH] Fix building

---
 src/acs/interface.cpp | 10 +++++-----
 src/acs/interface.h   | 10 +++++-----
 src/acs/stream.cpp    | 14 ++++++--------
 src/acs/stream.hpp    |  6 +++---
 src/p_local.h         | 26 +++++++++++++++++++++++++-
 src/p_saveg.c         | 31 +++++++------------------------
 src/p_saveg.h         | 18 +++++-------------
 7 files changed, 56 insertions(+), 59 deletions(-)

diff --git a/src/acs/interface.cpp b/src/acs/interface.cpp
index deca14f2ce..f80d0bb38c 100644
--- a/src/acs/interface.cpp
+++ b/src/acs/interface.cpp
@@ -1,7 +1,7 @@
 // SONIC ROBO BLAST 2
 //-----------------------------------------------------------------------------
 // Copyright (C) 2024 by Russell's Smart Interfaces
-// Copyright (C) 2024 by Sonic Team Junior.
+// Copyright (C) 2025 by Sonic Team Junior.
 // Copyright (C) 2016 by James Haley, David Hill, et al. (Team Eternity)
 // Copyright (C) 2024 by Sally "TehRealSalt" Cochenour
 // Copyright (C) 2024 by Kart Krew
@@ -453,11 +453,11 @@ boolean ACS_Terminate(const char *name)
 }
 
 /*--------------------------------------------------
-	void ACS_Archive(savebuffer_t *save)
+	void ACS_Archive(save_t *save)
 
 		See header file for description.
 --------------------------------------------------*/
-void ACS_Archive(savebuffer_t *save)
+void ACS_Archive(save_t *save)
 {
 	Environment *env = &ACSEnv;
 
@@ -481,11 +481,11 @@ void ACS_Archive(savebuffer_t *save)
 }
 
 /*--------------------------------------------------
-	void ACS_UnArchive(savebuffer_t *save)
+	void ACS_UnArchive(save_t *save)
 
 		See header file for description.
 --------------------------------------------------*/
-void ACS_UnArchive(savebuffer_t *save)
+void ACS_UnArchive(save_t *save)
 {
 	Environment *env = &ACSEnv;
 
diff --git a/src/acs/interface.h b/src/acs/interface.h
index bdca8a6448..9aa103869e 100644
--- a/src/acs/interface.h
+++ b/src/acs/interface.h
@@ -1,7 +1,7 @@
 // SONIC ROBO BLAST 2
 //-----------------------------------------------------------------------------
 // Copyright (C) 2024 by Russell's Smart Interfaces
-// Copyright (C) 2024 by Sonic Team Junior.
+// Copyright (C) 2025 by Sonic Team Junior.
 // Copyright (C) 2016 by James Haley, David Hill, et al. (Team Eternity)
 // Copyright (C) 2024 by Sally "TehRealSalt" Cochenour
 // Copyright (C) 2024 by Kart Krew
@@ -286,7 +286,7 @@ boolean ACS_Terminate(const char *name);
 
 
 /*--------------------------------------------------
-	void ACS_Archive(savebuffer_t *save);
+	void ACS_Archive(save_t *save);
 
 		Saves the ACS VM state into a save buffer.
 
@@ -297,11 +297,11 @@ boolean ACS_Terminate(const char *name);
 		None
 --------------------------------------------------*/
 
-void ACS_Archive(savebuffer_t *save);
+void ACS_Archive(save_t *save);
 
 
 /*--------------------------------------------------
-	void ACS_UnArchive(savebuffer_t *save);
+	void ACS_UnArchive(save_t *save);
 
 		Loads the ACS VM state from a save buffer.
 
@@ -312,7 +312,7 @@ void ACS_Archive(savebuffer_t *save);
 		None
 --------------------------------------------------*/
 
-void ACS_UnArchive(savebuffer_t *save);
+void ACS_UnArchive(save_t *save);
 
 #ifdef __cplusplus
 }
diff --git a/src/acs/stream.cpp b/src/acs/stream.cpp
index 85e070587c..18e4822bd9 100644
--- a/src/acs/stream.cpp
+++ b/src/acs/stream.cpp
@@ -1,7 +1,7 @@
 // SONIC ROBO BLAST 2
 //-----------------------------------------------------------------------------
 // Copyright (C) 2024 by Russell's Smart Interfaces
-// Copyright (C) 2024 by Sonic Team Junior.
+// Copyright (C) 2025 by Sonic Team Junior.
 // Copyright (C) 2016 by James Haley, David Hill, et al. (Team Eternity)
 // Copyright (C) 2024 by Sally "TehRealSalt" Cochenour
 // Copyright (C) 2024 by Kart Krew
@@ -31,33 +31,31 @@
 
 using namespace srb2::acs;
 
-SaveBuffer::SaveBuffer(savebuffer_t *save_) :
+SaveBuffer::SaveBuffer(save_t *save_) :
 	save{save_}
 {
 }
 
 SaveBuffer::int_type SaveBuffer::overflow(SaveBuffer::int_type ch)
 {
-	if (save->p == save->end)
+	if (save->pos == save->size)
 	{
 		return traits_type::eof();
 	}
 
-	*save->p = static_cast<UINT8>(ch);
-	save->p++;
+	P_WriteUINT8(save, static_cast<UINT8>(ch));
 
 	return ch;
 }
 
 SaveBuffer::int_type SaveBuffer::underflow()
 {
-	if (save->p == save->end)
+	if (save->pos == save->size)
 	{
 		return traits_type::eof();
 	}
 
-	UINT8 ret = *save->p;
-	save->p++;
+	UINT8 ret = P_ReadUINT8(save);
 
 	// Allow the streambuf internal funcs to work
 	buf[0] = ret;
diff --git a/src/acs/stream.hpp b/src/acs/stream.hpp
index e18be2c46d..28c525062e 100644
--- a/src/acs/stream.hpp
+++ b/src/acs/stream.hpp
@@ -1,7 +1,7 @@
 // SONIC ROBO BLAST 2
 //-----------------------------------------------------------------------------
 // Copyright (C) 2024 by Russell's Smart Interfaces
-// Copyright (C) 2024 by Sonic Team Junior.
+// Copyright (C) 2025 by Sonic Team Junior.
 // Copyright (C) 2016 by James Haley, David Hill, et al. (Team Eternity)
 // Copyright (C) 2024 by Sally "TehRealSalt" Cochenour
 // Copyright (C) 2024 by Kart Krew
@@ -35,10 +35,10 @@ namespace srb2::acs {
 class SaveBuffer : public std::streambuf
 {
 public:
-	savebuffer_t *save;
+	save_t *save;
 	UINT8 buf[1];
 
-	explicit SaveBuffer(savebuffer_t *save_);
+	explicit SaveBuffer(save_t *save_);
 
 private:
 	virtual int_type overflow(int_type ch);
diff --git a/src/p_local.h b/src/p_local.h
index 85a31cf898..8a740d70c5 100644
--- a/src/p_local.h
+++ b/src/p_local.h
@@ -2,7 +2,7 @@
 //-----------------------------------------------------------------------------
 // Copyright (C) 1993-1996 by id Software, Inc.
 // Copyright (C) 1998-2000 by DooM Legacy Team.
-// Copyright (C) 1999-2024 by Sonic Team Junior.
+// Copyright (C) 1999-2025 by Sonic Team Junior.
 //
 // This program is free software distributed under the
 // terms of the GNU General Public License, version 2.
@@ -23,6 +23,10 @@
 #include "r_defs.h"
 #include "p_maputl.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define FLOATSPEED (FRACUNIT*4)
 
 // Maximum player score.
@@ -69,6 +73,7 @@ extern thinker_t thlist[];
 extern mobj_t *mobjcache;
 
 void P_InitThinkers(void);
+void P_InvalidateThinkersWithoutInit(void);
 void P_AddThinker(const thinklistnum_t n, thinker_t *thinker);
 void P_RemoveThinker(thinker_t *thinker);
 
@@ -147,6 +152,7 @@ UINT16 P_GetPlayerColor(player_t *player);
 boolean P_IsObjectInGoop(mobj_t *mo);
 boolean P_IsObjectOnGround(mobj_t *mo);
 boolean P_InSpaceSector(mobj_t *mo);
+#define P_IsObjectFlipped(o) (((o)->eflags & MFE_VERTICALFLIP) == MFE_VERTICALFLIP)
 boolean P_InQuicksand(mobj_t *mo);
 boolean P_InJumpFlipSector(mobj_t *mo);
 boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff);
@@ -204,6 +210,8 @@ void P_DoSpinDashDust(player_t *player);
 #define P_AnalogMove(player) (P_ControlStyle(player) == CS_LMAOGALOG)
 boolean P_TransferToNextMare(player_t *player);
 UINT8 P_FindLowestMare(void);
+UINT8 P_FindLowestLap(void);
+UINT8 P_FindHighestLap(void);
 void P_FindEmerald(void);
 void P_TransferToAxis(player_t *player, INT32 axisnum);
 boolean P_PlayerMoving(INT32 pnum);
@@ -316,6 +324,8 @@ fixed_t P_MobjCeilingZ(sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t
 #define P_GetSpecialBottomZ(mobj, src, bound) P_MobjFloorZ(src, bound, mobj->x, mobj->y, mobj->radius, NULL, src != bound, true)
 #define P_GetSpecialTopZ(mobj, src, bound) P_MobjCeilingZ(src, bound, mobj->x, mobj->y, mobj->radius, NULL, src == bound, true)
 
+INT32 P_FloorPicAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height);
+
 #define P_CameraGetFloorZ(mobj, sector, x, y, line) P_MobjFloorZ(sector, NULL, x, y, mobj->radius, line, false, false)
 #define P_CameraGetCeilingZ(mobj, sector, x, y, line) P_MobjCeilingZ(sector, NULL, x, y, mobj->radius, line, true, false)
 #define P_CameraGetFOFTopZ(mobj, sector, fof, x, y, line) P_MobjCeilingZ(sectors + fof->secnum, sector, x, y, mobj->radius, line, false, false)
@@ -333,6 +343,7 @@ mobj_t *P_SpawnXYZMissile(mobj_t *source, mobj_t *dest, mobjtype_t type, fixed_t
 mobj_t *P_SpawnPointMissile(mobj_t *source, fixed_t xa, fixed_t ya, fixed_t za, mobjtype_t type, fixed_t x, fixed_t y, fixed_t z);
 mobj_t *P_SpawnAlteredDirectionMissile(mobj_t *source, mobjtype_t type, fixed_t x, fixed_t y, fixed_t z, INT32 shiftingAngle);
 mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle, UINT8 aimtype, UINT32 flags2);
+mobj_t *P_SpawnMissileAtSpeeds(mobj_t *source, mobjtype_t type, angle_t angle, fixed_t hspeed, fixed_t vspeed, boolean useGravity);
 #define P_SpawnPlayerMissile(s,t,f) P_SPMAngle(s,t,s->angle,true,f)
 #define P_SpawnNameFinder(s,t) P_SPMAngle(s,t,s->angle,true,0)
 void P_ColorTeamMissile(mobj_t *missile, player_t *source);
@@ -553,5 +564,18 @@ void P_DoSuperDetransformation(player_t *player);
 void P_ExplodeMissile(mobj_t *mo);
 void P_CheckGravity(mobj_t *mo, boolean affect);
 void P_SetPitchRollFromSlope(mobj_t *mo, pslope_t *slope);
+fixed_t P_GetMobjHead(mobj_t *mo);
+fixed_t P_GetMobjFeet(mobj_t *mo);
+
+void P_InitTIDHash(void);
+void P_SetThingTID(mobj_t *mo, mtag_t tid);
+void P_RemoveThingTID(mobj_t *mo);
+mobj_t *P_FindMobjFromTID(mtag_t tid, mobj_t *i, mobj_t *activator);
+
+void P_DeleteMobjStringArgs(mobj_t *mobj);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
 
 #endif // __P_LOCAL__
diff --git a/src/p_saveg.c b/src/p_saveg.c
index f671993883..e953f3171a 100644
--- a/src/p_saveg.c
+++ b/src/p_saveg.c
@@ -2,7 +2,7 @@
 //-----------------------------------------------------------------------------
 // Copyright (C) 1993-1996 by id Software, Inc.
 // Copyright (C) 1998-2000 by DooM Legacy Team.
-// Copyright (C) 1999-2024 by Sonic Team Junior.
+// Copyright (C) 1999-2025 by Sonic Team Junior.
 //
 // This program is free software distributed under the
 // terms of the GNU General Public License, version 2.
@@ -5560,33 +5560,16 @@ static inline boolean P_UnArchiveLuabanksAndConsistency(save_t *save_p)
 	return true;
 }
 
-static void DoACSArchive(void)
+static void DoACSArchive(save_t *save_p)
 {
-	savebuffer_t save;
-	save.buffer = save_start;
-	save.end = save_end;
-	save.p = save_p;
-	save.size = save_length;
-
-	ACS_Archive(&save);
-
-	save_p = save.p;
+	ACS_Archive(save_p);
 }
 
-static void DoACSUnArchive(void)
+static void DoACSUnArchive(save_t *save_p)
 {
-	savebuffer_t save;
-	save.buffer = save_start;
-	save.end = save_end;
-	save.p = save_p;
-	save.size = save_length;
-
-	ACS_UnArchive(&save);
-
-	save_p = save.p;
+	ACS_UnArchive(save_p);
 }
 
-
 void P_SaveGame(save_t *save_p, INT16 mapnum)
 {
 	P_ArchiveMisc(save_p, mapnum);
@@ -5628,7 +5611,7 @@ void P_SaveNetGame(save_t *save_p, boolean resending)
 		P_NetArchiveSectorPortals(save_p);
 	}
 
-	DoACSArchive();
+	DoACSArchive(save_p);
 	LUA_Archive(save_p);
 
 	P_ArchiveLuabanksAndConsistency(save_p);
@@ -5673,7 +5656,7 @@ boolean P_LoadNetGame(save_t *save_p, boolean reloading)
 		P_FinishMobjs();
 	}
 
-	DoACSUnArchive();
+	DoACSUnArchive(save_p);
 	LUA_UnArchive(save_p);
 
 	// This is stupid and hacky, but maybe it'll work!
diff --git a/src/p_saveg.h b/src/p_saveg.h
index 58a4317f89..3d1ecf871d 100644
--- a/src/p_saveg.h
+++ b/src/p_saveg.h
@@ -2,7 +2,7 @@
 //-----------------------------------------------------------------------------
 // Copyright (C) 1993-1996 by id Software, Inc.
 // Copyright (C) 1998-2000 by DooM Legacy Team.
-// Copyright (C) 1999-2024 by Sonic Team Junior.
+// Copyright (C) 1999-2025 by Sonic Team Junior.
 //
 // This program is free software distributed under the
 // terms of the GNU General Public License, version 2.
@@ -37,14 +37,6 @@ void P_SaveNetGame(save_t *save_p, boolean resending);
 boolean P_LoadGame(save_t *save_p, INT16 mapoverride);
 boolean P_LoadNetGame(save_t *save_p, boolean reloading);
 
-typedef struct
-{
-	UINT8 *buffer;
-	UINT8 *p;
-	UINT8 *end;
-	size_t size;
-} savebuffer_t;
-
 typedef struct
 {
 	UINT8 skin;
@@ -58,10 +50,6 @@ typedef struct
 
 extern savedata_t savedata;
 
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
 void P_WriteUINT8(save_t *p, UINT8 v);
 void P_WriteSINT8(save_t *p, SINT8 v);
 void P_WriteUINT16(save_t *p, UINT16 v);
@@ -94,4 +82,8 @@ void P_ReadStringL(save_t *p, char *s, size_t n);
 void P_ReadString(save_t *p, char *s);
 void P_ReadMem(save_t *p, void *s, size_t n);
 
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
 #endif
-- 
GitLab