Merge remote-tracking branch 'gzdoom/master'

# Conflicts:
#	src/v_video.cpp
This commit is contained in:
Rachael Alexanderson 2017-03-03 16:29:33 -05:00
commit 21a8964bea
36 changed files with 388 additions and 131 deletions

View file

@ -1037,7 +1037,7 @@ public:
double StealthAlpha; // Minmum alpha for MF_STEALTH. double StealthAlpha; // Minmum alpha for MF_STEALTH.
int WoundHealth; // Health needed to enter wound state int WoundHealth; // Health needed to enter wound state
SDWORD tics; // state tic counter int32_t tics; // state tic counter
FState *state; FState *state;
//VMFunction *Damage; // For missiles and monster railgun //VMFunction *Damage; // For missiles and monster railgun
int DamageVal; int DamageVal;
@ -1062,10 +1062,10 @@ public:
// also the originator for missiles // also the originator for missiles
TObjPtr<AActor> lastenemy; // Last known enemy -- killough 2/15/98 TObjPtr<AActor> lastenemy; // Last known enemy -- killough 2/15/98
TObjPtr<AActor> LastHeard; // [RH] Last actor this one heard TObjPtr<AActor> LastHeard; // [RH] Last actor this one heard
SDWORD reactiontime; // if non 0, don't attack yet; used by int32_t reactiontime; // if non 0, don't attack yet; used by
// player to freeze a bit after teleporting // player to freeze a bit after teleporting
SDWORD threshold; // if > 0, the target will be chased int32_t threshold; // if > 0, the target will be chased
SDWORD DefThreshold; // [MC] Default threshold which the actor will reset its threshold to after switching targets int32_t DefThreshold; // [MC] Default threshold which the actor will reset its threshold to after switching targets
// no matter what (even if shot) // no matter what (even if shot)
player_t *player; // only valid if type of APlayerPawn player_t *player; // only valid if type of APlayerPawn
TObjPtr<AActor> LastLookActor; // Actor last looked for (if TIDtoHate != 0) TObjPtr<AActor> LastLookActor; // Actor last looked for (if TIDtoHate != 0)
@ -1159,7 +1159,7 @@ public:
double MaxDropOffHeight; double MaxDropOffHeight;
double MaxStepHeight; double MaxStepHeight;
SDWORD Mass; int32_t Mass;
SWORD PainChance; SWORD PainChance;
int PainThreshold; int PainThreshold;
FNameNoInit DamageType; FNameNoInit DamageType;

View file

@ -7,7 +7,6 @@ typedef int8_t SBYTE;
typedef uint8_t BYTE; typedef uint8_t BYTE;
typedef int16_t SWORD; typedef int16_t SWORD;
typedef uint16_t WORD; typedef uint16_t WORD;
typedef int32_t SDWORD;
typedef uint32_t uint32; typedef uint32_t uint32;
typedef int64_t SQWORD; typedef int64_t SQWORD;
typedef uint64_t QWORD; typedef uint64_t QWORD;
@ -63,7 +62,7 @@ union QWORD_UNION
#define FRACBITS 16 #define FRACBITS 16
#define FRACUNIT (1<<FRACBITS) #define FRACUNIT (1<<FRACBITS)
typedef SDWORD fixed_t; typedef int32_t fixed_t;
typedef DWORD dsfixed_t; // fixedpt used by span drawer typedef DWORD dsfixed_t; // fixedpt used by span drawer
#define FIXED_MAX (signed)(0x7fffffff) #define FIXED_MAX (signed)(0x7fffffff)

View file

@ -1267,7 +1267,7 @@ void C_DrawConsole (bool hw2d)
DTA_KeepRatio, true, TAG_DONE); DTA_KeepRatio, true, TAG_DONE);
// Draw the marker // Draw the marker
i = LEFTMARGIN+5+tickbegin*8 + Scale (TickerAt, (SDWORD)(tickend - tickbegin)*8, TickerMax); i = LEFTMARGIN+5+tickbegin*8 + Scale (TickerAt, (int32_t)(tickend - tickbegin)*8, TickerMax);
if (textScale == 1) if (textScale == 1)
screen->DrawChar (ConFont, CR_ORANGE, (int)i, tickerY, 0x13, TAG_DONE); screen->DrawChar (ConFont, CR_ORANGE, (int)i, tickerY, 0x13, TAG_DONE);
else else

View file

@ -1396,10 +1396,13 @@ void PPointer::WriteValue(FSerializer &ar, const char *key,const void *addr) con
ar(key, *(DObject **)addr); ar(key, *(DObject **)addr);
} }
} }
else if (writer != nullptr)
{
writer(ar, key, addr);
}
else else
{ {
assert(0 && "Pointer points to a type we don't handle"); I_Error("Attempt to save pointer to unhandled type %s", PointedType->DescriptiveName());
I_Error("Attempt to save pointer to unhandled type");
} }
} }
@ -1426,6 +1429,10 @@ bool PPointer::ReadValue(FSerializer &ar, const char *key, void *addr) const
} }
return res; return res;
} }
else if (reader != nullptr)
{
return reader(ar, key, addr);
}
return false; return false;
} }

View file

