Permalink
Browse files

- moved UDMF custom properties into FLevelLocals.

  • Loading branch information...
coelckers committed Jan 10, 2019
1 parent 229dde1 commit 439c36c8f721013da3f9c807d58b6062c8c92daa
Showing with 30 additions and 39 deletions.
  1. +3 −0 src/g_levellocals.h
  2. +7 −21 src/maploader/udmf.cpp
  3. +6 −6 src/p_acs.cpp
  4. +5 −3 src/p_setup.cpp
  5. +3 −3 src/p_setup.h
  6. +6 −6 src/scripting/vmthunks.cpp
@@ -60,6 +60,7 @@ class DSectorMarker;

typedef TMap<int, int> FDialogueIDMap; // maps dialogue IDs to dialogue array index (for ACS)
typedef TMap<FName, int> FDialogueMap; // maps actor class names to dialogue array index
typedef TMap<int, FUDMFKeys> FUDMFKeyMap;

struct FLevelData
{
@@ -121,6 +122,8 @@ struct FLevelData
int i_compatflags = 0;
int i_compatflags2 = 0;

FUDMFKeyMap UDMFKeys[4];

};


@@ -285,20 +285,6 @@ const char *UDMFParserBase::CheckString(const char *key)
//
//===========================================================================

typedef TMap<int, FUDMFKeys> FUDMFKeyMap;


static FUDMFKeyMap UDMFKeys[4];
// Things must be handled differently

void P_ClearUDMFKeys()
{
for(int i=0;i<4;i++)
{
UDMFKeys[i].Clear();
}
}

