From 6d4eb7f62d73cd9ea7ea7630b5af3d588a45b5d6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Jul 2014 10:07:37 +0200 Subject: [PATCH 01/15] - changed handling of DF_NO_COOP_WEAPON_SPAWN dmflag so that weapons are not determined by class type but by a newly added flag WEAPONSPAWN, to allow CustomInventory replacements to act like weapons when being spawned. --- src/actor.h | 1 + src/p_mobj.cpp | 2 +- src/thingdef/thingdef_data.cpp | 1 + wadsrc/static/actors/shared/inventory.txt | 6 +++++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/actor.h b/src/actor.h index 0dd20c14f..4c2952639 100644 --- a/src/actor.h +++ b/src/actor.h @@ -340,6 +340,7 @@ enum MF7_NOTELESTOMP = 0x00000002, // cannot telefrag under any circumstances (even when set by MAPINFO) MF7_ALWAYSTELEFRAG = 0x00000004, // will unconditionally be telefragged when in the way. Overrides all other settings. MF7_HANDLENODELAY = 0x00000008, // respect NoDelay state flag + MF7_WEAPONSPAWN = 0x00000010, // subject to DF_NO_COOP_WEAPON_SPAWN dmflag // --- mobj.renderflags --- diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 076d106eb..cdc511d11 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4724,7 +4724,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) // [RH] don't spawn extra weapons in coop if so desired if (multiplayer && !deathmatch && (dmflags & DF_NO_COOP_WEAPON_SPAWN)) { - if (i->IsDescendantOf (RUNTIME_CLASS(AWeapon))) + if (GetDefaultByType(i)->flags7 & MF7_WEAPONSPAWN) { if ((mthing->flags & (MTF_DEATHMATCH|MTF_SINGLE)) == MTF_DEATHMATCH) return NULL; diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index bf0bf2e13..013415cc7 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -240,6 +240,7 @@ static FFlagDef ActorFlags[]= DEFINE_FLAG(MF7, NEVERTARGET, AActor, flags7), DEFINE_FLAG(MF7, NOTELESTOMP, AActor, flags7), DEFINE_FLAG(MF7, ALWAYSTELEFRAG, AActor, flags7), + DEFINE_FLAG(MF7, WEAPONSPAWN, AActor, flags7), // Effect flags DEFINE_FLAG(FX, VISIBILITYPULSE, AActor, effects), diff --git a/wadsrc/static/actors/shared/inventory.txt b/wadsrc/static/actors/shared/inventory.txt index ed113c4df..e293282b8 100644 --- a/wadsrc/static/actors/shared/inventory.txt +++ b/wadsrc/static/actors/shared/inventory.txt @@ -335,6 +335,7 @@ Actor Weapon : Inventory native Weapon.BobSpeed 1.0 Weapon.BobRangeX 1.0 Weapon.BobRangeY 1.0 + +WEAPONSPAWN States { LightDone: @@ -362,4 +363,7 @@ Actor WeaponHolder : Inventory native +INVENTORY.UNDROPPABLE } -Actor WeaponPiece : Inventory native {} +Actor WeaponPiece : Inventory native +{ + +WEAPONSPAWN +} From 993b6c30665f6ef11d5808dd574a824c07b58a63 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Jul 2014 17:13:42 +0200 Subject: [PATCH 02/15] - fixed typo in FraggleScript item class list --- src/fragglescript/t_func.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 32d4909d4..4825fe06b 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -154,7 +154,7 @@ static const char * const ActorNames_init[]= "RocketAmmo", "RocketBox", "Cell", - "CellBox", + "CellPack", "Shell", "ShellBox", "Backpack", From 6af441c4d7509b1e194fbca053338940ed0c2db5 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Tue, 29 Jul 2014 11:06:02 +1200 Subject: [PATCH 03/15] Dup frames shouldn't adapt. Adapting during a dup frame caused jittery network performance (especially when using high dup values). The demoplayback check also didn't need to be there anyway. --- src/d_net.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index 0daf010c6..9ba6eefa0 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -1276,7 +1276,7 @@ void NetUpdate (void) // listen for other packets GetPackets (); - if (!demoplayback) + if (!resendOnly) { // ideally nettics[0] should be 1 - 3 tics above lowtic // if we are consistantly slower, speed up time @@ -1323,7 +1323,7 @@ void NetUpdate (void) } oldnettics = nettics[0]; } - }// !demoplayback + } } From 4c6edd5e58e5b61b601d39a4aec271e1ec2d4747 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 26 Jul 2014 22:58:47 -0500 Subject: [PATCH 04/15] Add script array support to ZDoom --- src/p_acs.cpp | 421 +++++++++++++++++++++++++++++++++++++------------- src/p_acs.h | 79 +++++++++- 2 files changed, 389 insertions(+), 111 deletions(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 87e65cac3..baf573b99 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -122,10 +122,11 @@ FRandom pr_acs ("ACS"); struct CallReturn { - CallReturn(int pc, ScriptFunction *func, FBehavior *module, SDWORD *locals, bool discard, unsigned int runaway) + CallReturn(int pc, ScriptFunction *func, FBehavior *module, SDWORD *locals, ACSLocalArrays *arrays, bool discard, unsigned int runaway) : ReturnFunction(func), ReturnModule(module), ReturnLocals(locals), + ReturnArrays(arrays), ReturnAddress(pc), bDiscardResult(discard), EntryInstrCount(runaway) @@ -134,6 +135,7 @@ struct CallReturn ScriptFunction *ReturnFunction; FBehavior *ReturnModule; SDWORD *ReturnLocals; + ACSLocalArrays *ReturnArrays; int ReturnAddress; int bDiscardResult; unsigned int EntryInstrCount; @@ -1673,6 +1675,26 @@ void FBehavior::SerializeVarSet (FArchive &arc, SDWORD *vars, int max) } } +static int ParseLocalArrayChunk(void *chunk, ACSLocalArrays *arrays, int offset) +{ + unsigned count = (LittleShort(((unsigned *)chunk)[1]) - 2) / 4; + int *sizes = (int *)((BYTE *)chunk + 10); + arrays->Count = count; + if (count > 0) + { + ACSLocalArrayInfo *info = new ACSLocalArrayInfo[count]; + arrays->Info = info; + for (unsigned i = 0; i < count; ++i) + { + info[i].Size = LittleLong(sizes[i]); + info[i].Offset = offset; + offset += info[i].Size; + } + } + // Return the new local variable size, with space for the arrays + return offset; +} + FBehavior::FBehavior (int lumpnum, FileReader * fr, int len) { BYTE *object; @@ -1822,12 +1844,45 @@ FBehavior::FBehavior (int lumpnum, FileReader * fr, int len) { DWORD *chunk; - Functions = FindChunk (MAKE_ID('F','U','N','C')); - if (Functions != NULL) + // Load functions + BYTE *funcs; + Functions = NULL; + funcs = FindChunk (MAKE_ID('F','U','N','C')); + if (funcs != NULL) { - NumFunctions = LittleLong(((DWORD *)Functions)[1]) / 8; - Functions += 8; + NumFunctions = LittleLong(((DWORD *)funcs)[1]) / 8; + funcs += 8; FunctionProfileData = new ACSProfileInfo[NumFunctions]; + Functions = new ScriptFunction[NumFunctions]; + for (i = 0; i < NumFunctions; ++i) + { + ScriptFunctionInFile *funcf = &((ScriptFunctionInFile *)funcs)[i]; + ScriptFunction *funcm = &Functions[i]; + funcm->ArgCount = funcf->ArgCount; + funcm->HasReturnValue = funcf->HasReturnValue; + funcm->ImportNum = funcf->ImportNum; + funcm->LocalCount = funcf->LocalCount; + funcm->Address = funcf->Address; + } + } + + // Load local arrays for functions + if (NumFunctions > 0) + { + for (chunk = (DWORD *)FindChunk(MAKE_ID('F','A','R','Y')); chunk != NULL; chunk = (DWORD *)NextChunk((BYTE *)chunk)) + { + int size = LittleLong(chunk[1]); + if (size >= 6) + { + unsigned int func_num = LittleShort(((WORD *)chunk)[4]); + if (func_num < (unsigned int)NumFunctions) + { + ScriptFunction *func = &Functions[func_num]; + // Unlike scripts, functions do not include their arg count in their local count. + func->LocalCount = ParseLocalArrayChunk(chunk, &func->LocalArrays, func->LocalCount + func->ArgCount) - func->ArgCount; + } + } + } } // Load JUMP points @@ -2135,6 +2190,11 @@ FBehavior::~FBehavior () delete[] ArrayStore; ArrayStore = NULL; } + if (Functions != NULL) + { + delete[] Functions; + Functions = NULL; + } if (FunctionProfileData != NULL) { delete[] FunctionProfileData; @@ -2302,6 +2362,21 @@ void FBehavior::LoadScriptsDirectory () } } + // Load script array sizes. (One chunk per script that uses arrays.) + for (scripts.b = FindChunk(MAKE_ID('S','A','R','Y')); scripts.dw != NULL; scripts.b = NextChunk(scripts.b)) + { + int size = LittleLong(scripts.dw[1]); + if (size >= 6) + { + int script_num = LittleShort(scripts.w[4]); + ScriptPtr *ptr = const_cast(FindScript(script_num)); + if (ptr != NULL) + { + ptr->VarCount = ParseLocalArrayChunk(scripts.b, &ptr->LocalArrays, ptr->VarCount); + } + } + } + // Load script names (if any) scripts.b = FindChunk(MAKE_ID('S','N','A','M')); if (scripts.dw != NULL) @@ -5460,14 +5535,50 @@ inline int getshort (int *&pc) return res; } +static bool CharArrayParms(int &capacity, int &offset, int &a, int *Stack, int &sp, bool ranged) +{ + if (ranged) + { + capacity = STACK(1); + offset = STACK(2); + if (capacity < 1 || offset < 0) + { + sp -= 4; + return false; + } + sp -= 2; + } + else + { + capacity = INT_MAX; + offset = 0; + } + a = STACK(1); + offset += STACK(2); + sp -= 2; + return true; +} + int DLevelScript::RunScript () { DACSThinker *controller = DACSThinker::ActiveThinker; SDWORD *locals = localvars; + ACSLocalArrays noarrays; + ACSLocalArrays *localarrays = &noarrays; ScriptFunction *activeFunction = NULL; FRemapTable *translation = 0; int resultValue = 1; + if (InModuleScriptNumber >= 0) + { + ScriptPtr *ptr = activeBehavior->GetScriptPtr(InModuleScriptNumber); + assert(ptr != NULL); + if (ptr != NULL) + { + localarrays = &ptr->LocalArrays; + } + } + // Hexen truncates all special arguments to bytes (only when using an old MAPINFO and old ACS format const int specialargmask = ((level.flags2 & LEVEL2_HEXENHACK) && activeBehavior->GetFormat() == ACS_Old) ? 255 : ~0; @@ -5832,9 +5943,10 @@ int DLevelScript::RunScript () } sp += i; ::new(&Stack[sp]) CallReturn(activeBehavior->PC2Ofs(pc), activeFunction, - activeBehavior, mylocals, pcd == PCD_CALLDISCARD, runaway); + activeBehavior, mylocals, localarrays, pcd == PCD_CALLDISCARD, runaway); sp += (sizeof(CallReturn) + sizeof(int) - 1) / sizeof(int); pc = module->Ofs2PC (func->Address); + localarrays = &func->LocalArrays; activeFunction = func; activeBehavior = module; fmt = module->GetFormat(); @@ -5868,6 +5980,7 @@ int DLevelScript::RunScript () activeBehavior = ret->ReturnModule; fmt = activeBehavior->GetFormat(); locals = ret->ReturnLocals; + localarrays = ret->ReturnArrays; if (!ret->bDiscardResult) { Stack[sp++] = value; @@ -5966,6 +6079,11 @@ int DLevelScript::RunScript () sp--; break; + case PCD_ASSIGNSCRIPTARRAY: + localarrays->Set(locals, NEXTBYTE, STACK(2), STACK(1)); + sp -= 2; + break; + case PCD_ASSIGNMAPARRAY: activeBehavior->SetArrayVal (*(activeBehavior->MapVars[NEXTBYTE]), STACK(2), STACK(1)); sp -= 2; @@ -5997,6 +6115,10 @@ int DLevelScript::RunScript () PushToStack (ACS_GlobalVars[NEXTBYTE]); break; + case PCD_PUSHSCRIPTARRAY: + STACK(1) = localarrays->Get(locals, NEXTBYTE, STACK(1)); + break; + case PCD_PUSHMAPARRAY: STACK(1) = activeBehavior->GetArrayVal (*(activeBehavior->MapVars[NEXTBYTE]), STACK(1)); break; @@ -6029,6 +6151,14 @@ int DLevelScript::RunScript () sp--; break; + case PCD_ADDSCRIPTARRAY: + { + int a = NEXTBYTE, i = STACK(2); + localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) + STACK(1)); + sp -= 2; + } + break; + case PCD_ADDMAPARRAY: { int a = *(activeBehavior->MapVars[NEXTBYTE]); @@ -6074,6 +6204,14 @@ int DLevelScript::RunScript () sp--; break; + case PCD_SUBSCRIPTARRAY: + { + int a = NEXTBYTE, i = STACK(2); + localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) - STACK(1)); + sp -= 2; + } + break; + case PCD_SUBMAPARRAY: { int a = *(activeBehavior->MapVars[NEXTBYTE]); @@ -6119,6 +6257,14 @@ int DLevelScript::RunScript () sp--; break; + case PCD_MULSCRIPTARRAY: + { + int a = NEXTBYTE, i = STACK(2); + localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) * STACK(1)); + sp -= 2; + } + break; + case PCD_MULMAPARRAY: { int a = *(activeBehavior->MapVars[NEXTBYTE]); @@ -6192,6 +6338,19 @@ int DLevelScript::RunScript () } break; + case PCD_DIVSCRIPTARRAY: + if (STACK(1) == 0) + { + state = SCRIPT_DivideBy0; + } + else + { + int a = NEXTBYTE, i = STACK(2); + localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) / STACK(1)); + sp -= 2; + } + break; + case PCD_DIVMAPARRAY: if (STACK(1) == 0) { @@ -6280,6 +6439,19 @@ int DLevelScript::RunScript () } break; + case PCD_MODSCRIPTARRAY: + if (STACK(1) == 0) + { + state = SCRIPT_ModulusBy0; + } + else + { + int a = NEXTBYTE, i = STACK(2); + localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) % STACK(1)); + sp -= 2; + } + break; + case PCD_MODMAPARRAY: if (STACK(1) == 0) { @@ -6341,6 +6513,14 @@ int DLevelScript::RunScript () sp--; break; + case PCD_ANDSCRIPTARRAY: + { + int a = NEXTBYTE, i = STACK(2); + localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) & STACK(1)); + sp -= 2; + } + break; + case PCD_ANDMAPARRAY: { int a = *(activeBehavior->MapVars[NEXTBYTE]); @@ -6386,6 +6566,14 @@ int DLevelScript::RunScript () sp--; break; + case PCD_EORSCRIPTARRAY: + { + int a = NEXTBYTE, i = STACK(2); + localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) ^ STACK(1)); + sp -= 2; + } + break; + case PCD_EORMAPARRAY: { int a = *(activeBehavior->MapVars[NEXTBYTE]); @@ -6431,6 +6619,14 @@ int DLevelScript::RunScript () sp--; break; + case PCD_ORSCRIPTARRAY: + { + int a = NEXTBYTE, i = STACK(2); + localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) | STACK(1)); + sp -= 2; + } + break; + case PCD_ORMAPARRAY: { int a = *(activeBehavior->MapVars[NEXTBYTE]); @@ -6477,6 +6673,14 @@ int DLevelScript::RunScript () sp--; break; + case PCD_LSSCRIPTARRAY: + { + int a = NEXTBYTE, i = STACK(2); + localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) << STACK(1)); + sp -= 2; + } + break; + case PCD_LSMAPARRAY: { int a = *(activeBehavior->MapVars[NEXTBYTE]); @@ -6522,6 +6726,14 @@ int DLevelScript::RunScript () sp--; break; + case PCD_RSSCRIPTARRAY: + { + int a = NEXTBYTE, i = STACK(2); + localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) >> STACK(1)); + sp -= 2; + } + break; + case PCD_RSMAPARRAY: { int a = *(activeBehavior->MapVars[NEXTBYTE]); @@ -6564,6 +6776,14 @@ int DLevelScript::RunScript () ++ACS_GlobalVars[NEXTBYTE]; break; + case PCD_INCSCRIPTARRAY: + { + int a = NEXTBYTE, i = STACK(1); + localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) + 1); + sp--; + } + break; + case PCD_INCMAPARRAY: { int a = *(activeBehavior->MapVars[NEXTBYTE]); @@ -6605,6 +6825,14 @@ int DLevelScript::RunScript () --ACS_GlobalVars[NEXTBYTE]; break; + case PCD_DECSCRIPTARRAY: + { + int a = NEXTBYTE, i = STACK(1); + localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) - 1); + sp--; + } + break; + case PCD_DECMAPARRAY: { int a = *(activeBehavior->MapVars[NEXTBYTE]); @@ -7031,37 +7259,35 @@ scriptwait: } break; + // Print script character array + case PCD_PRINTSCRIPTCHARARRAY: + case PCD_PRINTSCRIPTCHRANGE: + { + int capacity, offset, a, c; + if (CharArrayParms(capacity, offset, a, Stack, sp, pcd == PCD_PRINTSCRIPTCHRANGE)) + { + while (capacity-- && (c = localarrays->Get(locals, a, offset)) != '\0') + { + work += (char)c; + offset++; + } + } + } + break; + // [JB] Print map character array case PCD_PRINTMAPCHARARRAY: case PCD_PRINTMAPCHRANGE: { - int capacity, offset; - - if (pcd == PCD_PRINTMAPCHRANGE) + int capacity, offset, a, c; + if (CharArrayParms(capacity, offset, a, Stack, sp, pcd == PCD_PRINTMAPCHRANGE)) { - capacity = STACK(1); - offset = STACK(2); - if (capacity < 1 || offset < 0) + while (capacity-- && (c = activeBehavior->GetArrayVal (a, offset)) != '\0') { - sp -= 4; - break; + work += (char)c; + offset++; } - sp -= 2; } - else - { - capacity = 0x7FFFFFFF; - offset = 0; - } - - int a = *(activeBehavior->MapVars[STACK(1)]); - offset += STACK(2); - int c; - while(capacity-- && (c = activeBehavior->GetArrayVal (a, offset)) != '\0') { - work += (char)c; - offset++; - } - sp-= 2; } break; @@ -7069,32 +7295,15 @@ scriptwait: case PCD_PRINTWORLDCHARARRAY: case PCD_PRINTWORLDCHRANGE: { - int capacity, offset; - if (pcd == PCD_PRINTWORLDCHRANGE) + int capacity, offset, a, c; + if (CharArrayParms(capacity, offset, a, Stack, sp, pcd == PCD_PRINTWORLDCHRANGE)) { - capacity = STACK(1); - offset = STACK(2); - if (capacity < 1 || offset < 0) + while (capacity-- && (c = ACS_WorldArrays[a][offset]) != '\0') { - sp -= 4; - break; + work += (char)c; + offset++; } - sp -= 2; } - else - { - capacity = 0x7FFFFFFF; - offset = 0; - } - - int a = STACK(1); - offset += STACK(2); - int c; - while(capacity-- && (c = ACS_WorldArrays[a][offset]) != '\0') { - work += (char)c; - offset++; - } - sp-= 2; } break; @@ -7102,32 +7311,15 @@ scriptwait: case PCD_PRINTGLOBALCHARARRAY: case PCD_PRINTGLOBALCHRANGE: { - int capacity, offset; - if (pcd == PCD_PRINTGLOBALCHRANGE) + int capacity, offset, a, c; + if (CharArrayParms(capacity, offset, a, Stack, sp, pcd == PCD_PRINTGLOBALCHRANGE)) { - capacity = STACK(1); - offset = STACK(2); - if (capacity < 1 || offset < 0) + while (capacity-- && (c = ACS_GlobalArrays[a][offset]) != '\0') { - sp -= 4; - break; + work += (char)c; + offset++; } - sp -= 2; } - else - { - capacity = 0x7FFFFFFF; - offset = 0; - } - - int a = STACK(1); - offset += STACK(2); - int c; - while(capacity-- && (c = ACS_GlobalArrays[a][offset]) != '\0') { - work += (char)c; - offset++; - } - sp-= 2; } break; @@ -8674,6 +8866,7 @@ scriptwait: } break; + case PCD_STRCPYTOSCRIPTCHRANGE: case PCD_STRCPYTOMAPCHRANGE: case PCD_STRCPYTOWORLDCHRANGE: case PCD_STRCPYTOGLOBALCHRANGE: @@ -8704,7 +8897,7 @@ scriptwait: break; } - for (int i = 0;i < STACK(1); i++) + for (int i = 0; i < STACK(1); i++) { if (! (*(lookup++))) { @@ -8715,43 +8908,55 @@ scriptwait: switch (pcd) { - case PCD_STRCPYTOMAPCHRANGE: - { - int a = STACK(5); - if (a < NUM_MAPVARS && a > 0 && - activeBehavior->MapVars[a]) - { - Stack[sp-6] = activeBehavior->CopyStringToArray(*(activeBehavior->MapVars[a]), index, capacity, lookup); - } - } - break; - case PCD_STRCPYTOWORLDCHRANGE: - { - int a = STACK(5); + case PCD_STRCPYTOSCRIPTCHRANGE: + { + int a = STACK(5); - while (capacity-- > 0) - { - ACS_WorldArrays[a][index++] = *lookup; - if (! (*(lookup++))) goto STRCPYTORANGECOMPLETE; // complete with terminating 0 - } - - Stack[sp-6] = !(*lookup); // true/success if only terminating 0 was not copied - } - break; - case PCD_STRCPYTOGLOBALCHRANGE: + while (capacity-- > 0) { - int a = STACK(5); - - while (capacity-- > 0) - { - ACS_GlobalArrays[a][index++] = *lookup; - if (! (*(lookup++))) goto STRCPYTORANGECOMPLETE; // complete with terminating 0 - } - - Stack[sp-6] = !(*lookup); // true/success if only terminating 0 was not copied + localarrays->Set(locals, a, index++, *lookup); + if (! (*(lookup++))) goto STRCPYTORANGECOMPLETE; // complete with terminating 0 } - break; - + + Stack[sp-6] = !(*lookup); // true/success if only terminating 0 was not copied + } + break; + case PCD_STRCPYTOMAPCHRANGE: + { + int a = STACK(5); + if (a < NUM_MAPVARS && a > 0 && + activeBehavior->MapVars[a]) + { + Stack[sp-6] = activeBehavior->CopyStringToArray(*(activeBehavior->MapVars[a]), index, capacity, lookup); + } + } + break; + case PCD_STRCPYTOWORLDCHRANGE: + { + int a = STACK(5); + + while (capacity-- > 0) + { + ACS_WorldArrays[a][index++] = *lookup; + if (! (*(lookup++))) goto STRCPYTORANGECOMPLETE; // complete with terminating 0 + } + + Stack[sp-6] = !(*lookup); // true/success if only terminating 0 was not copied + } + break; + case PCD_STRCPYTOGLOBALCHRANGE: + { + int a = STACK(5); + + while (capacity-- > 0) + { + ACS_GlobalArrays[a][index++] = *lookup; + if (! (*(lookup++))) goto STRCPYTORANGECOMPLETE; // complete with terminating 0 + } + + Stack[sp-6] = !(*lookup); // true/success if only terminating 0 was not copied + } + break; } sp -= 5; } diff --git a/src/p_acs.h b/src/p_acs.h index ec41ab886..02544e367 100644 --- a/src/p_acs.h +++ b/src/p_acs.h @@ -144,6 +144,51 @@ struct ProfileCollector int Index; }; +struct ACSLocalArrayInfo +{ + unsigned int Size; + int Offset; +}; + +struct ACSLocalArrays +{ + unsigned int Count; + ACSLocalArrayInfo *Info; + + ACSLocalArrays() + { + Count = 0; + Info = NULL; + } + ~ACSLocalArrays() + { + if (Info != NULL) + { + delete[] Info; + Info = NULL; + } + } + + // Bounds-checking Set and Get for local arrays + void Set(int *locals, int arraynum, int arrayentry, int value) + { + if ((unsigned int)arraynum < Count && + (unsigned int)arrayentry < Info[arraynum].Size) + { + locals[Info[arraynum].Offset + arrayentry] = value; + } + } + int Get(int *locals, int arraynum, int arrayentry) + { + if ((unsigned int)arraynum < Count && + (unsigned int)arrayentry < Info[arraynum].Size) + { + return locals[Info[arraynum].Offset + arrayentry]; + } + return 0; + } +}; + // The in-memory version struct ScriptPtr { @@ -153,6 +198,7 @@ struct ScriptPtr BYTE ArgCount; WORD VarCount; WORD Flags; + ACSLocalArrays LocalArrays; ACSProfileInfo ProfileData; }; @@ -189,7 +235,7 @@ struct ScriptFlagsPtr WORD Flags; }; -struct ScriptFunction +struct ScriptFunctionInFile { BYTE ArgCount; BYTE LocalCount; @@ -198,6 +244,16 @@ struct ScriptFunction DWORD Address; }; +struct ScriptFunction +{ + BYTE ArgCount; + BYTE HasReturnValue; + BYTE ImportNum; + int LocalCount; + DWORD Address; + ACSLocalArrays LocalArrays; +}; + // Script types enum { @@ -285,7 +341,7 @@ private: BYTE *Chunks; ScriptPtr *Scripts; int NumScripts; - BYTE *Functions; + ScriptFunction *Functions; ACSProfileInfo *FunctionProfileData; int NumFunctions; ArrayInfo *ArrayStore; @@ -694,8 +750,25 @@ public: PCD_SCRIPTWAITNAMED, PCD_TRANSLATIONRANGE3, PCD_GOTOSTACK, + PCD_ASSIGNSCRIPTARRAY, + PCD_PUSHSCRIPTARRAY, + PCD_ADDSCRIPTARRAY, + PCD_SUBSCRIPTARRAY, + PCD_MULSCRIPTARRAY, + PCD_DIVSCRIPTARRAY, +/*370*/ PCD_MODSCRIPTARRAY, + PCD_INCSCRIPTARRAY, + PCD_DECSCRIPTARRAY, + PCD_ANDSCRIPTARRAY, + PCD_EORSCRIPTARRAY, + PCD_ORSCRIPTARRAY, + PCD_LSSCRIPTARRAY, + PCD_RSSCRIPTARRAY, + PCD_PRINTSCRIPTCHARARRAY, + PCD_PRINTSCRIPTCHRANGE, +/*380*/ PCD_STRCPYTOSCRIPTCHRANGE, -/*363*/ PCODE_COMMAND_COUNT +/*381*/ PCODE_COMMAND_COUNT }; // Some constants used by ACS scripts From 7280d278d90eaed2c9f216ce767d9e5202e7f18c Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Mon, 28 Jul 2014 21:03:41 -0500 Subject: [PATCH 05/15] Fix VC2005 warning in F7ZFile::Open --- src/resourcefiles/file_7z.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/resourcefiles/file_7z.cpp b/src/resourcefiles/file_7z.cpp index 72e8d5f0e..21c11ed25 100644 --- a/src/resourcefiles/file_7z.cpp +++ b/src/resourcefiles/file_7z.cpp @@ -289,8 +289,8 @@ bool F7ZFile::Open(bool quiet) continue; } - nameUTF16.Resize(nameLength); - nameASCII.Resize(nameLength); + nameUTF16.Resize((unsigned)nameLength); + nameASCII.Resize((unsigned)nameLength); SzArEx_GetFileNameUtf16(&Archive->DB, i, &nameUTF16[0]); for (size_t c = 0; c < nameLength; ++c) { From cd28ad78a3258a6e54f9139e547741e12579cf55 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Mon, 28 Jul 2014 21:04:30 -0500 Subject: [PATCH 06/15] Used debug GME for debug ZDoom build with VC2005 solution --- zdoom.sln | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zdoom.sln b/zdoom.sln index 988e84d68..11dc1b075 100644 --- a/zdoom.sln +++ b/zdoom.sln @@ -162,8 +162,8 @@ Global {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Release|Win32.Build.0 = Release|Win32 {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Release|x64.ActiveCfg = Release|x64 {A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Release|x64.Build.0 = Release|x64 - {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|Win32.ActiveCfg = Release|Win32 - {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|Win32.Build.0 = Release|Win32 + {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|Win32.ActiveCfg = Debug|Win32 + {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|Win32.Build.0 = Debug|Win32 {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|x64.ActiveCfg = Release|x64 {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|x64.Build.0 = Release|x64 {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Release|Win32.ActiveCfg = Release|Win32 From ea7ba9dba3ed1301e52d4e6f982dc31874827b82 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Mon, 28 Jul 2014 23:15:50 -0500 Subject: [PATCH 07/15] Add per-actor friction - This is multiplied by the sector's friction. - This is intentionally not serialized yet, while awaiting feedback. --- src/actor.h | 1 + src/p_acs.cpp | 7 ++++++- src/p_map.cpp | 8 +++++++- src/p_spec.cpp | 18 ++---------------- src/p_spec.h | 19 +++++++++++++++++++ src/thingdef/thingdef_properties.cpp | 11 +++++++++++ wadsrc/static/actors/actor.txt | 1 + 7 files changed, 47 insertions(+), 18 deletions(-) diff --git a/src/actor.h b/src/actor.h index 4c2952639..783eb5408 100644 --- a/src/actor.h +++ b/src/actor.h @@ -906,6 +906,7 @@ public: fixed_t wallbouncefactor; // The bounce factor for walls can be different. int bouncecount; // Strife's grenades only bounce twice before exploding fixed_t gravity; // [GRB] Gravity factor + fixed_t Friction; int FastChaseStrafeCount; fixed_t pushfactor; int lastpush; diff --git a/src/p_acs.cpp b/src/p_acs.cpp index baf573b99..16e511b23 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -3605,7 +3605,8 @@ enum APROP_MeleeRange = 38, APROP_ViewHeight = 39, APROP_AttackZOffset = 40, - APROP_StencilColor = 41 + APROP_StencilColor = 41, + APROP_Friction = 42, }; // These are needed for ACS's APROP_RenderStyle @@ -3839,6 +3840,9 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value) actor->SetShade(value); break; + case APROP_Friction: + actor->Friction = value; + default: // do nothing. break; @@ -3937,6 +3941,7 @@ int DLevelScript::GetActorProperty (int tid, int property, const SDWORD *stack, case APROP_Species: return GlobalACSStrings.AddString(actor->GetSpecies(), stack, stackdepth); case APROP_NameTag: return GlobalACSStrings.AddString(actor->GetTag(), stack, stackdepth); case APROP_StencilColor:return actor->fillcolor; + case APROP_Friction: return actor->Friction; default: return 0; } diff --git a/src/p_map.cpp b/src/p_map.cpp index 45eb0d95c..db0c09202 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -554,7 +554,13 @@ int P_GetFriction (const AActor *mo, int *frictionfactor) } } } - + + if (mo->Friction != FRACUNIT) + { + friction = clamp(FixedMul(friction, mo->Friction), 0, FRACUNIT); + movefactor = FrictionToMoveFactor(friction); + } + if (frictionfactor) *frictionfactor = movefactor; diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 5068cd575..00ed322c0 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -1990,26 +1990,12 @@ void P_SetSectorFriction (int tag, int amount, bool alterFlag) friction = (0x1EB8*amount)/0x80 + 0xD001; // killough 8/28/98: prevent odd situations - if (friction > FRACUNIT) - friction = FRACUNIT; - if (friction < 0) - friction = 0; + friction = clamp(friction, 0, FRACUNIT); // The following check might seem odd. At the time of movement, // the move distance is multiplied by 'friction/0x10000', so a // higher friction value actually means 'less friction'. - - // [RH] Twiddled these values so that velocity on ice (with - // friction 0xf900) is the same as in Heretic/Hexen. - if (friction >= ORIG_FRICTION) // ice -// movefactor = ((0x10092 - friction)*(0x70))/0x158; - movefactor = ((0x10092 - friction) * 1024) / 4352 + 568; - else - movefactor = ((friction - 0xDB34)*(0xA))/0x80; - - // killough 8/28/98: prevent odd situations - if (movefactor < 32) - movefactor = 32; + movefactor = FrictionToMoveFactor(friction); for (s = -1; (s = P_FindSectorFromTag (tag,s)) >= 0; ) { diff --git a/src/p_spec.h b/src/p_spec.h index 245c699d7..dc0eb3646 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -172,6 +172,25 @@ void P_PlayerOnSpecialFlat (player_t *player, int floorType); void P_SectorDamage(int tag, int amount, FName type, const PClass *protectClass, int flags); void P_SetSectorFriction (int tag, int amount, bool alterFlag); +inline fixed_t FrictionToMoveFactor(fixed_t friction) +{ + fixed_t movefactor; + + // [RH] Twiddled these values so that velocity on ice (with + // friction 0xf900) is the same as in Heretic/Hexen. + if (friction >= ORIG_FRICTION) // ice +// movefactor = ((0x10092 - friction)*(0x70))/0x158; + movefactor = ((0x10092 - friction) * 1024) / 4352 + 568; + else + movefactor = ((friction - 0xDB34)*(0xA))/0x80; + + // killough 8/28/98: prevent odd situations + if (movefactor < 32) + movefactor = 32; + + return movefactor; +} + void P_GiveSecret(AActor *actor, bool printmessage, bool playsound, int sectornum); // diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 81452c7b0..b5fdc8e42 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -1297,6 +1297,17 @@ DEFINE_PROPERTY(gravity, F, Actor) defaults->gravity = i; } +//========================================================================== +// +//========================================================================== +DEFINE_PROPERTY(friction, F, Actor) +{ + PROP_FIXED_PARM(i, 0); + + if (i < 0) I_Error ("Friction must not be negative."); + defaults->Friction = i; +} + //========================================================================== // //========================================================================== diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 1eb00440c..501933f04 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -18,6 +18,7 @@ ACTOR Actor native //: Thinker FloatSpeed 4 FloatBobPhase -1 // randomly initialize by default Gravity 1 + Friction 1 DamageFactor 1.0 PushFactor 0.25 WeaveIndexXY 0 From f3d8edb4d87e2cfbf9f998172929cc82f7cccb41 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 29 Jul 2014 19:45:04 -0500 Subject: [PATCH 08/15] Fixed: No sprites were loaded for Build maps --- src/p_buildmap.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index f2fd7b0bf..a93ba6465 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -687,6 +687,8 @@ static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites, { int count = 0; + memset(mapthings, 0, sizeof(*mapthings)*numsprites); + for (int i = 0; i < numsprites; ++i) { mapthings[count].thingid = 0; @@ -699,6 +701,9 @@ static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites, mapthings[count].flags = MTF_SINGLE|MTF_COOPERATIVE|MTF_DEATHMATCH; mapthings[count].special = 0; mapthings[count].gravity = FRACUNIT; + mapthings[count].RenderStyle = STYLE_Count; + mapthings[count].alpha = -1; + mapthings[count].health = -1; if (xsprites != NULL && sprites[i].lotag == 710) { // Blood ambient sound From 02e7c56c820d464286dbad216a987904c49d1b93 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 29 Jul 2014 20:22:45 -0500 Subject: [PATCH 09/15] Move SpriteFrames.Clear() from R_InitSprites to FTextureManager::Init - Fixed: Blood sprite rotations were overwritten by the Doom sprite rotations. --- src/r_data/sprites.cpp | 2 -- src/textures/texturemanager.cpp | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/r_data/sprites.cpp b/src/r_data/sprites.cpp index c1e59c415..ebf4699da 100644 --- a/src/r_data/sprites.cpp +++ b/src/r_data/sprites.cpp @@ -925,8 +925,6 @@ void R_InitSprites () numskins++; } - SpriteFrames.Clear(); - // [RH] Do some preliminary setup if (skins != NULL) delete [] skins; skins = new FPlayerSkin[numskins]; diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index a79769c3d..b8256bc65 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -964,6 +964,7 @@ void FTextureManager::SortTexturesByType(int start, int end) void FTextureManager::Init() { DeleteAll(); + SpriteFrames.Clear(); // Init Build Tile data if it hasn't been done already if (BuildTileFiles.Size() == 0) CountBuildTiles (); FTexture::InitGrayMap(); From 00854dd09e72cf11dddb1a0042baf02513f1c240 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 29 Jul 2014 20:42:17 -0500 Subject: [PATCH 10/15] Don't reopen the reader for encrypted maps - Fixed: Memory leak when loading Blood maps. --- src/p_setup.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_setup.cpp b/src/p_setup.cpp index a6462f31c..f84862ef0 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -312,7 +312,6 @@ MapData *P_OpenMapData(const char * mapname, bool justcheck) if (map->Encrypted) { // If it's encrypted, then it's a Blood file, presumably a map. - map->MapLumps[0].Reader = map->file = Wads.ReopenLumpNum(lump_name); if (!P_IsBuildMap(map)) { delete map; From d602b272b50ec4b2f25569aaf0d79763aea07dfe Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 29 Jul 2014 20:46:20 -0500 Subject: [PATCH 11/15] Never cache nodes for Build maps --- src/p_glnodes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_glnodes.cpp b/src/p_glnodes.cpp index 899005ffa..15b97b9e6 100644 --- a/src/p_glnodes.cpp +++ b/src/p_glnodes.cpp @@ -1014,7 +1014,7 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime) // Building nodes in debug is much slower so let's cache them only if cachetime is 0 buildtime = 0; #endif - if (gl_cachenodes && buildtime/1000.f >= gl_cachetime) + if (level.maptype != MAPTYPE_BUILD && gl_cachenodes && buildtime/1000.f >= gl_cachetime) { DPrintf("Caching nodes\n"); CreateCachedNodes(map); From 4296e9caa2558bfc27aa5baa2dd1d7b36e8dfb87 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 29 Jul 2014 20:47:01 -0500 Subject: [PATCH 12/15] Fix typo in comment --- src/p_buildmap.cpp | 2 +- src/s_advsound.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index a93ba6465..defaf6970 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -708,7 +708,7 @@ static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites, if (xsprites != NULL && sprites[i].lotag == 710) { // Blood ambient sound mapthings[count].args[0] = xsprites[i].Data3; - // I am totally guessing abount the volume level. 50 seems to be a pretty + // I am totally guessing about the volume level. 50 seems to be a pretty // typical value for Blood's standard maps, so I assume it's 100-based. mapthings[count].args[1] = xsprites[i].Data4; mapthings[count].args[2] = xsprites[i].Data1; diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index c2d567f29..67fc544dc 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -2231,7 +2231,7 @@ void AAmbientSound::BeginPlay () // // AmbientSound :: Activate // -// Starts playing a sound (or does nothing of the sound is already playing). +// Starts playing a sound (or does nothing if the sound is already playing). // //========================================================================== From e0e00c4f8c0f964f01c3ae9f48a3b097581bf882 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 29 Jul 2014 20:56:20 -0500 Subject: [PATCH 13/15] Fixed: None of the Blood ambient sounds were registered correctly --- src/s_advsound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index 67fc544dc..d424be45d 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -1433,7 +1433,7 @@ static void S_AddBloodSFX (int lumpnum) ambient->periodmax = 0; ambient->volume = 1; ambient->attenuation = 1; - ambient->sound = name; + ambient->sound = FSoundID(sfxnum); } } From 449a17c2f4e33f64e1f9f81e1d9d68634085fd19 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 29 Jul 2014 21:09:29 -0500 Subject: [PATCH 14/15] Correctly assign the sample rate for all Blood SFX formats - Blood can do 44100 Hz sounds! --- src/s_advsound.cpp | 19 +++++++++++-------- src/s_sound.cpp | 2 +- src/s_sound.h | 4 ++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index d424be45d..5b2e4e7c1 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -511,8 +511,6 @@ int S_AddSoundLump (const char *logicalname, int lump) newsfx.LimitRange = 256*256; newsfx.bRandomHeader = false; newsfx.bPlayerReserve = false; - newsfx.bForce11025 = false; - newsfx.bForce22050 = false; newsfx.bLoadRAW = false; newsfx.bPlayerCompat = false; newsfx.b16bit = false; @@ -520,6 +518,7 @@ int S_AddSoundLump (const char *logicalname, int lump) newsfx.bSingular = false; newsfx.bTentative = false; newsfx.bPlayerSilent = false; + newsfx.RawRate = 0; newsfx.link = sfxinfo_t::NO_LINK; newsfx.Rolloff.RolloffType = ROLLOFF_Doom; newsfx.Rolloff.MinDistance = 0; @@ -1414,13 +1413,17 @@ static void S_AddBloodSFX (int lumpnum) { const char *name = Wads.GetLumpFullName(lumpnum); sfxnum = S_AddSound(name, rawlump); - if (sfx->Format == 5) - { - S_sfx[sfxnum].bForce22050 = true; + if (sfx->Format < 5 || sfx->Format > 12) + { // [0..4] + invalid formats + S_sfx[sfxnum].RawRate = 11025; } - else // I don't know any other formats for this - { - S_sfx[sfxnum].bForce11025 = true; + else if (sfx->Format < 9) + { // [5..8] + S_sfx[sfxnum].RawRate = 22050; + } + else + { // [9..12] + S_sfx[sfxnum].RawRate = 44100; } S_sfx[sfxnum].bLoadRAW = true; S_sfx[sfxnum].LoopStart = LittleLong(sfx->LoopStart); diff --git a/src/s_sound.cpp b/src/s_sound.cpp index d1c313967..32a245675 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -1334,7 +1334,7 @@ sfxinfo_t *S_LoadSound(sfxinfo_t *sfx) if (sfx->bLoadRAW) { len = Wads.LumpLength (sfx->lumpnum); - frequency = (sfx->bForce22050 ? 22050 : 11025); + frequency = sfx->RawRate; } else { diff --git a/src/s_sound.h b/src/s_sound.h index 346e51ce1..da8bf3cbc 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -49,8 +49,6 @@ struct sfxinfo_t WORD bRandomHeader:1; WORD bPlayerReserve:1; - WORD bForce11025:1; - WORD bForce22050:1; WORD bLoadRAW:1; WORD bPlayerCompat:1; WORD b16bit:1; @@ -59,6 +57,8 @@ struct sfxinfo_t WORD bTentative:1; WORD bPlayerSilent:1; // This player sound is intentionally silent. + WORD RawRate; // Sample rate to use when bLoadRAW is true + int LoopStart; // -1 means no specific loop defined unsigned int link; From a922ae04cca88ad5a46df12784f4965fdb7e24d0 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 29 Jul 2014 21:39:05 -0500 Subject: [PATCH 15/15] Use Blood player starts - Blood's maps use thing types, much like Doom's, so getting its player starts is easy. There's no need to synthesize a start from the editor position like with other Build maps. --- src/p_buildmap.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index defaf6970..63e38c616 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -16,6 +16,7 @@ #include "p_setup.h" #include "g_level.h" #include "r_data/colormaps.h" +#include "gi.h" // MACROS ------------------------------------------------------------------ @@ -361,9 +362,8 @@ static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **mapthings, int * // BUILD info from the map we need. (Sprites are ignored.) LoadSectors (bsec); LoadWalls (bwal, numWalls, bsec); - *mapthings = new FMapThing[numsprites + 1]; - CreateStartSpot ((fixed_t *)infoBlock, *mapthings); - *numspr = 1 + LoadSprites (bspr, xspr, numsprites, bsec, *mapthings + 1); + *mapthings = new FMapThing[numsprites]; + *numspr = LoadSprites (bspr, xspr, numsprites, bsec, *mapthings); delete[] bsec; delete[] bwal; @@ -713,9 +713,19 @@ static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites, mapthings[count].args[1] = xsprites[i].Data4; mapthings[count].args[2] = xsprites[i].Data1; mapthings[count].args[3] = xsprites[i].Data2; - mapthings[count].args[4] = 0; mapthings[count].type = 14065; } + else if (xsprites != NULL && sprites[i].lotag == 1) + { // Blood player start + if (xsprites[i].Data1 < 4) + mapthings[count].type = 1 + xsprites[i].Data1; + else + mapthings[count].type = gameinfo.player5start + xsprites[i].Data1 - 4; + } + else if (xsprites != NULL && sprites[i].lotag == 2) + { // Bloodbath start + mapthings[count].type = 11; + } else { if (sprites[i].cstat & (16|32|32768)) continue;