@ -362,13 +362,26 @@ public:
class PPointer : public PBasicType class PPointer : public PBasicType
{ {
DECLARE_CLASS(PPointer, PBasicType); DECLARE_CLASS(PPointer, PBasicType);
public: public:
typedef void(*WriteHandler)(FSerializer &ar, const char *key, const void *addr);
typedef bool(*ReadHandler)(FSerializer &ar, const char *key, void *addr);
PPointer(); PPointer();
PPointer(PType *pointsat, bool isconst = false); PPointer(PType *pointsat, bool isconst = false);
PType *PointedType; PType *PointedType;
bool IsConst; bool IsConst;
WriteHandler writer = nullptr;
ReadHandler reader = nullptr;
void InstallHandlers(WriteHandler w, ReadHandler r)
{
writer = w;
reader = r;
}
virtual bool IsMatch(intptr_t id1, intptr_t id2) const; virtual bool IsMatch(intptr_t id1, intptr_t id2) const;
virtual void GetTypeIDs(intptr_t &id1, intptr_t &id2) const; virtual void GetTypeIDs(intptr_t &id1, intptr_t &id2) const;
void SetPointer(void *base, unsigned offset, TArray<size_t> *special = NULL) const override; void SetPointer(void *base, unsigned offset, TArray<size_t> *special = NULL) const override;

View file

@ -262,8 +262,8 @@ struct mapseg_t
struct mapseg4_t struct mapseg4_t
{ {
SDWORD v1; int32_t v1;
SDWORD v2; int32_t v2;
SWORD angle; SWORD angle;
WORD linedef; WORD linedef;
SWORD side; SWORD side;

View file

@ -479,7 +479,7 @@ DFsSection *FParser::looping_section()
int n; int n;
// check thru all the hashchains // check thru all the hashchains
SDWORD rover_index = Script->MakeIndex(Rover); int32_t rover_index = Script->MakeIndex(Rover);
for(n=0; n<SECTIONSLOTS; n++) for(n=0; n<SECTIONSLOTS; n++)
{ {

View file

@ -182,7 +182,7 @@ public:
union value_t union value_t
{ {
SDWORD i; int32_t i;
fsfix fixed; // haleyjd: fixed-point fsfix fixed; // haleyjd: fixed-point
// the following are only used in the global script so we don't need to bother with them // the following are only used in the global script so we don't need to bother with them

View file

@ -2270,7 +2270,29 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio
I_FreezeTime(true); I_FreezeTime(true);
insave = true; insave = true;
try
{
G_SnapshotLevel(); G_SnapshotLevel();
}
catch(CRecoverableError &err)
{
// delete the snapshot. Since the save failed it is broken.
insave = false;
level.info->Snapshot.Clean();
Printf(PRINT_HIGH, "Save failed\n");
Printf(PRINT_HIGH, "%s\n", err.GetMessage());
// The time freeze must be reset if the save fails.
if (cl_waitforsave)
I_FreezeTime(false);
return;
}
catch (...)
{
insave = false;
if (cl_waitforsave)
I_FreezeTime(false);
throw;
}
BufferWriter savepic; BufferWriter savepic;
FSerializer savegameinfo; // this is for displayable info about the savegame FSerializer savegameinfo; // this is for displayable info about the savegame

View file

@ -83,7 +83,7 @@ OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, int width, int height, int
{ {
// SetVSync needs to be at the very top to workaround a bug in Nvidia's OpenGL driver. // SetVSync needs to be at the very top to workaround a bug in Nvidia's OpenGL driver.
// If wglSwapIntervalEXT is called after glBindFramebuffer in a frame the setting is not changed! // If wglSwapIntervalEXT is called after glBindFramebuffer in a frame the setting is not changed!
SetVSync(vid_vsync); Super::SetVSync(vid_vsync);
// Make sure all global variables tracking OpenGL context state are reset.. // Make sure all global variables tracking OpenGL context state are reset..
FHardwareTexture::InitGlobalState(); FHardwareTexture::InitGlobalState();
@ -230,6 +230,27 @@ void OpenGLFrameBuffer::Swap()
mDebug->Update(); mDebug->Update();
} }
//==========================================================================
//
// Enable/disable vertical sync
//
//==========================================================================
void OpenGLFrameBuffer::SetVSync(bool vsync)
{
// Switch to the default frame buffer because some drivers associate the vsync state with the bound FB object.
GLint oldDrawFramebufferBinding = 0, oldReadFramebufferBinding = 0;
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldDrawFramebufferBinding);
glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &oldReadFramebufferBinding);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
Super::SetVSync(vsync);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, oldDrawFramebufferBinding);
glBindFramebuffer(GL_READ_FRAMEBUFFER, oldReadFramebufferBinding);
}
//=========================================================================== //===========================================================================
// //
// DoSetGamma // DoSetGamma

View file

@ -83,6 +83,8 @@ public:
bool Is8BitMode() { return false; } bool Is8BitMode() { return false; }
bool IsHWGammaActive() const { return HWGammaActive; } bool IsHWGammaActive() const { return HWGammaActive; }
void SetVSync(bool vsync);
private: private:
PalEntry Flash; PalEntry Flash;

View file

@ -49,14 +49,14 @@
#ifndef _WIN32 #ifndef _WIN32
struct POINT { struct POINT {
SDWORD x; int32_t x;
SDWORD y; int32_t y;
}; };
struct RECT { struct RECT {
SDWORD left; int32_t left;
SDWORD top; int32_t top;
SDWORD right; int32_t right;
SDWORD bottom; int32_t bottom;
}; };
#endif #endif

View file

@ -35,7 +35,7 @@ static FRandom pr_opl;
typedef uintptr_t Bitu; typedef uintptr_t Bitu;
typedef intptr_t Bits; typedef intptr_t Bits;
typedef DWORD Bit32u; typedef DWORD Bit32u;
typedef SDWORD Bit32s; typedef int32_t Bit32s;
typedef WORD Bit16u; typedef WORD Bit16u;
typedef SWORD Bit16s; typedef SWORD Bit16s;
typedef BYTE Bit8u; typedef BYTE Bit8u;

View file

@ -35,7 +35,7 @@
typedef uintptr_t Bitu; typedef uintptr_t Bitu;
typedef intptr_t Bits; typedef intptr_t Bits;
typedef DWORD Bit32u; typedef DWORD Bit32u;
typedef SDWORD Bit32s; typedef int32_t Bit32s;
typedef WORD Bit16u; typedef WORD Bit16u;
typedef SWORD Bit16s; typedef SWORD Bit16s;
typedef BYTE Bit8u; typedef BYTE Bit8u;

View file

@ -180,7 +180,7 @@ inline int PitchToACS(DAngle ang)
struct CallReturn struct CallReturn
{ {
CallReturn(int pc, ScriptFunction *func, FBehavior *module, SDWORD *locals, ACSLocalArrays *arrays, bool discard, unsigned int runaway) CallReturn(int pc, ScriptFunction *func, FBehavior *module, int32_t *locals, ACSLocalArrays *arrays, bool discard, unsigned int runaway)
: ReturnFunction(func), : ReturnFunction(func),
ReturnModule(module), ReturnModule(module),
ReturnLocals(locals), ReturnLocals(locals),
@ -192,7 +192,7 @@ struct CallReturn
ScriptFunction *ReturnFunction; ScriptFunction *ReturnFunction;
FBehavior *ReturnModule; FBehavior *ReturnModule;
SDWORD *ReturnLocals; int32_t *ReturnLocals;
ACSLocalArrays *ReturnArrays; ACSLocalArrays *ReturnArrays;
int ReturnAddress; int ReturnAddress;
int bDiscardResult; int bDiscardResult;
@ -206,7 +206,7 @@ static DLevelScript *P_GetScriptGoing (AActor *who, line_t *where, int num, cons
struct FBehavior::ArrayInfo struct FBehavior::ArrayInfo
{ {
DWORD ArraySize; DWORD ArraySize;
SDWORD *Elements; int32_t *Elements;
}; };
TArray<FBehavior *> FBehavior::StaticModules; TArray<FBehavior *> FBehavior::StaticModules;
@ -243,11 +243,11 @@ inline int uallong(const int &foo)
//============================================================================ //============================================================================
// ACS variables with world scope // ACS variables with world scope
SDWORD ACS_WorldVars[NUM_WORLDVARS]; int32_t ACS_WorldVars[NUM_WORLDVARS];
FWorldGlobalArray ACS_WorldArrays[NUM_WORLDVARS]; FWorldGlobalArray ACS_WorldArrays[NUM_WORLDVARS];
// ACS variables with global scope // ACS variables with global scope
SDWORD ACS_GlobalVars[NUM_GLOBALVARS]; int32_t ACS_GlobalVars[NUM_GLOBALVARS];
FWorldGlobalArray ACS_GlobalArrays[NUM_GLOBALVARS]; FWorldGlobalArray ACS_GlobalArrays[NUM_GLOBALVARS];
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -261,7 +261,7 @@ FWorldGlobalArray ACS_GlobalArrays[NUM_GLOBALVARS];
struct FACSStack struct FACSStack
{ {
SDWORD buffer[STACK_SIZE]; int32_t buffer[STACK_SIZE];
int sp; int sp;
FACSStack *next; FACSStack *next;
FACSStack *prev; FACSStack *prev;
@ -979,7 +979,7 @@ void P_ClearACSVars(bool alsoglobal)
// //
//============================================================================ //============================================================================
static void WriteVars (FSerializer &file, SDWORD *vars, size_t count, const char *key) static void WriteVars (FSerializer &file, int32_t *vars, size_t count, const char *key)
{ {
size_t i, j; size_t i, j;
@ -1007,7 +1007,7 @@ static void WriteVars (FSerializer &file, SDWORD *vars, size_t count, const char
// //
//============================================================================ //============================================================================
static void ReadVars (FSerializer &arc, SDWORD *vars, size_t count, const char *key) static void ReadVars (FSerializer &arc, int32_t *vars, size_t count, const char *key)
{ {
memset(&vars[0], 0, count * 4); memset(&vars[0], 0, count * 4);
arc.Array(key, vars, (int)count); arc.Array(key, vars, (int)count);
@ -1684,10 +1684,10 @@ void FBehavior::SerializeVars (FSerializer &arc)
} }
} }
void FBehavior::SerializeVarSet (FSerializer &arc, SDWORD *vars, int max) void FBehavior::SerializeVarSet (FSerializer &arc, int32_t *vars, int max)
{ {
SDWORD count; int32_t count;
SDWORD first, last; int32_t first, last;
if (arc.BeginObject(nullptr)) if (arc.BeginObject(nullptr))
{ {
@ -1997,7 +1997,7 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len)
{ {
MapVarStore[LittleLong(chunk[2+i*2])] = i; MapVarStore[LittleLong(chunk[2+i*2])] = i;
ArrayStore[i].ArraySize = LittleLong(chunk[3+i*2]); ArrayStore[i].ArraySize = LittleLong(chunk[3+i*2]);
ArrayStore[i].Elements = new SDWORD[ArrayStore[i].ArraySize]; ArrayStore[i].Elements = new int32_t[ArrayStore[i].ArraySize];
memset(ArrayStore[i].Elements, 0, ArrayStore[i].ArraySize*sizeof(DWORD)); memset(ArrayStore[i].Elements, 0, ArrayStore[i].ArraySize*sizeof(DWORD));
} }
} }
@ -2013,7 +2013,7 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len)
// optimizer. Might be some undefined behavior in this code, // optimizer. Might be some undefined behavior in this code,
// but I don't know what it is. // but I don't know what it is.
unsigned int initsize = MIN<unsigned int> (ArrayStore[arraynum].ArraySize, (LittleLong(chunk[1])-4)/4); unsigned int initsize = MIN<unsigned int> (ArrayStore[arraynum].ArraySize, (LittleLong(chunk[1])-4)/4);
SDWORD *elems = ArrayStore[arraynum].Elements; int32_t *elems = ArrayStore[arraynum].Elements;
for (unsigned int j = 0; j < initsize; ++j) for (unsigned int j = 0; j < initsize; ++j)
{ {
elems[j] = LittleLong(chunk[3+j]); elems[j] = LittleLong(chunk[3+j]);
@ -2062,7 +2062,7 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len)
int arraynum = MapVarStore[LittleLong(chunk[i+2])]; int arraynum = MapVarStore[LittleLong(chunk[i+2])];
if ((unsigned)arraynum < (unsigned)NumArrays) if ((unsigned)arraynum < (unsigned)NumArrays)
{ {
SDWORD *elems = ArrayStore[arraynum].Elements; int32_t *elems = ArrayStore[arraynum].Elements;
for (int j = ArrayStore[arraynum].ArraySize; j > 0; --j, ++elems) for (int j = ArrayStore[arraynum].ArraySize; j > 0; --j, ++elems)
{ {
// *elems |= LibraryID; // *elems |= LibraryID;
@ -2088,7 +2088,7 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len)
chunkData += 4; chunkData += 4;
if ((unsigned)arraynum < (unsigned)NumArrays) if ((unsigned)arraynum < (unsigned)NumArrays)
{ {
SDWORD *elems = ArrayStore[arraynum].Elements; int32_t *elems = ArrayStore[arraynum].Elements;
// Ending zeros may be left out. // Ending zeros may be left out.
for (int j = MIN(LittleLong(chunk[1])-5, ArrayStore[arraynum].ArraySize); j > 0; --j, ++elems, ++chunkData) for (int j = MIN(LittleLong(chunk[1])-5, ArrayStore[arraynum].ArraySize); j > 0; --j, ++elems, ++chunkData)
{ {
@ -4371,6 +4371,7 @@ enum EACSFunctions
ACSF_Floor, ACSF_Floor,
ACSF_Round, ACSF_Round,
ACSF_Ceil, ACSF_Ceil,
ACSF_ScriptCall,
// OpenGL stuff // OpenGL stuff
@ -4753,9 +4754,121 @@ static int SwapActorTeleFog(AActor *activator, int tid)
return count; return count;
} }
static int ScriptCall(unsigned argc, int32_t *args)
{
int retval = 0;
if (argc >= 2)
{
auto clsname = FBehavior::StaticLookupString(args[0]);
auto funcname = FBehavior::StaticLookupString(args[1]);
auto cls = PClass::FindClass(clsname);
if (!cls)
{
I_Error("ACS call to unknown class in script function %s.%s", cls, funcname);
}
auto funcsym = dyn_cast<PFunction>(cls->Symbols.FindSymbol(funcname, true));
if (funcsym == nullptr)
{
I_Error("ACS call to unknown script function %s.%s", cls, funcname);
}
auto func = funcsym->Variants[0].Implementation;
if (func->ImplicitArgs > 0)
{
I_Error("ACS call to non-static script function %s.%s", cls, funcname);
}
TArray<VMValue> params;
for (unsigned i = 2; i < argc; i++)
{
if (func->Proto->ArgumentTypes.Size() < i - 1)
{
I_Error("Too many parameters in call to %s.%s", cls, funcname);
}
auto argtype = func->Proto->ArgumentTypes[i - 2];
// The only types allowed are int, bool, double, Name, Sound, Color and String
if (argtype == TypeSInt32 || argtype == TypeColor)
{
params.Push(args[i]);
}
else if (argtype == TypeBool)
{
params.Push(!!args[i]);
}
else if (argtype == TypeFloat64)
{
params.Push(ACSToDouble(args[i]));
}
else if (argtype == TypeName)
{
params.Push(FName(FBehavior::StaticLookupString(args[i])).GetIndex());
}
else if (argtype == TypeString)
{
params.Push(FBehavior::StaticLookupString(args[i]));
}
else if (argtype == TypeSound)
{
params.Push(int(FSoundID(FBehavior::StaticLookupString(args[i]))));
}
else
{
I_Error("Invalid type %s in call to %s.%s", argtype->DescriptiveName(), cls, funcname);
}
}
if (func->Proto->ArgumentTypes.Size() > params.Size())
{
// Check if we got enough parameters. That means we either cover the full argument list of the function or the next argument is optional.
if (!(funcsym->Variants[0].ArgFlags[params.Size()] & VARF_Optional))
{
I_Error("Insufficient parameters in call to %s.%s", cls, funcname);
}
}
// The return value can be the same types as the parameter types, plus void
if (func->Proto->ReturnTypes.Size() == 0)
{
GlobalVMStack.Call(func, &params[0], params.Size(), nullptr, 0);
}
else
{
auto rettype = func->Proto->ReturnTypes[0];
if (rettype == TypeSInt32 || rettype == TypeBool || rettype == TypeColor || rettype == TypeName || rettype == TypeSound)
{
VMReturn ret(&retval);
GlobalVMStack.Call(func, &params[0], params.Size(), &ret, 1);
if (rettype == TypeName)
{
retval = GlobalACSStrings.AddString(FName(ENamedName(retval)));
}
else if (rettype == TypeSound)
{
retval = GlobalACSStrings.AddString(FSoundID(retval));
}
}
else if (rettype == TypeFloat64)
{
double d;
VMReturn ret(&d);
GlobalVMStack.Call(func, &params[0], params.Size(), &ret, 1);
retval = DoubleToACS(d);
}
else if (rettype == TypeString)
{
FString d;
VMReturn ret(&d);
GlobalVMStack.Call(func, &params[0], params.Size(), &ret, 1);
retval = GlobalACSStrings.AddString(d);
}
else
{
// All other return values can not be handled so ignore them.
GlobalVMStack.Call(func, &params[0], params.Size(), nullptr, 0);
}
}
}
return retval;
}
int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args) int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args)
{ {
AActor *actor; AActor *actor;
switch(funcIndex) switch(funcIndex)
@ -6103,6 +6216,9 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
case ACSF_Round: case ACSF_Round:
return (args[0] + 32768) & ~0xffff; return (args[0] + 32768) & ~0xffff;
case ACSF_ScriptCall:
return ScriptCall(argCount, args);
default: default:
break; break;
} }
@ -6192,7 +6308,7 @@ static void SetMarineSprite(AActor *marine, PClassActor *source)
int DLevelScript::RunScript () int DLevelScript::RunScript ()
{ {
DACSThinker *controller = DACSThinker::ActiveThinker; DACSThinker *controller = DACSThinker::ActiveThinker;
SDWORD *locals = &Localvars[0]; int32_t *locals = &Localvars[0];
ACSLocalArrays noarrays; ACSLocalArrays noarrays;
ACSLocalArrays *localarrays = &noarrays; ACSLocalArrays *localarrays = &noarrays;
ScriptFunction *activeFunction = NULL; ScriptFunction *activeFunction = NULL;
@ -6266,7 +6382,7 @@ int DLevelScript::RunScript ()
} }
FACSStack stackobj; FACSStack stackobj;
SDWORD *Stack = stackobj.buffer; int32_t *Stack = stackobj.buffer;
int &sp = stackobj.sp; int &sp = stackobj.sp;
int *pc = this->pc; int *pc = this->pc;
@ -6560,7 +6676,7 @@ int DLevelScript::RunScript ()
int i; int i;
ScriptFunction *func; ScriptFunction *func;
FBehavior *module; FBehavior *module;
SDWORD *mylocals; int32_t *mylocals;
if(pcd == PCD_CALLSTACK) if(pcd == PCD_CALLSTACK)
{ {
@ -6615,7 +6731,7 @@ int DLevelScript::RunScript ()
int value; int value;
union union
{ {
SDWORD *retsp; int32_t *retsp;
CallReturn *ret; CallReturn *ret;
}; };
@ -7770,7 +7886,7 @@ scriptwait:
while (min <= max) while (min <= max)
{ {
int mid = (min + max) / 2; int mid = (min + max) / 2;
SDWORD caseval = LittleLong(pc[mid*2]); int32_t caseval = LittleLong(pc[mid*2]);
if (caseval == STACK(1)) if (caseval == STACK(1))
{ {
pc = activeBehavior->Ofs2PC (LittleLong(pc[mid*2+1])); pc = activeBehavior->Ofs2PC (LittleLong(pc[mid*2+1]));
@ -9185,7 +9301,7 @@ scriptwait:
const char *str = FBehavior::StaticLookupString(STACK(1)); const char *str = FBehavior::StaticLookupString(STACK(1));
if (str != NULL) if (str != NULL)
{ {
STACK(1) = SDWORD(strlen(str)); STACK(1) = int32_t(strlen(str));
break; break;
} }
@ -9355,7 +9471,7 @@ scriptwait:
switch (STACK(1)) switch (STACK(1))
{ {
case PLAYERINFO_TEAM: STACK(2) = userinfo->GetTeam(); break; case PLAYERINFO_TEAM: STACK(2) = userinfo->GetTeam(); break;
case PLAYERINFO_AIMDIST: STACK(2) = (SDWORD)(userinfo->GetAimDist() * (0x40000000/90.)); break; // Yes, this has been returning a BAM since its creation. case PLAYERINFO_AIMDIST: STACK(2) = (int32_t)(userinfo->GetAimDist() * (0x40000000/90.)); break; // Yes, this has been returning a BAM since its creation.
case PLAYERINFO_COLOR: STACK(2) = userinfo->GetColor(); break; case PLAYERINFO_COLOR: STACK(2) = userinfo->GetColor(); break;
case PLAYERINFO_GENDER: STACK(2) = userinfo->GetGender(); break; case PLAYERINFO_GENDER: STACK(2) = userinfo->GetGender(); break;
case PLAYERINFO_NEVERSWITCH: STACK(2) = userinfo->GetNeverSwitch(); break; case PLAYERINFO_NEVERSWITCH: STACK(2) = userinfo->GetNeverSwitch(); break;
@ -9762,7 +9878,7 @@ DLevelScript::DLevelScript (AActor *who, line_t *where, int num, const ScriptPtr
script = num; script = num;
assert(code->VarCount >= code->ArgCount); assert(code->VarCount >= code->ArgCount);
Localvars.Resize(code->VarCount); Localvars.Resize(code->VarCount);
memset(&Localvars[0], 0, code->VarCount * sizeof(SDWORD)); memset(&Localvars[0], 0, code->VarCount * sizeof(int32_t));
for (int i = 0; i < MIN<int>(argcount, code->ArgCount); ++i) for (int i = 0; i < MIN<int>(argcount, code->ArgCount); ++i)
{ {
Localvars[i] = args[i]; Localvars[i] = args[i];

View file

@ -60,14 +60,14 @@ struct InitIntToZero
v = 0; v = 0;
} }
}; };
typedef TMap<SDWORD, SDWORD, THashTraits<SDWORD>, InitIntToZero> FWorldGlobalArray; typedef TMap<int32_t, int32_t, THashTraits<int32_t>, InitIntToZero> FWorldGlobalArray;
// ACS variables with world scope // ACS variables with world scope
extern SDWORD ACS_WorldVars[NUM_WORLDVARS]; extern int32_t ACS_WorldVars[NUM_WORLDVARS];
extern FWorldGlobalArray ACS_WorldArrays[NUM_WORLDVARS]; extern FWorldGlobalArray ACS_WorldArrays[NUM_WORLDVARS];
// ACS variables with global scope // ACS variables with global scope
extern SDWORD ACS_GlobalVars[NUM_GLOBALVARS]; extern int32_t ACS_GlobalVars[NUM_GLOBALVARS];
extern FWorldGlobalArray ACS_GlobalArrays[NUM_GLOBALVARS]; extern FWorldGlobalArray ACS_GlobalArrays[NUM_GLOBALVARS];
#define LIBRARYID_MASK 0xFFF00000 #define LIBRARYID_MASK 0xFFF00000
@ -323,7 +323,7 @@ public:
ACSProfileInfo *GetFunctionProfileData(ScriptFunction *func) { return GetFunctionProfileData((int)(func - (ScriptFunction *)Functions)); } ACSProfileInfo *GetFunctionProfileData(ScriptFunction *func) { return GetFunctionProfileData((int)(func - (ScriptFunction *)Functions)); }
const char *LookupString (DWORD index) const; const char *LookupString (DWORD index) const;
SDWORD *MapVars[NUM_MAPVARS]; int32_t *MapVars[NUM_MAPVARS];
static FBehavior *StaticLoadModule (int lumpnum, FileReader * fr=NULL, int len=0); static FBehavior *StaticLoadModule (int lumpnum, FileReader * fr=NULL, int len=0);
static void StaticLoadDefaultModules (); static void StaticLoadDefaultModules ();
@ -359,7 +359,7 @@ private:
ArrayInfo **Arrays; ArrayInfo **Arrays;
int NumTotalArrays; int NumTotalArrays;
DWORD StringTable; DWORD StringTable;
SDWORD MapVarStore[NUM_MAPVARS]; int32_t MapVarStore[NUM_MAPVARS];
TArray<FBehavior *> Imports; TArray<FBehavior *> Imports;
DWORD LibraryID; DWORD LibraryID;
char ModuleName[9]; char ModuleName[9];
@ -375,7 +375,7 @@ private:
int FindStringInChunk (DWORD *chunk, const char *varname) const; int FindStringInChunk (DWORD *chunk, const char *varname) const;
void SerializeVars (FSerializer &arc); void SerializeVars (FSerializer &arc);
void SerializeVarSet (FSerializer &arc, SDWORD *vars, int max); void SerializeVarSet (FSerializer &arc, int32_t *vars, int max);
void MarkMapVarStrings() const; void MarkMapVarStrings() const;
void LockMapVarStrings() const; void LockMapVarStrings() const;
@ -919,7 +919,7 @@ protected:
int DoSpawnSpot (int type, int spot, int tid, int angle, bool forced); int DoSpawnSpot (int type, int spot, int tid, int angle, bool forced);
int DoSpawnSpotFacing (int type, int spot, int tid, bool forced); int DoSpawnSpotFacing (int type, int spot, int tid, bool forced);
int DoClassifyActor (int tid); int DoClassifyActor (int tid);
int CallFunction(int argCount, int funcIndex, SDWORD *args); int CallFunction(int argCount, int funcIndex, int32_t *args);
void DoFadeTo (int r, int g, int b, int a, int time); void DoFadeTo (int r, int g, int b, int a, int time);
void DoFadeRange (int r1, int g1, int b1, int a1, void DoFadeRange (int r1, int g1, int b1, int a1,

View file

@ -46,7 +46,7 @@
struct sectortype struct sectortype
{ {
SWORD wallptr, wallnum; SWORD wallptr, wallnum;
SDWORD ceilingZ, floorZ; int32_t ceilingZ, floorZ;
SWORD ceilingstat, floorstat; SWORD ceilingstat, floorstat;
SWORD ceilingpicnum, ceilingheinum; SWORD ceilingpicnum, ceilingheinum;
SBYTE ceilingshade; SBYTE ceilingshade;
@ -74,7 +74,7 @@ struct sectortype
//32 bytes //32 bytes
struct walltype struct walltype
{ {
SDWORD x, y; int32_t x, y;
SWORD point2, nextwall, nextsector, cstat; SWORD point2, nextwall, nextsector, cstat;
SWORD picnum, overpicnum; SWORD picnum, overpicnum;
SBYTE shade; SBYTE shade;
@ -100,7 +100,7 @@ struct walltype
//44 bytes //44 bytes
struct spritetype struct spritetype
{ {
SDWORD x, y, z; int32_t x, y, z;
SWORD cstat, picnum; SWORD cstat, picnum;
SBYTE shade; SBYTE shade;
BYTE pal, clipdist, filler; BYTE pal, clipdist, filler;
@ -146,8 +146,8 @@ static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **sprites, int *nu
static void LoadSectors (sectortype *bsectors, int count); static void LoadSectors (sectortype *bsectors, int count);
static void LoadWalls (walltype *walls, int numwalls, sectortype *bsectors); static void LoadWalls (walltype *walls, int numwalls, sectortype *bsectors);
static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites, sectortype *bsectors, FMapThing *mapthings); static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites, sectortype *bsectors, FMapThing *mapthings);
static vertex_t *FindVertex (SDWORD x, SDWORD y); static vertex_t *FindVertex (int32_t x, int32_t y);
static void CreateStartSpot (SDWORD *pos, FMapThing *start); static void CreateStartSpot (int32_t *pos, FMapThing *start);
static void CalcPlane (SlopeWork &slope, secplane_t &plane); static void CalcPlane (SlopeWork &slope, secplane_t &plane);
static void Decrypt (void *to, const void *from, int len, int key); static void Decrypt (void *to, const void *from, int len, int key);
@ -232,7 +232,7 @@ bool P_LoadBuildMap (BYTE *data, size_t len, FMapThing **sprites, int *numspr)
numsprites = *(WORD *)(data + 24 + numsec*sizeof(sectortype) + numwalls*sizeof(walltype)); numsprites = *(WORD *)(data + 24 + numsec*sizeof(sectortype) + numwalls*sizeof(walltype));
*sprites = new FMapThing[numsprites + 1]; *sprites = new FMapThing[numsprites + 1];
CreateStartSpot ((SDWORD *)(data + 4), *sprites); CreateStartSpot ((int32_t *)(data + 4), *sprites);
*numspr = 1 + LoadSprites ((spritetype *)(data + 26 + numsec*sizeof(sectortype) + numwalls*sizeof(walltype)), *numspr = 1 + LoadSprites ((spritetype *)(data + 26 + numsec*sizeof(sectortype) + numwalls*sizeof(walltype)),
NULL, numsprites, (sectortype *)(data + 22), *sprites + 1); NULL, numsprites, (sectortype *)(data + 22), *sprites + 1);
@ -755,7 +755,7 @@ static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites,
// //
//========================================================================== //==========================================================================
vertex_t *FindVertex (SDWORD xx, SDWORD yy) vertex_t *FindVertex (int32_t xx, int32_t yy)
{ {
int i; int i;
@ -780,7 +780,7 @@ vertex_t *FindVertex (SDWORD xx, SDWORD yy)
// //
//========================================================================== //==========================================================================
static void CreateStartSpot (SDWORD *pos, FMapThing *start) static void CreateStartSpot (int32_t *pos, FMapThing *start)
{ {
short angle = LittleShort(*(WORD *)(&pos[3])); short angle = LittleShort(*(WORD *)(&pos[3]));
FMapThing mt = { 0, }; FMapThing mt = { 0, };

View file

@ -66,22 +66,22 @@
// The conversations as they exist inside a SCRIPTxx lump. // The conversations as they exist inside a SCRIPTxx lump.
struct Response struct Response
{ {
SDWORD GiveType; int32_t GiveType;
SDWORD Item[3]; int32_t Item[3];
SDWORD Count[3]; int32_t Count[3];
char Reply[32]; char Reply[32];
char Yes[80]; char Yes[80];
SDWORD Link; int32_t Link;
DWORD Log; uint32_t Log;
char No[80]; char No[80];
}; };
struct Speech struct Speech
{ {
DWORD SpeakerType; uint32_t SpeakerType;
SDWORD DropType; int32_t DropType;
SDWORD ItemCheck[3]; int32_t ItemCheck[3];
SDWORD Link; int32_t Link;
char Name[16]; char Name[16];
char Sound[8]; char Sound[8];
char Backdrop[8]; char Backdrop[8];
@ -92,9 +92,9 @@ struct Speech
// The Teaser version of the game uses an older version of the structure // The Teaser version of the game uses an older version of the structure
struct TeaserSpeech struct TeaserSpeech
{ {
DWORD SpeakerType; uint32_t SpeakerType;
SDWORD DropType; int32_t DropType;
DWORD VoiceNumber; uint32_t VoiceNumber;
char Name[16]; char Name[16];
char Dialogue[320]; char Dialogue[320];
Response Responses[5]; Response Responses[5];
@ -116,8 +116,8 @@ static int ConversationPauseTic;
static int StaticLastReply; static int StaticLastReply;
static bool LoadScriptFile(int lumpnum, FileReader *lump, int numnodes, bool include, int type); static bool LoadScriptFile(int lumpnum, FileReader *lump, int numnodes, bool include, int type);
static FStrifeDialogueNode *ReadRetailNode (FileReader *lump, DWORD &prevSpeakerType); static FStrifeDialogueNode *ReadRetailNode (FileReader *lump, uint32_t &prevSpeakerType);
static FStrifeDialogueNode *ReadTeaserNode (FileReader *lump, DWORD &prevSpeakerType); static FStrifeDialogueNode *ReadTeaserNode (FileReader *lump, uint32_t &prevSpeakerType);
static void ParseReplies (FStrifeDialogueReply **replyptr, Response *responses); static void ParseReplies (FStrifeDialogueReply **replyptr, Response *responses);
static bool DrawConversationMenu (); static bool DrawConversationMenu ();
static void PickConversationReply (int replyindex); static void PickConversationReply (int replyindex);
@ -243,7 +243,7 @@ bool LoadScriptFile (const char *name, bool include, int type)
static bool LoadScriptFile(int lumpnum, FileReader *lump, int numnodes, bool include, int type) static bool LoadScriptFile(int lumpnum, FileReader *lump, int numnodes, bool include, int type)
{ {
int i; int i;
DWORD prevSpeakerType; uint32_t prevSpeakerType;
FStrifeDialogueNode *node; FStrifeDialogueNode *node;
char buffer[4]; char buffer[4];
@ -317,7 +317,7 @@ static bool LoadScriptFile(int lumpnum, FileReader *lump, int numnodes, bool inc
// //
//============================================================================ //============================================================================
static FStrifeDialogueNode *ReadRetailNode (FileReader *lump, DWORD &prevSpeakerType) static FStrifeDialogueNode *ReadRetailNode (FileReader *lump, uint32_t &prevSpeakerType)
{ {
FStrifeDialogueNode *node; FStrifeDialogueNode *node;
Speech speech; Speech speech;
@ -393,7 +393,7 @@ static FStrifeDialogueNode *ReadRetailNode (FileReader *lump, DWORD &prevSpeaker
// //
//============================================================================ //============================================================================
static FStrifeDialogueNode *ReadTeaserNode (FileReader *lump, DWORD &prevSpeakerType) static FStrifeDialogueNode *ReadTeaserNode (FileReader *lump, uint32_t &prevSpeakerType)
{ {
FStrifeDialogueNode *node; FStrifeDialogueNode *node;
TeaserSpeech speech; TeaserSpeech speech;

View file

@ -82,13 +82,13 @@ static void CreateCachedNodes(MapData *map);
// fixed 32 bit gl_vert format v2.0+ (glBsp 1.91) // fixed 32 bit gl_vert format v2.0+ (glBsp 1.91)
struct mapglvertex_t struct mapglvertex_t
{ {
SDWORD x,y; int32_t x,y;
}; };
struct gl3_mapsubsector_t struct gl3_mapsubsector_t
{ {
SDWORD numsegs; int32_t numsegs;
SDWORD firstseg; // Index of first one; segs are stored sequentially. int32_t firstseg; // Index of first one; segs are stored sequentially.
}; };
struct glseg_t struct glseg_t
@ -102,11 +102,11 @@ struct glseg_t
struct glseg3_t struct glseg3_t
{ {
SDWORD v1; int32_t v1;
SDWORD v2; int32_t v2;
WORD linedef; WORD linedef;
WORD side; WORD side;
SDWORD partner; int32_t partner;
}; };
struct gl5_mapnode_t struct gl5_mapnode_t
@ -621,7 +621,7 @@ static bool LoadNodes (FileReader * lump)
no->dy = LittleShort(mn->dy)<<FRACBITS; no->dy = LittleShort(mn->dy)<<FRACBITS;
for (j = 0; j < 2; j++) for (j = 0; j < 2; j++)
{ {
SDWORD child = LittleLong(mn->children[j]); int32_t child = LittleLong(mn->children[j]);
if (child & GL5_NF_SUBSECTOR) if (child & GL5_NF_SUBSECTOR)
{ {
child &= ~GL5_NF_SUBSECTOR; child &= ~GL5_NF_SUBSECTOR;

View file

@ -5563,6 +5563,7 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
for (int ii=0; ii < BODYQUESIZE; ++ii) for (int ii=0; ii < BODYQUESIZE; ++ii)
if (bodyque[ii] == p->mo) if (bodyque[ii] == p->mo)
bodyque[ii] = oldactor; bodyque[ii] = oldactor;
E_PlayerRespawned(int(p - players));
FBehavior::StaticStartTypedScripts (SCRIPT_Respawn, p->mo, true); FBehavior::StaticStartTypedScripts (SCRIPT_Respawn, p->mo, true);
} }
} }

View file

@ -69,7 +69,7 @@ public:
bool bFlippable; bool bFlippable;
bool bReturning; bool bReturning;
FSwitchDef *m_SwitchDef; FSwitchDef *m_SwitchDef;
SDWORD m_Frame; int32_t m_Frame;
DWORD m_Timer; DWORD m_Timer;
DVector2 m_Pos; DVector2 m_Pos;

View file

@ -147,7 +147,7 @@ polyspawns_t *polyspawns; // [RH] Let P_SpawnMapThings() find our thingies for u
// PRIVATE DATA DEFINITIONS ------------------------------------------------ // PRIVATE DATA DEFINITIONS ------------------------------------------------
static TArray<SDWORD> KnownPolySides; static TArray<int32_t> KnownPolySides;
static FPolyNode *FreePolyNodes; static FPolyNode *FreePolyNodes;
// CODE -------------------------------------------------------------------- // CODE --------------------------------------------------------------------

View file

@ -151,7 +151,7 @@ static DWORD Zip_FindCentralDir(FileReader * fin)
if (fin->Seek(uReadPos, SEEK_SET) != 0) break; if (fin->Seek(uReadPos, SEEK_SET) != 0) break;
if (fin->Read(buf, (SDWORD)uReadSize) != (SDWORD)uReadSize) break; if (fin->Read(buf, (int32_t)uReadSize) != (int32_t)uReadSize) break;
for (i = (int)uReadSize - 3; (i--) > 0;) for (i = (int)uReadSize - 3; (i--) > 0;)
{ {

View file

@ -167,7 +167,7 @@ struct FBloodSFX
int Pitch; // pitch change int Pitch; // pitch change
int PitchRange; // range of random pitch int PitchRange; // range of random pitch
DWORD Format; // format of audio 1=11025 5=22050 DWORD Format; // format of audio 1=11025 5=22050
SDWORD LoopStart; // loop position (-1 means no looping) int32_t LoopStart; // loop position (-1 means no looping)
char RawName[9]; // name of RAW resource char RawName[9]; // name of RAW resource
}; };

View file

@ -34,8 +34,8 @@
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
#define GetCommand(a) ((a) & 255) #define GetCommand(a) ((a) & 255)
#define GetData(a) (SDWORD(a) >> 8 ) #define GetData(a) (int32_t(a) >> 8 )
#define GetFloatData(a) float((SDWORD(a) >> 8 )/65536.f) #define GetFloatData(a) float((int32_t(a) >> 8 )/65536.f)
#define MakeCommand(a,b) ((a) | ((b) << 8)) #define MakeCommand(a,b) ((a) | ((b) << 8))
#define HexenPlatSeq(a) (a) #define HexenPlatSeq(a) (a)
#define HexenDoorSeq(a) ((a) | 0x40) #define HexenDoorSeq(a) ((a) | 0x40)
@ -1390,7 +1390,7 @@ void SN_StopAllSequences (void)
// //
//========================================================================== //==========================================================================
ptrdiff_t SN_GetSequenceOffset (int sequence, SDWORD *sequencePtr) ptrdiff_t SN_GetSequenceOffset (int sequence, int32_t *sequencePtr)
{ {
return sequencePtr - Sequences[sequence]->Script; return sequencePtr - Sequences[sequence]->Script;
} }

View file

@ -44,7 +44,7 @@ protected:
DSeqNode (); DSeqNode ();
DSeqNode (int sequence, int modenum); DSeqNode (int sequence, int modenum);
SDWORD *m_SequencePtr; int32_t *m_SequencePtr;
int m_Sequence; int m_Sequence;
FSoundID m_CurrentSoundID; FSoundID m_CurrentSoundID;
@ -74,7 +74,7 @@ struct FSoundSequence
FName SeqName; FName SeqName;
FName Slot; FName Slot;
FSoundID StopSound; FSoundID StopSound;
SDWORD Script[1]; // + more until end of sequence script int32_t Script[1]; // + more until end of sequence script
}; };
void S_ParseSndSeq (int levellump); void S_ParseSndSeq (int levellump);
@ -93,7 +93,7 @@ void SN_StopSequence (FPolyObj *poly);
bool SN_AreModesSame(int sequence, seqtype_t type, int mode1, int mode2); bool SN_AreModesSame(int sequence, seqtype_t type, int mode1, int mode2);
bool SN_AreModesSame(FName name, int mode1, int mode2); bool SN_AreModesSame(FName name, int mode1, int mode2);
void SN_UpdateActiveSequences (void); void SN_UpdateActiveSequences (void);
ptrdiff_t SN_GetSequenceOffset (int sequence, SDWORD *sequencePtr); ptrdiff_t SN_GetSequenceOffset (int sequence, int32_t *sequencePtr);
void SN_DoStop (void *); void SN_DoStop (void *);
void SN_ChangeNodeData (int nodeNum, int seqOffset, int delayTics, void SN_ChangeNodeData (int nodeNum, int seqOffset, int delayTics,
float volume, int currentSoundID); float volume, int currentSoundID);

View file

@ -1400,7 +1400,7 @@ sfxinfo_t *S_LoadSound(sfxinfo_t *sfx)
FWadLump wlump = Wads.OpenLumpNum(sfx->lumpnum); FWadLump wlump = Wads.OpenLumpNum(sfx->lumpnum);
BYTE *sfxdata = new BYTE[size]; BYTE *sfxdata = new BYTE[size];
wlump.Read(sfxdata, size); wlump.Read(sfxdata, size);
SDWORD dmxlen = LittleLong(((SDWORD *)sfxdata)[1]); int32_t dmxlen = LittleLong(((int32_t *)sfxdata)[1]);
std::pair<SoundHandle,bool> snd; std::pair<SoundHandle,bool> snd;
// If the sound is voc, use the custom loader. // If the sound is voc, use the custom loader.
@ -1460,7 +1460,7 @@ static void S_LoadSound3D(sfxinfo_t *sfx)
FWadLump wlump = Wads.OpenLumpNum(sfx->lumpnum); FWadLump wlump = Wads.OpenLumpNum(sfx->lumpnum);
BYTE *sfxdata = new BYTE[size]; BYTE *sfxdata = new BYTE[size];
wlump.Read(sfxdata, size); wlump.Read(sfxdata, size);
SDWORD dmxlen = LittleLong(((SDWORD *)sfxdata)[1]); int32_t dmxlen = LittleLong(((int32_t *)sfxdata)[1]);
std::pair<SoundHandle,bool> snd; std::pair<SoundHandle,bool> snd;
// If the sound is voc, use the custom loader. // If the sound is voc, use the custom loader.

View file

@ -483,7 +483,7 @@ static void ParseInsideDecoration (Baggage &bag, AActor *defaults,
else if (sc.Compare ("Mass")) else if (sc.Compare ("Mass"))
{ {
sc.MustGetFloat (); sc.MustGetFloat ();
defaults->Mass = SDWORD(sc.Float); defaults->Mass = int32_t(sc.Float);
} }
else if (sc.Compare ("Translation1")) else if (sc.Compare ("Translation1"))
{ {

View file

@ -59,6 +59,7 @@
#include "menu/menu.h" #include "menu/menu.h"
#include "teaminfo.h" #include "teaminfo.h"
#include "r_data/sprites.h" #include "r_data/sprites.h"
#include "serializer.h"
static TArray<FPropertyInfo*> properties; static TArray<FPropertyInfo*> properties;
static TArray<AFuncDesc> AFTable; static TArray<AFuncDesc> AFTable;
@ -741,7 +742,7 @@ static int fieldcmp(const void * a, const void * b)
void InitThingdef() void InitThingdef()
{ {
// Create all global variables here because this cannot be done on the script side and really isn't worth adding support for. // Create all global variables here because this cannot be done on the script side and really isn't worth adding support for.
// Also create all special fields here that cannot be declared by script syntax. // Also create all special fields here that cannot be declared by script syntax plus the pointer serializers. Doing all these with class overrides would be a bit messy.
auto secplanestruct = NewNativeStruct("Secplane", nullptr); auto secplanestruct = NewNativeStruct("Secplane", nullptr);
secplanestruct->Size = sizeof(secplane_t); secplanestruct->Size = sizeof(secplane_t);
@ -750,18 +751,62 @@ void InitThingdef()
auto sectorstruct = NewNativeStruct("Sector", nullptr); auto sectorstruct = NewNativeStruct("Sector", nullptr);
sectorstruct->Size = sizeof(sector_t); sectorstruct->Size = sizeof(sector_t);
sectorstruct->Align = alignof(sector_t); sectorstruct->Align = alignof(sector_t);
NewPointer(sectorstruct, false)->InstallHandlers(
[](FSerializer &ar, const char *key, const void *addr)
{
ar(key, *(sector_t **)addr);
},
[](FSerializer &ar, const char *key, void *addr)
{
Serialize<sector_t>(ar, key, *(sector_t **)addr, nullptr);
return true;
}
);
auto linestruct = NewNativeStruct("Line", nullptr); auto linestruct = NewNativeStruct("Line", nullptr);
linestruct->Size = sizeof(line_t); linestruct->Size = sizeof(line_t);
linestruct->Align = alignof(line_t); linestruct->Align = alignof(line_t);
NewPointer(linestruct, false)->InstallHandlers(
[](FSerializer &ar, const char *key, const void *addr)
{
ar(key, *(line_t **)addr);
},
[](FSerializer &ar, const char *key, void *addr)
{
Serialize<line_t>(ar, key, *(line_t **)addr, nullptr);
return true;
}
);
auto sidestruct = NewNativeStruct("Side", nullptr); auto sidestruct = NewNativeStruct("Side", nullptr);
sidestruct->Size = sizeof(side_t); sidestruct->Size = sizeof(side_t);
sidestruct->Align = alignof(side_t); sidestruct->Align = alignof(side_t);
NewPointer(sidestruct, false)->InstallHandlers(
[](FSerializer &ar, const char *key, const void *addr)
{
ar(key, *(side_t **)addr);
},
[](FSerializer &ar, const char *key, void *addr)
{
Serialize<side_t>(ar, key, *(side_t **)addr, nullptr);
return true;
}
);
auto vertstruct = NewNativeStruct("Vertex", nullptr); auto vertstruct = NewNativeStruct("Vertex", nullptr);
vertstruct->Size = sizeof(vertex_t); vertstruct->Size = sizeof(vertex_t);
vertstruct->Align = alignof(vertex_t); vertstruct->Align = alignof(vertex_t);
NewPointer(vertstruct, false)->InstallHandlers(
[](FSerializer &ar, const char *key, const void *addr)
{
ar(key, *(vertex_t **)addr);
},
[](FSerializer &ar, const char *key, void *addr)
{
Serialize<vertex_t>(ar, key, *(vertex_t **)addr, nullptr);
return true;
}
);
auto sectorportalstruct = NewNativeStruct("SectorPortal", nullptr); auto sectorportalstruct = NewNativeStruct("SectorPortal", nullptr);
sectorportalstruct->Size = sizeof(FSectorPortal); sectorportalstruct->Size = sizeof(FSectorPortal);
@ -779,6 +824,36 @@ void InitThingdef()
teamstruct->Size = sizeof(FTeam); teamstruct->Size = sizeof(FTeam);
teamstruct->Align = alignof(FTeam); teamstruct->Align = alignof(FTeam);
PStruct *pstruct = NewNativeStruct("PlayerInfo", nullptr);
pstruct->Size = sizeof(player_t);
pstruct->Align = alignof(player_t);
NewPointer(pstruct, false)->InstallHandlers(
[](FSerializer &ar, const char *key, const void *addr)
{
ar(key, *(player_t **)addr);
},
[](FSerializer &ar, const char *key, void *addr)
{
Serialize<player_t>(ar, key, *(player_t **)addr, nullptr);
return true;
}
);
auto fontstruct = NewNativeStruct("FFont", nullptr);
fontstruct->Size = sizeof(FFont);
fontstruct->Align = alignof(FFont);
NewPointer(fontstruct, false)->InstallHandlers(
[](FSerializer &ar, const char *key, const void *addr)
{
ar(key, *(FFont **)addr);
},
[](FSerializer &ar, const char *key, void *addr)
{
Serialize<FFont>(ar, key, *(FFont **)addr, nullptr);
return true;
}
);
// set up the lines array in the sector struct. This is a bit messy because the type system is not prepared to handle a pointer to an array of pointers to a native struct even remotely well... // set up the lines array in the sector struct. This is a bit messy because the type system is not prepared to handle a pointer to an array of pointers to a native struct even remotely well...
// As a result, the size has to be set to something large and arbritrary because it can change between maps. This will need some serious improvement when things get cleaned up. // As a result, the size has to be set to something large and arbritrary because it can change between maps. This will need some serious improvement when things get cleaned up.
sectorstruct->AddNativeField("lines", NewPointer(NewResizableArray(NewPointer(linestruct, false)), false), myoffsetof(sector_t, Lines), VARF_Native); sectorstruct->AddNativeField("lines", NewPointer(NewResizableArray(NewPointer(linestruct, false)), false), myoffsetof(sector_t, Lines), VARF_Native);
@ -843,9 +918,6 @@ void InitThingdef()
Namespaces.GlobalNamespace->Symbols.AddSymbol(gi); Namespaces.GlobalNamespace->Symbols.AddSymbol(gi);
// set up a variable for the global players array. // set up a variable for the global players array.
PStruct *pstruct = NewNativeStruct("PlayerInfo", nullptr);
pstruct->Size = sizeof(player_t);
pstruct->Align = alignof(player_t);
PArray *parray = NewArray(pstruct, MAXPLAYERS); PArray *parray = NewArray(pstruct, MAXPLAYERS);
PField *fieldptr = new PField("players", parray, VARF_Native | VARF_Static, (intptr_t)&players); PField *fieldptr = new PField("players", parray, VARF_Native | VARF_Static, (intptr_t)&players);
Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr); Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr);

View file

@ -289,7 +289,7 @@ void FBackdropTexture::Render()
DWORD a1, a2, a3, a4; DWORD a1, a2, a3, a4;
SDWORD c1, c2, c3, c4; int32_t c1, c2, c3, c4;
DWORD tx, ty, tc, ts; DWORD tx, ty, tc, ts;
DWORD ux, uy, uc, us; DWORD ux, uy, uc, us;
DWORD ltx, lty, lux, luy; DWORD ltx, lty, lux, luy;
@ -302,10 +302,10 @@ void FBackdropTexture::Render()
double z1 = (cos(TORAD(z2ang)) / 4 + 0.5) * (0x8000000); double z1 = (cos(TORAD(z2ang)) / 4 + 0.5) * (0x8000000);
double z2 = (cos(TORAD(z1ang)) / 4 + 0.75) * (0x8000000); double z2 = (cos(TORAD(z1ang)) / 4 + 0.75) * (0x8000000);
tc = SDWORD(cos(TORAD(t1ang)) * z1); tc = int32_t(cos(TORAD(t1ang)) * z1);
ts = SDWORD(sin(TORAD(t1ang)) * z1); ts = int32_t(sin(TORAD(t1ang)) * z1);
uc = SDWORD(cos(TORAD(t2ang)) * z2); uc = int32_t(cos(TORAD(t2ang)) * z2);
us = SDWORD(sin(TORAD(t2ang)) * z2); us = int32_t(sin(TORAD(t2ang)) * z2);
ltx = -width / 2 * tc; ltx = -width / 2 * tc;
lty = -width / 2 * ts; lty = -width / 2 * ts;
@ -316,8 +316,8 @@ void FBackdropTexture::Render()
{ {
a1 = time1; a1 = time1;
a2 = time2; a2 = time2;
c3 = SDWORD(cos(TORAD(a3)) * 65536.0); c3 = int32_t(cos(TORAD(a3)) * 65536.0);
c4 = SDWORD(cos(TORAD(a4)) * 65536.0); c4 = int32_t(cos(TORAD(a4)) * 65536.0);
tx = ltx - (y - height / 2)*ts; tx = ltx - (y - height / 2)*ts;
ty = lty + (y - height / 2)*tc; ty = lty + (y - height / 2)*tc;
ux = lux - (y - height / 2)*us; ux = lux - (y - height / 2)*us;

View file

@ -126,7 +126,7 @@ struct DDSURFACEDESC2
DWORD Width; DWORD Width;
union union
{ {
SDWORD Pitch; int32_t Pitch;
DWORD LinearSize; DWORD LinearSize;
}; };
DWORD Depth; DWORD Depth;
@ -172,7 +172,7 @@ protected:
BYTE RShiftL, GShiftL, BShiftL, AShiftL; BYTE RShiftL, GShiftL, BShiftL, AShiftL;
BYTE RShiftR, GShiftR, BShiftR, AShiftR; BYTE RShiftR, GShiftR, BShiftR, AShiftR;
SDWORD Pitch; int32_t Pitch;
DWORD LinearSize; DWORD LinearSize;
static void CalcBitShift (DWORD mask, BYTE *lshift, BYTE *rshift); static void CalcBitShift (DWORD mask, BYTE *lshift, BYTE *rshift);

View file

@ -253,7 +253,7 @@ http://www.midi.org/about-midi/dls/dlsspec.shtml
#define FAR #define FAR
typedef SWORD SHORT; typedef SWORD SHORT;
typedef WORD USHORT; typedef WORD USHORT;
typedef SDWORD LONG; typedef int32_t LONG;
typedef DWORD ULONG; typedef DWORD ULONG;
#define mmioFOURCC MAKE_ID #define mmioFOURCC MAKE_ID
#define DEFINE_GUID(A, B, C, E, F, G, H, I, J, K, L, M) #define DEFINE_GUID(A, B, C, E, F, G, H, I, J, K, L, M)
@ -1075,15 +1075,15 @@ static double to_normalized_percent(int decipercent)
} }
/* convert from 8bit value to fractional offset (15.15) */ /* convert from 8bit value to fractional offset (15.15) */
static SDWORD to_offset(int offset) static int32_t to_offset(int offset)
{ {
return (SDWORD)offset << (7+15); return (int32_t)offset << (7+15);
} }
/* calculate ramp rate in fractional unit; /* calculate ramp rate in fractional unit;
* diff = 8bit, time = msec * diff = 8bit, time = msec
*/ */
static SDWORD calc_rate(Renderer *song, int diff, int sample_rate, double msec) static int32_t calc_rate(Renderer *song, int diff, int sample_rate, double msec)
{ {
double rate; double rate;
@ -1093,7 +1093,7 @@ static SDWORD calc_rate(Renderer *song, int diff, int sample_rate, double msec)
diff = 255; diff = 255;
diff <<= (7+15); diff <<= (7+15);
rate = ((double)diff / song->rate) * song->control_ratio * 1000.0 / msec; rate = ((double)diff / song->rate) * song->control_ratio * 1000.0 / msec;
return (SDWORD)rate; return (int32_t)rate;
} }
static int load_connection(ULONG cConnections, CONNECTION *artList, USHORT destination) static int load_connection(ULONG cConnections, CONNECTION *artList, USHORT destination)

View file

@ -199,12 +199,12 @@ static double timecent_to_sec(SWORD timecent)
return pow(2.0, timecent / 1200.0); return pow(2.0, timecent / 1200.0);
} }
static SDWORD to_offset(int offset) static int32_t to_offset(int offset)
{ {
return (SDWORD)offset << (7+15); return (int32_t)offset << (7+15);
} }
static SDWORD calc_rate(Renderer *song, int diff, double sec) static int32_t calc_rate(Renderer *song, int diff, double sec)
{ {
double rate; double rate;
@ -214,7 +214,7 @@ static SDWORD calc_rate(Renderer *song, int diff, double sec)
diff = 255; diff = 255;
diff <<= (7+15); diff <<= (7+15);
rate = ((double)diff / song->rate) * song->control_ratio / sec; rate = ((double)diff / song->rate) * song->control_ratio / sec;
return (SDWORD)rate; return (int32_t)rate;
} }
@ -1524,7 +1524,7 @@ void SFFile::LoadSample(SFSample *sample)
{ {
BYTE samp; BYTE samp;
*fp >> samp; *fp >> samp;
sample->InMemoryData[i] = ((((SDWORD(sample->InMemoryData[i] * 32768) << 8) | samp) << 8) >> 8) / 8388608.f; sample->InMemoryData[i] = ((((int32_t(sample->InMemoryData[i] * 32768) << 8) | samp) << 8) >> 8) / 8388608.f;
} }
} }
// Final 0 byte is for interpolation. // Final 0 byte is for interpolation.

View file

@ -426,7 +426,7 @@ static int update_signal(Voice *v)
return 0; return 0;
} }
static void mix_mystery_signal(SDWORD control_ratio, const sample_t *sp, float *lp, Voice *v, int count) static void mix_mystery_signal(int32_t control_ratio, const sample_t *sp, float *lp, Voice *v, int count)
{ {
final_volume_t final_volume_t
left = v->left_mix, left = v->left_mix,
@ -477,7 +477,7 @@ static void mix_mystery_signal(SDWORD control_ratio, const sample_t *sp, float *
} }
} }
static void mix_single_signal(SDWORD control_ratio, const sample_t *sp, float *lp, Voice *v, float *ampat, int count) static void mix_single_signal(int32_t control_ratio, const sample_t *sp, float *lp, Voice *v, float *ampat, int count)
{ {
final_volume_t amp; final_volume_t amp;
int cc; int cc;
@ -518,17 +518,17 @@ static void mix_single_signal(SDWORD control_ratio, const sample_t *sp, float *l
} }
} }
static void mix_single_left_signal(SDWORD control_ratio, const sample_t *sp, float *lp, Voice *v, int count) static void mix_single_left_signal(int32_t control_ratio, const sample_t *sp, float *lp, Voice *v, int count)
{ {
mix_single_signal(control_ratio, sp, lp, v, &v->left_mix, count); mix_single_signal(control_ratio, sp, lp, v, &v->left_mix, count);
} }
static void mix_single_right_signal(SDWORD control_ratio, const sample_t *sp, float *lp, Voice *v, int count) static void mix_single_right_signal(int32_t control_ratio, const sample_t *sp, float *lp, Voice *v, int count)
{ {
mix_single_signal(control_ratio, sp, lp + 1, v, &v->right_mix, count); mix_single_signal(control_ratio, sp, lp + 1, v, &v->right_mix, count);
} }
static void mix_mono_signal(SDWORD control_ratio, const sample_t *sp, float *lp, Voice *v, int count) static void mix_mono_signal(int32_t control_ratio, const sample_t *sp, float *lp, Voice *v, int count)
{ {
final_volume_t final_volume_t
left = v->left_mix; left = v->left_mix;
@ -568,7 +568,7 @@ static void mix_mono_signal(SDWORD control_ratio, const sample_t *sp, float *lp,
} }
} }
static void mix_mystery(SDWORD control_ratio, const sample_t *sp, float *lp, Voice *v, int count) static void mix_mystery(int32_t control_ratio, const sample_t *sp, float *lp, Voice *v, int count)
{ {
final_volume_t final_volume_t
left = v->left_mix, left = v->left_mix,

View file

@ -211,7 +211,7 @@ enum
struct Sample struct Sample
{ {
SDWORD int32_t
loop_start, loop_end, data_length, loop_start, loop_end, data_length,
sample_rate; sample_rate;
float float
@ -233,7 +233,7 @@ struct Sample
} sf2; } sf2;
} envelope; } envelope;
sample_t *data; sample_t *data;
SDWORD int32_t
tremolo_sweep_increment, tremolo_phase_increment, tremolo_sweep_increment, tremolo_phase_increment,
vibrato_sweep_increment, vibrato_control_ratio; vibrato_sweep_increment, vibrato_control_ratio;
BYTE BYTE

View file

@ -75,6 +75,7 @@ FRenderer *Renderer;
IMPLEMENT_CLASS(DCanvas, true, false) IMPLEMENT_CLASS(DCanvas, true, false)
IMPLEMENT_CLASS(DFrameBuffer, true, false) IMPLEMENT_CLASS(DFrameBuffer, true, false)
EXTERN_CVAR (Bool, swtruecolor) EXTERN_CVAR (Bool, swtruecolor)
EXTERN_CVAR (Bool, fullscreen)
#if defined(_DEBUG) && defined(_M_IX86) && !defined(__MINGW32__) #if defined(_DEBUG) && defined(_M_IX86) && !defined(__MINGW32__)
#define DBGBREAK { __asm int 3 } #define DBGBREAK { __asm int 3 }
@ -1493,6 +1494,9 @@ CCMD (vid_setmode)
goodmode = true; goodmode = true;
} }
if (!fullscreen)
goodmode = true;
if (goodmode) if (goodmode)
{ {
// The actual change of resolution will take place // The actual change of resolution will take place