static int udmfcmp(const void *a, const void *b)
{
FUDMFKey *A = (FUDMFKey*)a;
@@ -346,11 +332,11 @@ FUDMFKey *FUDMFKeys::Find(FName key)
//
//===========================================================================

int GetUDMFInt(int type, int index, FName key)
int GetUDMFInt(FLevelLocals *Level, int type, int index, FName key)
{
assert(type >=0 && type <=3);

FUDMFKeys *pKeys = UDMFKeys[type].CheckKey(index);
FUDMFKeys *pKeys = Level->UDMFKeys[type].CheckKey(index);

if (pKeys != NULL)
{
@@ -363,11 +349,11 @@ int GetUDMFInt(int type, int index, FName key)
return 0;
}

double GetUDMFFloat(int type, int index, FName key)
double GetUDMFFloat(FLevelLocals *Level, int type, int index, FName key)
{
assert(type >=0 && type <=3);

FUDMFKeys *pKeys = UDMFKeys[type].CheckKey(index);
FUDMFKeys *pKeys = Level->UDMFKeys[type].CheckKey(index);

if (pKeys != NULL)
{
@@ -380,11 +366,11 @@ double GetUDMFFloat(int type, int index, FName key)
return 0;
}

FString GetUDMFString(int type, int index, FName key)
FString GetUDMFString(FLevelLocals *Level, int type, int index, FName key)
{
assert(type >= 0 && type <= 3);

FUDMFKeys *pKeys = UDMFKeys[type].CheckKey(index);
FUDMFKeys *pKeys = Level->UDMFKeys[type].CheckKey(index);

if (pKeys != NULL)
{
@@ -459,7 +445,7 @@ class UDMFParser : public UDMFParserBase
}
void AddUserKey(FName key, int kind, int index)
{
FUDMFKeys &keyarray = UDMFKeys[kind][index];
FUDMFKeys &keyarray = Level->UDMFKeys[kind][index];

for(unsigned i=0; i < keyarray.Size(); i++)
{
@@ -5311,26 +5311,26 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args)
switch(funcIndex)
{
case ACSF_GetLineUDMFInt:
return GetUDMFInt(UDMF_Line, LineFromID(args[0]), Level->Behaviors.LookupString(args[1]));
return GetUDMFInt(Level, UDMF_Line, LineFromID(args[0]), Level->Behaviors.LookupString(args[1]));

case ACSF_GetLineUDMFFixed:
return DoubleToACS(GetUDMFFloat(UDMF_Line, LineFromID(args[0]), Level->Behaviors.LookupString(args[1])));
return DoubleToACS(GetUDMFFloat(Level, UDMF_Line, LineFromID(args[0]), Level->Behaviors.LookupString(args[1])));

case ACSF_GetThingUDMFInt:
case ACSF_GetThingUDMFFixed:
return 0; // Not implemented yet

case ACSF_GetSectorUDMFInt:
return GetUDMFInt(UDMF_Sector, Level->tagManager.FindFirstSectorFromTag(args[0]), Level->Behaviors.LookupString(args[1]));
return GetUDMFInt(Level, UDMF_Sector, Level->tagManager.FindFirstSectorFromTag(args[0]), Level->Behaviors.LookupString(args[1]));

case ACSF_GetSectorUDMFFixed:
return DoubleToACS(GetUDMFFloat(UDMF_Sector, Level->tagManager.FindFirstSectorFromTag(args[0]), Level->Behaviors.LookupString(args[1])));
return DoubleToACS(GetUDMFFloat(Level, UDMF_Sector, Level->tagManager.FindFirstSectorFromTag(args[0]), Level->Behaviors.LookupString(args[1])));

case ACSF_GetSideUDMFInt:
return GetUDMFInt(UDMF_Side, SideFromID(args[0], args[1]), Level->Behaviors.LookupString(args[2]));
return GetUDMFInt(Level, UDMF_Side, SideFromID(args[0], args[1]), Level->Behaviors.LookupString(args[2]));

case ACSF_GetSideUDMFFixed:
return DoubleToACS(GetUDMFFloat(UDMF_Side, SideFromID(args[0], args[1]), Level->Behaviors.LookupString(args[2])));
return DoubleToACS(GetUDMFFloat(Level, UDMF_Side, SideFromID(args[0], args[1]), Level->Behaviors.LookupString(args[2])));

case ACSF_GetActorVelX:
actor = SingleActorFromTID(args[0], activator);
@@ -73,8 +73,6 @@
#include "p_acs.h"
#include "fragglescript/t_script.h"

void P_ClearUDMFKeys();

extern unsigned int R_OldBlend;

static void P_Shutdown ();
@@ -261,6 +259,11 @@ void FLevelLocals::ClearLevelData()
total_monsters = total_items = total_secrets =
killed_monsters = found_items = found_secrets =
wminfo.maxfrags = 0;

for (int i = 0; i < 4; i++)
{
UDMFKeys[i].Clear();
}

SN_StopAllSequences(this);

@@ -352,7 +355,6 @@ void P_FreeLevelData ()
// [ZZ] delete per-map event handlers
E_Shutdown(true);
R_FreePastViewers();
P_ClearUDMFKeys();

level.ClearLevelData();
}
@@ -160,9 +160,9 @@ void P_LoadTranslator(const char *lumpname);
void P_TranslateLineDef (line_t *ld, maplinedef_t *mld, int lineindexforid = -1);
int P_TranslateSectorSpecial (int);

int GetUDMFInt(int type, int index, FName key);
double GetUDMFFloat(int type, int index, FName key);
FString GetUDMFString(int type, int index, FName key);
int GetUDMFInt(FLevelLocals *Level, int type, int index, FName key);
double GetUDMFFloat(FLevelLocals *Level, int type, int index, FName key);
FString GetUDMFString(FLevelLocals *Level, int type, int index, FName key);

void FixMinisegReferences();
void FixHoles();
@@ -2534,7 +2534,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetAutomapPosition, GetAutomapPositi

static int ZGetUDMFInt(FLevelLocals *self, int type, int index, int key)
{
return GetUDMFInt(type, index, ENamedName(key));
return GetUDMFInt(self,type, index, ENamedName(key));
}

DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetUDMFInt, ZGetUDMFInt)
@@ -2543,12 +2543,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetUDMFInt, ZGetUDMFInt)
PARAM_INT(type);
PARAM_INT(index);
PARAM_NAME(key);
ACTION_RETURN_INT(GetUDMFInt(type, index, key));
ACTION_RETURN_INT(GetUDMFInt(self, type, index, key));
}

static double ZGetUDMFFloat(FLevelLocals *self, int type, int index, int key)
{
return GetUDMFFloat(type, index, ENamedName(key));
return GetUDMFFloat(self, type, index, ENamedName(key));
}

DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetUDMFFloat, ZGetUDMFFloat)
@@ -2557,12 +2557,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetUDMFFloat, ZGetUDMFFloat)
PARAM_INT(type);
PARAM_INT(index);
PARAM_NAME(key);
ACTION_RETURN_FLOAT(GetUDMFFloat(type, index, key));
ACTION_RETURN_FLOAT(GetUDMFFloat(self, type, index, key));
}

static void ZGetUDMFString(FLevelLocals *self, int type, int index, int key, FString *result)
{
*result = GetUDMFString(type, index, ENamedName(key));
*result = GetUDMFString(self, type, index, ENamedName(key));
}

DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetUDMFString, ZGetUDMFString)
@@ -2571,7 +2571,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetUDMFString, ZGetUDMFString)
PARAM_INT(type);
PARAM_INT(index);
PARAM_NAME(key);
ACTION_RETURN_STRING(GetUDMFString(type, index, key));
ACTION_RETURN_STRING(GetUDMFString(self, type, index, key));
}

DEFINE_ACTION_FUNCTION(FLevelLocals, GetChecksum)

0 comments on commit 439c36c

Please sign in to comment.