From 993b6c30665f6ef11d5808dd574a824c07b58a63 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Jul 2014 17:13:42 +0200 Subject: [PATCH 01/54] - 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 02/54] 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 03/54] 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 04/54] 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 05/54] 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 06/54] 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 07/54] 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 08/54] 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 09/54] 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 10/54] 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 11/54] 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 12/54] 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 13/54] 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 14/54] 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; From e55e7b9a38134be754b8b5b6d05477818a646b12 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 31 Jul 2014 18:22:33 -0500 Subject: [PATCH 15/54] Don't weed out wall and floor sprites when spawning Build sprites --- src/p_buildmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index 63e38c616..54bf92527 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -728,7 +728,7 @@ static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites, } else { - if (sprites[i].cstat & (16|32|32768)) continue; + if (sprites[i].cstat & 32768) continue; if (sprites[i].xrepeat == 0 || sprites[i].yrepeat == 0) continue; mapthings[count].type = 9988; From 4cf468452cea77af73cfe137c890192f87172d51 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 31 Jul 2014 19:15:08 -0500 Subject: [PATCH 16/54] Remove slopetype from line_t. - Recomputing it in the only two places where it's used is trivial, so it's basically a waste of space to precompute it. --- src/m_bbox.cpp | 39 ++++++++++++++++++--------------------- src/p_map.cpp | 36 ++++++++++++++++++------------------ src/p_setup.cpp | 7 ------- src/po_man.cpp | 12 ------------ src/r_defs.h | 13 ------------- 5 files changed, 36 insertions(+), 71 deletions(-) diff --git a/src/m_bbox.cpp b/src/m_bbox.cpp index 6d3a5b744..199da8d68 100644 --- a/src/m_bbox.cpp +++ b/src/m_bbox.cpp @@ -54,19 +54,8 @@ int FBoundingBox::BoxOnLineSide (const line_t *ld) const int p1; int p2; - switch (ld->slopetype) - { - case ST_HORIZONTAL: - p1 = m_Box[BOXTOP] > ld->v1->y; - p2 = m_Box[BOXBOTTOM] > ld->v1->y; - if (ld->dx < 0) - { - p1 ^= 1; - p2 ^= 1; - } - break; - - case ST_VERTICAL: + if (ld->dx == 0) + { // ST_VERTICAL p1 = m_Box[BOXRIGHT] < ld->v1->x; p2 = m_Box[BOXLEFT] < ld->v1->x; if (ld->dy < 0) @@ -74,18 +63,26 @@ int FBoundingBox::BoxOnLineSide (const line_t *ld) const p1 ^= 1; p2 ^= 1; } - break; - - case ST_POSITIVE: + } + else if (ld->dy == 0) + { // ST_HORIZONTAL: + p1 = m_Box[BOXTOP] > ld->v1->y; + p2 = m_Box[BOXBOTTOM] > ld->v1->y; + if (ld->dx < 0) + { + p1 ^= 1; + p2 ^= 1; + } + } + else if ((ld->dy ^ ld->dx) >= 0) + { // ST_POSITIVE: p1 = P_PointOnLineSide (m_Box[BOXLEFT], m_Box[BOXTOP], ld); p2 = P_PointOnLineSide (m_Box[BOXRIGHT], m_Box[BOXBOTTOM], ld); - break; - - case ST_NEGATIVE: - default: // Just to assure GCC that p1 and p2 really do get initialized + } + else + { // ST_NEGATIVE: p1 = P_PointOnLineSide (m_Box[BOXRIGHT], m_Box[BOXTOP], ld); p2 = P_PointOnLineSide (m_Box[BOXLEFT], m_Box[BOXBOTTOM], ld); - break; } return (p1 == p2) ? p1 : -1; diff --git a/src/p_map.cpp b/src/p_map.cpp index db0c09202..96b2b6195 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2244,24 +2244,8 @@ void FSlide::HitSlideLine (line_t* ld) slidemo->z <= slidemo->floorz && P_GetFriction (slidemo, NULL) > ORIG_FRICTION; - if (ld->slopetype == ST_HORIZONTAL) - { - if (icyfloor && (abs(tmymove) > abs(tmxmove))) - { - tmxmove /= 2; // absorb half the velocity - tmymove = -tmymove/2; - if (slidemo->player && slidemo->health > 0 && !(slidemo->player->cheats & CF_PREDICTING)) - { - S_Sound (slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff! - } - } - else - tmymove = 0; // no more movement in the Y direction - return; - } - - if (ld->slopetype == ST_VERTICAL) - { + if (ld->dx == 0) + { // ST_VERTICAL if (icyfloor && (abs(tmxmove) > abs(tmymove))) { tmxmove = -tmxmove/2; // absorb half the velocity @@ -2276,6 +2260,22 @@ void FSlide::HitSlideLine (line_t* ld) return; } + if (ld->dy == 0) + { // ST_HORIZONTAL + if (icyfloor && (abs(tmymove) > abs(tmxmove))) + { + tmxmove /= 2; // absorb half the velocity + tmymove = -tmymove/2; + if (slidemo->player && slidemo->health > 0 && !(slidemo->player->cheats & CF_PREDICTING)) + { + S_Sound (slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff! + } + } + else + tmymove = 0; // no more movement in the Y direction + return; + } + // The wall is angled. Bounce if the angle of approach is // phares // less than 45 degrees. // phares diff --git a/src/p_setup.cpp b/src/p_setup.cpp index f84862ef0..a6dbca868 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -1888,13 +1888,6 @@ void P_AdjustLine (line_t *ld) ld->dx = v2->x - v1->x; ld->dy = v2->y - v1->y; - if (ld->dx == 0) - ld->slopetype = ST_VERTICAL; - else if (ld->dy == 0) - ld->slopetype = ST_HORIZONTAL; - else - ld->slopetype = ((ld->dy ^ ld->dx) >= 0) ? ST_POSITIVE : ST_NEGATIVE; - if (v1->x < v2->x) { ld->bbox[BOXLEFT] = v1->x; diff --git a/src/po_man.cpp b/src/po_man.cpp index d844133b0..e19acc53a 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -950,18 +950,6 @@ void FPolyObj::UpdateBBox () // Update the line's slopetype line->dx = line->v2->x - line->v1->x; line->dy = line->v2->y - line->v1->y; - if (!line->dx) - { - line->slopetype = ST_VERTICAL; - } - else if (!line->dy) - { - line->slopetype = ST_HORIZONTAL; - } - else - { - line->slopetype = ((line->dy ^ line->dx) >= 0) ? ST_POSITIVE : ST_NEGATIVE; - } } CalcCenter(); } diff --git a/src/r_defs.h b/src/r_defs.h index 2e9c0876b..dd2136508 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -882,18 +882,6 @@ struct side_t FArchive &operator<< (FArchive &arc, side_t::part &p); -// -// Move clipping aid for LineDefs. -// -enum slopetype_t -{ - ST_HORIZONTAL, - ST_VERTICAL, - ST_POSITIVE, - ST_NEGATIVE -}; - - struct line_t { vertex_t *v1, *v2; // vertices, from v1 to v2 @@ -908,7 +896,6 @@ struct line_t side_t *sidedef[2]; //DWORD sidenum[2]; // sidenum[1] will be NO_SIDE if one sided fixed_t bbox[4]; // bounding box, for the extent of the LineDef. - slopetype_t slopetype; // To aid move clipping. sector_t *frontsector, *backsector; int validcount; // if == validcount, already checked int locknumber; // [Dusk] lock number for special From bbc3b69a7c227e319bbaf24bbccd9350ef4136ed Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 31 Jul 2014 19:43:36 -0500 Subject: [PATCH 17/54] Remove polymost stuff - Maybe it will be back someday, but it's been essentially dead for nearly 10 years, so don't hold your breath. --- src/CMakeLists.txt | 1 - src/d_main.cpp | 24 +- src/r_main.cpp | 29 +- src/r_polymost.cpp | 1599 ------------------------------------------ src/r_polymost.h | 55 -- src/r_swrenderer.cpp | 3 - zdoom.vcproj | 8 - 7 files changed, 3 insertions(+), 1716 deletions(-) delete mode 100644 src/r_polymost.cpp delete mode 100644 src/r_polymost.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1564c9e60..1444f1cf3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -896,7 +896,6 @@ add_executable( zdoom WIN32 r_drawt.cpp r_main.cpp r_plane.cpp - r_polymost.cpp r_segs.cpp r_sky.cpp r_things.cpp diff --git a/src/d_main.cpp b/src/d_main.cpp index 90391433a..ab33bfaec 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -108,10 +108,6 @@ #include "r_renderer.h" #include "p_local.h" -#ifdef USE_POLYMOST -#include "r_polymost.h" -#endif - EXTERN_CVAR(Bool, hud_althud) void DrawHUD(); @@ -186,9 +182,6 @@ CUSTOM_CVAR (Int, fraglimit, 0, CVAR_SERVERINFO) } } -#ifdef USE_POLYMOST -CVAR(Bool, testpolymost, false, 0) -#endif CVAR (Float, timelimit, 0.f, CVAR_SERVERINFO); CVAR (Int, wipetype, 1, CVAR_ARCHIVE); CVAR (Int, snd_drawoutput, 0, 0); @@ -282,10 +275,6 @@ void D_ProcessEvents (void) continue; // console ate the event if (M_Responder (ev)) continue; // menu ate the event - #ifdef USE_POLYMOST - if (testpolymost) - Polymost_Responder (ev); - #endif G_Responder (ev); } } @@ -307,9 +296,6 @@ void D_PostEvent (const event_t *ev) } events[eventhead] = *ev; if (ev->type == EV_Mouse && !paused && menuactive == MENU_Off && ConsoleState != c_down && ConsoleState != c_falling -#ifdef USE_POLYMOST - && !testpolymost -#endif ) { if (Button_Mlook.bDown || freelook) @@ -743,15 +729,7 @@ void D_Display () hw2d = false; -#ifdef USE_POLYMOST - if (testpolymost) - { - drawpolymosttest(); - C_DrawConsole(hw2d); - M_Drawer(); - } - else -#endif + { unsigned int nowtime = I_FPSTime(); TexMan.UpdateAnimations(nowtime); diff --git a/src/r_main.cpp b/src/r_main.cpp index a726bc714..bc3c4c7c0 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -72,8 +72,6 @@ // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- void R_SpanInitData (); -void RP_RenderBSPNode (void *node); -bool RP_SetupFrame (bool backside); void R_DeinitSprites(); // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- @@ -94,14 +92,12 @@ extern "C" int fuzzviewheight; static float CurrentVisibility = 8.f; static fixed_t MaxVisForWall; static fixed_t MaxVisForFloor; -static bool polyclipped; extern bool r_showviewer; bool r_dontmaplines; // PUBLIC DATA DEFINITIONS ------------------------------------------------- CVAR (String, r_viewsize, "", CVAR_NOSET) -CVAR (Int, r_polymost, 0, 0) CVAR (Bool, r_shadercolormaps, true, CVAR_ARCHIVE) fixed_t r_BaseVisibility; @@ -612,14 +608,6 @@ void R_SetupFreelook() } } -void R_SetupPolymost() -{ - if (r_polymost) - { - polyclipped = RP_SetupFrame (false); - } -} - //========================================================================== // // R_EnterMirror @@ -812,11 +800,8 @@ void R_RenderActorView (AActor *actor, bool dontmaplines) } // Link the polyobjects right before drawing the scene to reduce the amounts of calls to this function PO_LinkToSubsectors(); - if (r_polymost < 2) - { - R_RenderBSPNode (nodes + numnodes - 1); // The head node is the last node output. - R_3D_ResetClip(); // reset clips (floor/ceiling) - } + R_RenderBSPNode (nodes + numnodes - 1); // The head node is the last node output. + R_3D_ResetClip(); // reset clips (floor/ceiling) camera->renderflags = savedflags; WallCycles.Unclock(); @@ -843,16 +828,6 @@ void R_RenderActorView (AActor *actor, bool dontmaplines) MaskedCycles.Unclock(); NetUpdate (); - - if (r_polymost) - { - RP_RenderBSPNode (nodes + numnodes - 1); - if (polyclipped) - { - RP_SetupFrame (true); - RP_RenderBSPNode (nodes + numnodes - 1); - } - } } WallMirrors.Clear (); interpolator.RestoreInterpolations (); diff --git a/src/r_polymost.cpp b/src/r_polymost.cpp deleted file mode 100644 index e7963faa2..000000000 --- a/src/r_polymost.cpp +++ /dev/null @@ -1,1599 +0,0 @@ -/************************************************************************************************** -"POLYMOST" code written by Ken Silverman -Ken Silverman's official web site: http://www.advsys.net/ken -This file has been modified (severely) from Ken Silverman's original release - -Motivation: -When 3D Realms released the Duke Nukem 3D source code, I thought somebody would do a OpenGL or -Direct3D port. Well, after a few months passed, I saw no sign of somebody working on a true -hardware-accelerated port of Build, just people saying it wasn't possible. Eventually, I realized -the only way this was going to happen was for me to do it myself. First, I needed to port Build to -Windows. I could have done it myself, but instead I thought I'd ask my Australian buddy, Jonathon -Fowler, if he would upgrade his Windows port to my favorite compiler (MSVC) - which he did. Once -that was done, I was ready to start the "POLYMOST" project. - -About: -This source file is basically a complete rewrite of the entire rendering part of the Build engine. -There are small pieces in ENGINE.C to activate this code, and other minor hacks in other source -files, but most of it is in here. If you're looking for polymost-related code in the other source -files, you should find most of them by searching for either "polymost" or "rendmode". Speaking of -rendmode, there are now 4 rendering modes in Build: - - rendmode 0: The original code I wrote from 1993-1997 - rendmode 1: Solid-color rendering: my debug code before I did texture mapping - rendmode 2: Software rendering before I started the OpenGL code (Note: this is just a quick - hack to make testing easier - it's not optimized to my usual standards!) - rendmode 3: The OpenGL code - -The original Build engine did hidden surface removal by using a vertical span buffer on the tops -and bottoms of walls. This worked nice back in the day, but it it's not suitable for a polygon -engine. So I decided to write a brand new hidden surface removal algorithm - using the same idea -as the original Build - but one that worked with vectors instead of already rasterized data. - -Brief history: -06/20/2000: I release Build Source code -04/01/2003: 3D Realms releases Duke Nukem 3D source code -10/04/2003: Jonathon Fowler gets his Windows port working in Visual C -10/04/2003: I start writing POLYMOST.BAS, a new hidden surface removal algorithm for Build that - works on a polygon level instead of spans. -10/16/2003: Ported POLYMOST.BAS to C inside JonoF KenBuild's ENGINE.C; later this code was split - out of ENGINE.C and put in this file, POLYMOST.C. -12/10/2003: Started OpenGL code for POLYMOST (rendmode 3) -12/23/2003: 1st public release -01/01/2004: 2nd public release: fixed stray lines, status bar, mirrors, sky, and lots of other bugs. - ----------------------------------------------------------------------------------------------------- - -Todo list (in approximate chronological order): - -High priority: - * BOTH: Do accurate software sorting/chopping for sprites: drawing in wrong order is bad :/ - * BOTH: Fix hall of mirrors near "zenith". Call polymost_drawrooms twice? - * OPENGL: drawmapview() - -Low priority: - * SOFT6D: Do back-face culling of sprites during up/down/tilt transformation (top of drawpoly) - * SOFT6D: Fix depth shading: use saturation&LUT - * SOFT6D: Optimize using hyperbolic mapping (similar to KUBE algo) - * SOFT6D: Slab6-style voxel sprites. How to accelerate? :/ - * OPENGL: KENBUILD: Write flipping code for floor mirrors - * BOTH: KENBUILD: Parallaxing sky modes 1&2 - * BOTH: Masked/1-way walls don't clip correctly to sectors of intersecting ceiling/floor slopes - * BOTH: Editart x-center is not working correctly with Duke's camera/turret sprites - * BOTH: Get rid of horizontal line above Duke full-screen status bar - * BOTH: Combine ceilings/floors into a single triangle strip (should lower poly count by 2x) - * BOTH: Optimize/clean up texture-map setup equations - -**************************************************************************************************/ - -#include -#include -#include -#include "doomtype.h" -#include "r_polymost.h" -#include "c_cvars.h" -#include "c_dispatch.h" -#include "r_main.h" -#include "r_draw.h" -#include "templates.h" -#include "r_sky.h" -#include "g_level.h" -#include "r_bsp.h" -#include "v_palette.h" -#include "v_font.h" -#include "v_video.h" -#include "r_data/colormaps.h" - -EXTERN_CVAR (Int, r_polymost) - -#define SCISDIST 1.0 //1.0: Close plane clipping distance - -static double gyxscale, gxyaspect, gviewxrange, ghalfx, grhalfxdown10, grhalfxdown10x, ghoriz; -static double gcosang, gsinang, gcosang2, gsinang2; -static double gchang, gshang, gctang, gstang; -//static float gtang = 0.0; -CVAR (Float, gtang, 0, 0); -double guo, gux, guy; //Screen-based texture mapping parameters -double gvo, gvx, gvy; -double gdo, gdx, gdy; - -#ifdef _MSC_VER -#pragma warning (disable:4244) -#endif - -PolyClipper::PolyClipper () - : vsps (&EmptyList) -{ - UsedList.Next = UsedList.Prev = &UsedList; -} - -PolyClipper::~PolyClipper () -{ - vspgroup *probe = vsps.NextGroup; - while (probe != NULL) - { - vspgroup *next = probe->NextGroup; - delete probe; - probe = next; - } -} - -PolyClipper::vspgroup::vspgroup (vsptype *sentinel) -{ - int i; - - NextGroup = NULL; - vsp[0].Prev = sentinel; - vsp[0].Next = &vsp[1]; - for (i = 1; i < GROUP_SIZE-1; ++i) - { - vsp[i].Next = &vsp[i+1]; - vsp[i].Prev = &vsp[i-1]; - } - vsp[i].Next = sentinel; - vsp[i].Prev = &vsp[i-1]; - sentinel->Next = &vsp[0]; - sentinel->Prev = &vsp[i]; -} - - /*Init viewport boundary (must be 4 point convex loop): - // (px[0],py[0]).----.(px[1],py[1]) - // / \ - // / \ - // (px[3],py[3]).--------------.(px[2],py[2]) - */ -void PolyClipper::InitMosts (double *px, double *py, int n) -{ - int i, j, k, imin; - int vcnt; - vsptype *vsp[8]; - - EmptyAll (); - vcnt = 1; // 0 is dummy solid node - - if (n < 3) return; - imin = (px[1] < px[0]); - for(i=n-1;i>=2;i--) if (px[i] < px[imin]) imin = i; - - vsp[0] = &UsedList; - vsp[vcnt] = GetVsp (); - vsp[vcnt]->X = px[imin]; - vsp[vcnt]->Cy[0] = vsp[vcnt]->Fy[0] = py[imin]; - vsp[vcnt]->CTag = vsp[vcnt]->FTag = 1; - vcnt++; - i = imin+1; if (i >= n) i = 0; - j = imin-1; if (j < 0) j = n-1; - do - { - if (px[i] < px[j]) - { - if ((vcnt > 1) && (px[i] - vsp[vcnt-1]->X < 0.00001)) vcnt--; - else vsp[vcnt] = GetVsp (); - vsp[vcnt]->X = px[i]; - vsp[vcnt]->Cy[0] = py[i]; - k = j+1; if (k >= n) k = 0; - //(px[k],py[k]) - //(px[i],?) - //(px[j],py[j]) - vsp[vcnt]->Fy[0] = (px[i]-px[k])*(py[j]-py[k])/(px[j]-px[k]) + py[k]; - if (vcnt > 1) - { - vsp[vcnt]->CTag = vsp[vcnt-1]->CTag + 1; - vsp[vcnt]->FTag = vsp[vcnt-1]->FTag; - } - vcnt++; - i++; if (i >= n) i = 0; - } - else if (px[j] < px[i]) - { - if ((vcnt > 1) && (px[j] - vsp[vcnt-1]->X < 0.00001)) vcnt--; - else vsp[vcnt] = GetVsp (); - vsp[vcnt]->X = px[j]; - vsp[vcnt]->Fy[0] = py[j]; - k = i-1; if (k < 0) k = n-1; - //(px[k],py[k]) - //(px[j],?) - //(px[i],py[i]) - vsp[vcnt]->Cy[0] = (px[j]-px[k])*(py[i]-py[k])/(px[i]-px[k]) + py[k]; - if (vcnt > 1) - { - vsp[vcnt]->FTag = vsp[vcnt-1]->FTag + 1; - vsp[vcnt]->CTag = vsp[vcnt-1]->CTag; - } - vcnt++; - j--; if (j < 0) j = n-1; - } - else - { - if ((vcnt > 1) && (px[i] - vsp[vcnt-1]->X < 0.00001)) vcnt--; - else vsp[vcnt] = GetVsp (); - vsp[vcnt]->X = px[i]; - vsp[vcnt]->Cy[0] = py[i]; - vsp[vcnt]->Fy[0] = py[j]; - if (vcnt > 1) - { - vsp[vcnt]->CTag = vsp[vcnt-1]->CTag + 1; - vsp[vcnt]->FTag = vsp[vcnt-1]->FTag + 1; - } - vcnt++; - i++; if (i >= n) i = 0; if (i == j) break; - j--; if (j < 0) j = n-1; - } - } while (i != j); - if (px[i] > vsp[vcnt-1]->X) - { - vsp[vcnt] = GetVsp (); - vsp[vcnt]->X = px[i]; - vsp[vcnt]->Cy[0] = vsp[vcnt]->Fy[0] = py[i]; - vsp[vcnt]->CTag = vsp[vcnt-1]->CTag + 1; - vsp[vcnt]->FTag = vsp[vcnt-1]->FTag + 1; - vcnt++; - } - - assert (vcnt < 8); - - vsp[vcnt-1]->CTag = vsp[vcnt-1]->FTag = vcnt-1; - for(i=0;iCy[1] = vsp[i+1]->Cy[0]; //vsp[i]->CTag = i; - vsp[i]->Fy[1] = vsp[i+1]->Fy[0]; //vsp[i]->FTag = i; - vsp[i]->Next = vsp[i+1]; vsp[i]->Prev = vsp[i-1]; - } - vsp[vcnt-1]->Next = &UsedList; UsedList.Prev = vsp[vcnt-1]; - GTag = vcnt; -} - -void PolyClipper::EmptyAll () -{ - if (UsedList.Next != &UsedList) - { - if (EmptyList.Next != &EmptyList) - { - // Move the used list to the start of the empty list - UsedList.Prev->Next = EmptyList.Next; - EmptyList.Next = UsedList.Next; - UsedList.Next->Prev = &EmptyList; - } - else - { - // The empty list is empty, so we can just move the - // used list to the empty list. - EmptyList.Next = UsedList.Next; - EmptyList.Prev = UsedList.Prev; - } - UsedList.Next = UsedList.Prev = &UsedList; - } -} - -void PolyClipper::AddGroup () -{ - vspgroup *group = new vspgroup (&EmptyList); - group->NextGroup = vsps.NextGroup; - vsps.NextGroup = group; -} - -PolyClipper::vsptype *PolyClipper::GetVsp () -{ - vsptype *vsp; - - if (EmptyList.Next == &EmptyList) - { - AddGroup (); - } - vsp = EmptyList.Next; - EmptyList.Next = vsp->Next; - vsp->Next->Prev = &EmptyList; - return vsp; -} - -void PolyClipper::FreeVsp (vsptype *vsp) -{ - vsp->Next->Prev = vsp->Prev; - vsp->Prev->Next = vsp->Next; - - vsp->Next = EmptyList.Next; - vsp->Next->Prev = vsp; - vsp->Prev = &EmptyList; - EmptyList.Next = vsp; -} - -PolyClipper::vsptype *PolyClipper::vsinsaft (vsptype *i) -{ - vsptype *r; - - // Get an element from the empty list - r = GetVsp (); - - *r = *i; // Copy i to r - - // Insert r after i - r->Prev = i; - r->Next = i->Next; - i->Next->Prev = r; - i->Next = r; - - return r; -} - -bool PolyClipper::TestVisibleMost (float x0, float x1) -{ - vsptype *i, *newi; - - for (i = UsedList.Next; i != &UsedList; i = newi) - { - newi = i->Next; - if ((x0 < newi->X) && (i->X < x1) && (i->CTag >= 0)) return true; - } - return false; -} - -int PolyClipper::DoMost (float x0, float y0, float x1, float y1, pmostcallbacktype callback, void *callbackdata) -{ - double dpx[4], dpy[4]; - float f, slop, dx0, dx1, nx, nx0, ny0, nx1, ny1; - double dx, d, n, t; - float spx[4], spy[4], cy[2], cv[2]; - int j, k, z, scnt, dir, spt[4]; - vsptype *vsp, *nvsp, *vcnt = NULL, *ni; - int did = 1; - - if (x0 < x1) - { - dir = 1; //clip dmost (floor) - y0 -= .01f; y1 -= .01f; - } - else - { - if (x0 == x1) return 0; - f = x0; x0 = x1; x1 = f; - f = y0; y0 = y1; y1 = f; - dir = 0; //clip umost (ceiling) - //y0 += .01f; y1 += .01f; //necessary? - } - - slop = (y1-y0)/(x1-x0); - for (vsp = UsedList.Next; vsp != &UsedList; vsp = nvsp) - { - nvsp = vsp->Next; nx0 = vsp->X; nx1 = nvsp->X; - if ((x0 >= nx1) || (nx0 >= x1) || (vsp->CTag <= 0)) continue; - dx = nx1-nx0; - cy[0] = vsp->Cy[0]; cv[0] = vsp->Cy[1]-cy[0]; - cy[1] = vsp->Fy[0]; cv[1] = vsp->Fy[1]-cy[1]; - - scnt = 0; - - //Test if left edge requires split (x0,y0) (nx0,cy(0)), - if ((x0 > nx0) && (x0 < nx1)) - { - t = (x0-nx0)*cv[dir] - (y0-cy[dir])*dx; - if (((!dir) && (t < 0)) || ((dir) && (t > 0))) - { spx[scnt] = x0; spy[scnt] = y0; spt[scnt] = -1; scnt++; } - } - - //Test for intersection on umost (j == 0) and dmost (j == 1) - for(j=0;j<2;j++) - { - d = (y0-y1)*dx - (x0-x1)*cv[j]; - n = (y0-cy[j])*dx - (x0-nx0)*cv[j]; - if ((fabsf(n) <= fabsf(d)) && (d*n >= 0) && (d != 0)) - { - t = n/d; nx = (x1-x0)*t + x0; - if ((nx > nx0) && (nx < nx1)) - { - spx[scnt] = nx; spy[scnt] = (y1-y0)*t + y0; - spt[scnt] = j; scnt++; - } - } - } - - //Nice hack to avoid full sort later :) - if ((scnt >= 2) && (spx[scnt-1] < spx[scnt-2])) - { - f = spx[scnt-1]; spx[scnt-1] = spx[scnt-2]; spx[scnt-2] = f; - f = spy[scnt-1]; spy[scnt-1] = spy[scnt-2]; spy[scnt-2] = f; - j = spt[scnt-1]; spt[scnt-1] = spt[scnt-2]; spt[scnt-2] = j; - } - - //Test if right edge requires split - if ((x1 > nx0) && (x1 < nx1)) - { - t = (x1-nx0)*cv[dir] - (y1-cy[dir])*dx; - if (((!dir) && (t < 0)) || ((dir) && (t > 0))) - { spx[scnt] = x1; spy[scnt] = y1; spt[scnt] = -1; scnt++; } - } - - vsp->Tag = nvsp->Tag = -1; - for(z = 0; z <= scnt; z++, vsp = vcnt) - { - if (z < scnt) - { - vcnt = vsinsaft(vsp); - t = (spx[z]-nx0)/dx; - vsp->Cy[1] = t*cv[0] + cy[0]; - vsp->Fy[1] = t*cv[1] + cy[1]; - vcnt->X = spx[z]; - vcnt->Cy[0] = vsp->Cy[1]; - vcnt->Fy[0] = vsp->Fy[1]; - vcnt->Tag = spt[z]; - } - - ni = vsp->Next; if (ni == &UsedList) continue; //this 'if' fixes many bugs! - dx0 = vsp->X; if (x0 > dx0) continue; - dx1 = ni->X; if (x1 < dx1) continue; - ny0 = (dx0-x0)*slop + y0; - ny1 = (dx1-x0)*slop + y0; - - // dx0 dx1 - // ³ ³ - //---------------------------- - // t0+=0 t1+=0 - // vsp[i].cy[0] vsp[i].cy[1] - //============================ - // t0+=1 t1+=3 - //============================ - // vsp[i].fy[0] vsp[i].fy[1] - // t0+=2 t1+=6 - // - // ny0 ? ny1 ? - - k = 1+3; - if ((vsp->Tag == 0) || (ny0 <= vsp->Cy[0]+.01)) k--; - if ((vsp->Tag == 1) || (ny0 >= vsp->Fy[0]-.01)) k++; - if ((ni->Tag == 0) || (ny1 <= vsp->Cy[1]+.01)) k -= 3; - if ((ni->Tag == 1) || (ny1 >= vsp->Fy[1]-.01)) k += 3; - - if (!dir) - { - switch(k) - { - case 1: case 2: - dpx[0] = dx0; dpy[0] = vsp->Cy[0]; - dpx[1] = dx1; dpy[1] = vsp->Cy[1]; - dpx[2] = dx0; dpy[2] = ny0; - if(callback) callback(dpx,dpy,3,callbackdata); - vsp->Cy[0] = ny0; vsp->CTag = GTag; break; - case 3: case 6: - dpx[0] = dx0; dpy[0] = vsp->Cy[0]; - dpx[1] = dx1; dpy[1] = vsp->Cy[1]; - dpx[2] = dx1; dpy[2] = ny1; - if(callback) callback(dpx,dpy,3,callbackdata); - vsp->Cy[1] = ny1; vsp->CTag = GTag; break; - case 4: case 5: case 7: - dpx[0] = dx0; dpy[0] = vsp->Cy[0]; - dpx[1] = dx1; dpy[1] = vsp->Cy[1]; - dpx[2] = dx1; dpy[2] = ny1; - dpx[3] = dx0; dpy[3] = ny0; - if(callback) callback(dpx,dpy,4,callbackdata); - vsp->Cy[0] = ny0; vsp->Cy[1] = ny1; vsp->CTag = GTag; break; - case 8: - dpx[0] = dx0; dpy[0] = vsp->Cy[0]; - dpx[1] = dx1; dpy[1] = vsp->Cy[1]; - dpx[2] = dx1; dpy[2] = vsp->Fy[1]; - dpx[3] = dx0; dpy[3] = vsp->Fy[0]; - if(callback) callback(dpx,dpy,4,callbackdata); - vsp->CTag = vsp->FTag = -1; break; - default: did = 0; break; - } - } - else - { - switch(k) - { - case 7: case 6: - dpx[0] = dx0; dpy[0] = ny0; - dpx[1] = dx1; dpy[1] = vsp->Fy[1]; - dpx[2] = dx0; dpy[2] = vsp->Fy[0]; - if(callback) callback(dpx,dpy,3,callbackdata); - vsp->Fy[0] = ny0; vsp->FTag = GTag; break; - case 5: case 2: - dpx[0] = dx0; dpy[0] = vsp->Fy[0]; - dpx[1] = dx1; dpy[1] = ny1; - dpx[2] = dx1; dpy[2] = vsp->Fy[1]; - if(callback) callback(dpx,dpy,3,callbackdata); - vsp->Fy[1] = ny1; vsp->FTag = GTag; break; - case 4: case 3: case 1: - dpx[0] = dx0; dpy[0] = ny0; - dpx[1] = dx1; dpy[1] = ny1; - dpx[2] = dx1; dpy[2] = vsp->Fy[1]; - dpx[3] = dx0; dpy[3] = vsp->Fy[0]; - if(callback) callback(dpx,dpy,4,callbackdata); - vsp->Fy[0] = ny0; vsp->Fy[1] = ny1; vsp->FTag = GTag; break; - case 0: - dpx[0] = dx0; dpy[0] = vsp->Cy[0]; - dpx[1] = dx1; dpy[1] = vsp->Cy[1]; - dpx[2] = dx1; dpy[2] = vsp->Fy[1]; - dpx[3] = dx0; dpy[3] = vsp->Fy[0]; - if(callback) callback(dpx,dpy,4,callbackdata); - vsp->CTag = vsp->FTag = -1; break; - default: did = 0; break; - } - } - } - } - - GTag++; - - //Combine neighboring vertical strips with matching collinear top&bottom edges - //This prevents x-splits from propagating through the entire scan - vsp = UsedList.Next; - while (vsp->Next != &UsedList) - { - ni = vsp->Next; - if ((vsp->Cy[0] >= vsp->Fy[0]) && (vsp->Cy[1] >= vsp->Fy[1])) - { vsp->CTag = vsp->FTag = -1; } - if ((vsp->CTag == ni->CTag) && (vsp->FTag == ni->FTag)) - { vsp->Cy[1] = ni->Cy[1]; vsp->Fy[1] = ni->Fy[1]; FreeVsp (ni); } - else vsp = ni; - } - return did; -} - -#include "d_event.h" -static int pmx, pmy; -static int pt, px0, py0, px1, py1; -static struct polypt { float x, y; } polypts[80]; -static BYTE polysize[32]; -static int numpoly, polypt; -PolyClipper TestPoly; - -void drawline2d (float x1, float y1, float x2, float y2, BYTE col) -{ - float dx, dy, fxresm1, fyresm1, f; - long i, x, y, xi, yi, xup16, yup16; - - //Always draw lines in same direction - if ((y2 > y1) || ((y2 == y1) && (x2 > x1))) { f = x1; x1 = x2; x2 = f; f = y1; y1 = y2; y2 = f; } - - dx = x2-x1; dy = y2-y1; if ((dx == 0) && (dy == 0)) return; - fxresm1 = (float)RenderTarget->GetWidth()-.5; fyresm1 = (float)RenderTarget->GetHeight()-.5; - if (x1 >= fxresm1) { if (x2 >= fxresm1) return; y1 += (fxresm1-x1)*dy/dx; x1 = fxresm1; } - else if (x1 < 0) { if (x2 < 0) return; y1 += ( 0-x1)*dy/dx; x1 = 0; } - if (x2 >= fxresm1) { y2 += (fxresm1-x2)*dy/dx; x2 = fxresm1; } - else if (x2 < 0) { y2 += ( 0-x2)*dy/dx; x2 = 0; } - if (y1 >= fyresm1) { if (y2 >= fyresm1) return; x1 += (fyresm1-y1)*dx/dy; y1 = fyresm1; } - else if (y1 < 0) { if (y2 < 0) return; x1 += ( 0-y1)*dx/dy; y1 = 0; } - if (y2 >= fyresm1) { x2 += (fyresm1-y2)*dx/dy; y2 = fyresm1; } - else if (y2 < 0) { x2 += ( 0-y2)*dx/dy; y2 = 0; } - - dx = x2-x1; dy = y2-y1; - i = (long)(MAX(fabsf(dx)+1,fabsf(dy)+1)); f = 65536.f/((float)i); - x = (long)(x1*65536.f)+32768; xi = (long)(dx*f); xup16 = (RenderTarget->GetWidth()<<16); - y = (long)(y1*65536.f)+32768; yi = (long)(dy*f); yup16 = (RenderTarget->GetHeight()<<16); - do - { - if (((unsigned long)x < (unsigned long)xup16) && ((unsigned long)y < (unsigned long)yup16)) - *(ylookup[y>>16]+(x>>16)+dc_destorg) = col; - x += xi; y += yi; i--; - } while (i >= 0); -} - -static int maskhack; - -void fillconvpoly (float x[], float y[], int n, int col, int bcol) -{ - int mini = y[0] >= y[1], maxi = 1 - mini; - int i, j, y2, oz, z, yy, zz, ncol; - float area, xi, xx; - static int lastx[MAXHEIGHT+2]; - - for (z = 2; z < n; ++z) - { - if (y[z] < y[mini]) mini = z; - if (y[z] > y[maxi]) maxi = z; - } - - area = 0; zz = n - 1; - for (z = 0; z < n; ++z) - { - area += (x[zz] - x[z]) * (y[z] + y[zz]); zz = z; - } - if (area <= 0) return; - - i = maxi; y2 = int(y[i]); - do - { - j = i + 1; if (j == n) j = 0; - yy = int(ceilf(y[j])); - if (yy < 0) yy = 0; - if (yy < y2) - { - xi = (x[j] - x[i]) / (y[j] - y[i]); - xx = (y2 - y[j]) * xi + x[j]; - if (y2 >= RenderTarget->GetHeight()) { xx = xx - (y2 - RenderTarget->GetHeight() + 1)*xi; y2 = RenderTarget->GetHeight()-1; } - for (; y2 >= yy; --y2) - { - lastx[y2] = MAX (0, int(ceilf(xx))); xx = xx - xi; - } - } - i = j; - } while (i != mini); - if (y2 == yy) lastx[yy] = lastx[yy+1]; - do - { - j = i + 1; if (j == n) j = 0; - y2 = int(y[j]); - if (y2 >= RenderTarget->GetHeight()) y2 = RenderTarget->GetHeight()-1; - if (y2 > yy) - { - xi = (x[j] - x[i]) / (y[j] - y[i]); - xx = (yy - y[i]) * xi + x[i]; - if (yy < 0) { xx = xx - xi*yy; yy = 0; } - ncol = col; if (yy & 1) ncol = ncol ^ maskhack; - for (; yy <= y2; ++yy) - { - //drawline2d(lastx[yy], yy, int(ceilf(xx)), yy, ncol); xx = xx + xi; - int xxx = MIN(RenderTarget->GetWidth(), int(ceilf(xx))); - if (yy < RenderTarget->GetHeight() && lastx[yy] < xxx) memset(RenderTarget->GetBuffer()+yy*RenderTarget->GetPitch()+lastx[yy], ncol, xxx-lastx[yy]); - xx = xx + xi; - ncol = ncol ^ maskhack; - } - } - i = j; - } while (i != maxi); - - if (col != bcol) - { - oz = n - 1; - for (z = 0; z < n; ++z) - { - drawline2d(x[oz], y[oz], x[z], y[z], bcol); - oz = z; - } - } -} - -void drawtri(float x0, float y0, float x1, float y1, float x2, float y2, int col, int bcol) -{ - float x[3], y[3]; - x[0] = x0; y[0] = y0; - x[1] = x1; y[1] = y1; - x[2] = x2; y[2] = y2; - fillconvpoly(x, y, 3, col, bcol); -} - -void drawquad(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, int col, int bcol) -{ - float x[4], y[4]; - x[0] = x0; y[0] = y0; - x[1] = x1; y[1] = y1; - x[2] = x2; y[2] = y2; - x[3] = x3; y[3] = y3; - fillconvpoly(x, y, 4, col, bcol); // 2 triangles - if (col != bcol) - { - if (fabsf(y0-y2) < fabsf(y1-y3)) - drawline2d(x0,y0,x2,y2,bcol); - else - drawline2d(x1,y1,x3,y3,bcol); - } -} - -void printnum(int x, int y, int num) -{ - char foo[16]; mysnprintf (foo, countof(foo), "%d", num); - RenderTarget->DrawText (SmallFont, CR_WHITE, x, y, foo, TAG_DONE); -} - -void drawpolymosttest() -{ - float cx0 = 0, cy0 = 0, fx0 = 0, fy0 = 0; - int ccol, fcol; - PolyClipper::vsptype *vsp, *ovsp = &TestPoly.UsedList, *nvsp; - - fcol = 0; ccol = 0; - - RenderTarget->Clear(0, 0, RenderTarget->GetWidth(), RenderTarget->GetHeight(), 0, 0); - for (vsp = ovsp->Next; vsp->Next != &TestPoly.UsedList; ovsp = vsp, vsp = nvsp) - { - nvsp = vsp->Next; - if (vsp->CTag == -1 && vsp->FTag == -1) - { // Hide spans that have been clipped away - vsp->Cy[0] = vsp->Cy[1] = vsp->Fy[0] = vsp->Fy[1] = RenderTarget->GetHeight()/2; - } - - if (vsp->CTag != ovsp->CTag) cx0 = vsp->X, cy0 = vsp->Cy[0]; - if (vsp->CTag != nvsp->CTag) - { // fill the ceiling region - maskhack = 0x18; - drawquad(cx0, 0, nvsp->X, 0, nvsp->X, vsp->Cy[1], cx0, cy0, ccol, ccol); - maskhack = 0; ccol ^= 0x18; - printnum(int(cx0 + nvsp->X) / 2, 2, vsp->CTag); - } - - if(vsp->FTag != ovsp->FTag) fx0 = vsp->X, fy0 = vsp->Fy[0]; - if(vsp->FTag != nvsp->FTag) - { // fill the floor region - maskhack = 0x78; - drawquad(fx0, fy0+1, nvsp->X, vsp->Fy[1]+1, nvsp->X, RenderTarget->GetHeight(), fx0, RenderTarget->GetHeight(), fcol, fcol); - maskhack = 0; fcol ^= 0x78; - printnum(int(fx0 + nvsp->X) / 2, RenderTarget->GetHeight()-10, vsp->FTag); - } - - // fill the unclipped middle region - drawquad(vsp->X, vsp->Cy[0], nvsp->X, vsp->Cy[1], nvsp->X, vsp->Fy[1], vsp->X, vsp->Fy[0], 0xC4, 0xE6); - } - - int x = (pmx + 3) & ~7, y = (pmy + 3) & ~7; - - drawline2d (x - 3, y, x + 3, y, 30); - drawline2d (x, y - 3, x, y + 3, 30); - printnum ( 0, 20, x); - printnum (50, 20, y); - - if (pt > 0 && px0 != px1) - { - if (px0 < px1) - { - drawline2d (px0, py0, px0, RenderTarget->GetHeight()-1, 47); - drawline2d (px1, py1, px1, RenderTarget->GetHeight()-1, 47); - } - else - { - drawline2d (px0, py0, px0, 0, 47); - drawline2d (px1, py1, px1, 0, 47); - } - drawline2d (px0, py0, px1, py1, 47); - } - if (pt == 2) - { - int i = 0; - for (x = 0; x < numpoly; ++x) - { - if (polysize[x] == 3) - { - drawtri (polypts[i ].x, polypts[i ].y, - polypts[i+1].x, polypts[i+1].y, - polypts[i+2].x, polypts[i+2].y, 0x7f, 0x9f); - i += 3; - } - else - { - drawquad (polypts[i ].x, polypts[i ].y, - polypts[i+1].x, polypts[i+1].y, - polypts[i+2].x, polypts[i+2].y, - polypts[i+3].x, polypts[i+3].y, 0x7f, 0x9f); - i += 4; - } - } - } -} - -CCMD(initpolymosttest) -{ - double px[4], py[4]; - int test = 0; - - if (argv.argc() > 1) - test = atoi(argv[1]); - - // Box - px[0] = px[3] = 0; - px[1] = px[2] = screen->GetWidth(); - py[0] = py[1] = screen->GetHeight()/4; - py[2] = py[3] = screen->GetHeight()*3/4; - - switch (test) - { - case 1: // Shorter top edge - px[0] = px[1]/6; - px[1] = px[1]*5/6; - break; - - case 2: // Shorter bottom edge - px[3] = px[2]/6; - px[2] = px[2]*5/6; - break; - - case 3: // Shorter left edge - py[0] = screen->GetHeight()*3/8; - py[3] = screen->GetHeight()*5/8; - break; - - case 4: // Shorter right edge - py[1] = screen->GetHeight()*3/8; - py[2] = screen->GetHeight()*5/8; - break; - - case 5: - px[0] = -1.0048981460288360/2+50; py[0] = -1.0/2+50; - px[1] = 643.00492866407262/2+50; py[1] = -1.0/2+50; - px[2] = 643.00492866407262/2+50; py[2] = 483/2+50; - px[3] = -1.0048981460288360/2+50; py[3] = 483/2+50; - break; - } - TestPoly.InitMosts (px, py, 4); - pmx = screen->GetWidth()/2; - pmy = screen->GetHeight()/2; - pt = 0; -} - -static void testpolycallback (double *dpx, double *dpy, int n, void *foo) -{ - if (numpoly == sizeof(polysize)) return; - if (size_t(polypt + n) > countof(polypts)) return; - polysize[numpoly++] = n; - for (int i = 0; i < n; ++i) - { - polypts[polypt + i].x = dpx[i]; - polypts[polypt + i].y = dpy[i]; - } - polypt += n; -} - -void Polymost_Responder (event_t *ev) -{ - if (ev->type == EV_Mouse && pt < 2) - { - pmx = clamp (pmx + ev->x, 0, screen->GetWidth()-1); - pmy = clamp (pmy - ev->y, 0, screen->GetHeight()-1); - int x = (pmx + 3) & ~7, y = (pmy + 3) & ~7; - if (pt == 0) px0 = x, py0 = y; - if (pt <= 1) px1 = x, py1 = y; - } - else if (ev->type == EV_KeyDown && ev->data1 == KEY_MOUSE1) - { - if (pt == 0) pt = 1; else pt = 0; - } - else if (ev->type == EV_KeyUp && ev->data1 == KEY_MOUSE1) - { - if (pt == 1) { if (px0 != px1) pt++; else pt--; } - if (pt == 2) - { - numpoly = polypt = 0; - TestPoly.DoMost (px0, py0, px1, py1, testpolycallback, NULL); - } - } -} - - - - - - - - -extern fixed_t WallSZ1, WallSZ2, WallTX1, WallTX2, WallTY1, WallTY2, WallCX1, WallCX2, WallCY1, WallCY2; -extern int WallSX1, WallSX2; -extern float WallUoverZorg, WallUoverZstep, WallInvZorg, WallInvZstep, WallDepthScale, WallDepthOrg; -extern fixed_t rw_backcz1, rw_backcz2; -extern fixed_t rw_backfz1, rw_backfz2; -extern fixed_t rw_frontcz1, rw_frontcz2; -extern fixed_t rw_frontfz1, rw_frontfz2; -extern fixed_t rw_offset; -extern bool rw_markmirror; -extern bool rw_havehigh; -extern bool rw_havelow; -extern bool markfloor; -extern bool markceiling; -extern FTexture *toptexture; -extern FTexture *bottomtexture; -extern FTexture *midtexture; -extern bool rw_mustmarkfloor, rw_mustmarkceiling; -extern void R_NewWall(bool); -//extern void R_GetExtraLight (int *light, const secplane_t &plane, FExtraLight *el); -extern int doorclosed; -extern int viewpitch; -#include "p_lnspec.h" - -PolyClipper Mosts; -static bool drawback; - -bool RP_SetupFrame (bool backside) -{ - double ox, oy, oz, ox2, oy2, oz2, r, px[6], py[6], pz[6], px2[6], py2[6], pz2[6], sx[6], sy[6]; - int i, j, n, n2; - - drawback = backside; - if (backside) - { - viewangle += ANGLE_180; - viewsin = finesine[viewangle>>ANGLETOFINESHIFT]; - viewcos = finecosine[viewangle>>ANGLETOFINESHIFT]; - viewtansin = FixedMul (FocalTangent, viewsin); - viewtancos = FixedMul (FocalTangent, viewcos); - } - //Polymost supports true look up/down :) Here, we convert horizon to angle. - //gchang&gshang are cos&sin of this angle (respectively) -// gyxscale = ((double)xdimenscale)/131072.0; - gyxscale = double(InvZtoScale)/65536.0;///131072.0/320.0; -// gxyaspect = ((double)xyaspect*(double)viewingrange)*(5.0/(65536.0*262144.0)); -// gviewxrange = ((double)viewingrange)*((double)xdimen)/(32768.0*128.0); - gcosang = double(viewcos)/65536.0; - gsinang = double(viewsin)/65536.0; - gcosang2 = gcosang*double(FocalTangent)/65536.0; - gsinang2 = gsinang*double(FocalTangent)/65536.0; - ghalfx = (double)viewwidth*0.5; grhalfxdown10 = 1.0/(((double)ghalfx)*1024); - - //global cos/sin height angle - angle_t pitch = (angle_t)viewpitch; - if (backside) pitch = ANGLE_180 - pitch; - - gshang = double(finesine[pitch>>ANGLETOFINESHIFT])/65536.0; - gchang = double(finecosine[pitch>>ANGLETOFINESHIFT])/65536.0; - ghoriz = double(viewheight)*0.5; - - //global cos/sin tilt angle - gctang = cos(gtang); - gstang = sin(gtang); - if (fabs(gstang) < .001) //This hack avoids nasty precision bugs in domost() - { gstang = 0; if (gctang > 0) gctang = 1.0; else gctang = -1.0; } - - // Generate viewport trapezoid - px[0] = px[3] = 0-1; px[1] = px[2] = viewwidth+3; - py[0] = py[1] = 0-1; py[2] = py[3] = viewheight+3; n = 4; - for(i=0;i= n) j = 0; - if (pz[i] >= SCISDIST/16) { px2[n2] = px[i]; py2[n2] = py[i]; pz2[n2] = pz[i]; n2++; } - if ((pz[i] >= SCISDIST/16) != (pz[j] >= SCISDIST/16)) - { - clipped = true; - r = (SCISDIST/16-pz[i])/(pz[j]-pz[i]); - px2[n2] = (px[j]-px[i])*r + px[i]; - py2[n2] = (py[j]-py[i])*r + py[i]; - pz2[n2] = SCISDIST/16; - if (backside) py2[n2] -= r; - n2++; - } - } - if (n2 < 3) { return true; } - for(i=0;i= (dpx[2]-dpx[1])*(dpy[0]-dpy[1])) return; //for triangle - } - else - { - f = 0; //f is area of polygon / 2 - for(i=n-2,j=n-1,k=0;klinedef == NULL) return; - - //Offset&Rotate 3D coordinates to screen 3D space - x = double(line->v1->x - viewx); y = double(line->v1->y - viewy); - xp0 = x*gsinang - y*gcosang; - yp0 = x*gcosang2 + y*gsinang2; - x = double(line->v2->x - viewx); y = double(line->v2->y - viewy); - xp1 = x*gsinang - y*gcosang; - yp1 = x*gcosang2 + y*gsinang2; - - oxp0 = xp0; oyp0 = yp0; - - //Clip to close parallel-screen plane - // [RH] Why oh why does clipping the left side of the wall against - // a small SCISDIST not work for me? Strictly speaking, it's not - // the clipping of the left side that's the problem, because if I - // rotate the view 180 degrees so the right side of the wall is on - // the left of the screen, then clipping the right side becomes - // problematic. -#define WCLIPDIST (SCISDIST*256.0) - if (yp0 < WCLIPDIST) - { - if (yp1 < WCLIPDIST) return; - t0 = (WCLIPDIST-yp0)/(yp1-yp0); - xp0 = (xp1-xp0)*t0+xp0; - yp0 = WCLIPDIST; - nx0 = (line->v2->x - line->v1->x)*t0 + line->v1->x; - ny0 = (line->v2->y - line->v1->y)*t0 + line->v1->y; - } - else { t0 = 0.f; nx0 = line->v1->x; ny0 = line->v1->y; } - if (yp1 < WCLIPDIST) - { - t1 = (WCLIPDIST-oyp0)/(yp1-oyp0); - xp1 = (xp1-oxp0)*t1+oxp0; - yp1 = WCLIPDIST; - nx1 = (line->v2->x - line->v1->x)*t1 + line->v1->x; - ny1 = (line->v2->y - line->v1->y)*t1 + line->v1->y; - } - else { t1 = 1.f; nx1 = line->v2->x; ny1 = line->v2->y; } - - ryp0 = 1.0/yp0; ryp1 = 1.0/yp1; - - //Generate screen coordinates for front side of wall - x0 = ghalfx*xp0*ryp0 + ghalfx; - x1 = ghalfx*xp1*ryp1 + ghalfx; - if (x1 <= x0) return; - - ryp0 *= gyxscale; ryp1 *= gyxscale; - fixed_t fnx0 = fixed_t(nx0), fny0 = fixed_t(ny0); - fixed_t fnx1 = fixed_t(nx1), fny1 = fixed_t(ny1); - - fcz0 = frontsector->ceilingplane.ZatPoint (fnx0, fny0); - ffz0 = frontsector->floorplane.ZatPoint (fnx0, fny0); - fcz1 = frontsector->ceilingplane.ZatPoint (fnx1, fny1); - ffz1 = frontsector->floorplane.ZatPoint (fnx1, fny1); - bool cc = (t0>0 && x1 > 0); - cy0 = ghoriz - double(fcz0 - viewz) * ryp0; - fy0 = ghoriz - double(ffz0 - viewz) * ryp0; - cy1 = ghoriz - double(fcz1 - viewz) * ryp1; - fy1 = ghoriz - double(ffz1 - viewz) * ryp1; - -/* - tx1 = line->v1->x - viewx; - tx2 = line->v2->x - viewx; - ty1 = line->v1->y - viewy; - ty2 = line->v2->y - viewy; - // Reject lines not facing viewer - if (DMulScale32 (ty1, tx1-tx2, tx1, ty2-ty1) >= 0) - return; - - WallTX1 = DMulScale20 (tx1, viewsin, -ty1, viewcos); - WallTX2 = DMulScale20 (tx2, viewsin, -ty2, viewcos); - - WallTY1 = DMulScale20 (tx1, viewtancos, ty1, viewtansin); - WallTY2 = DMulScale20 (tx2, viewtancos, ty2, viewtansin); - - if (MirrorFlags & RF_XFLIP) - { - int t = 256-WallTX1; - WallTX1 = 256-WallTX2; - WallTX2 = t; - swap (WallTY1, WallTY2); - } - - if (WallTX1 >= -WallTY1) - { - if (WallTX1 > WallTY1) return; // left edge is off the right side - if (WallTY1 == 0) return; - WallSX1 = (centerxfrac + Scale (WallTX1, centerxfrac, WallTY1)) >> FRACBITS; - if (WallTX1 >= 0) WallSX1 = MIN (viewwidth, WallSX1+1); // fix for signed divide - WallSZ1 = WallTY1; - } - else - { - if (WallTX2 < -WallTY2) return; // wall is off the left side - fixed_t den = WallTX1 - WallTX2 - WallTY2 + WallTY1; - if (den == 0) return; - WallSX1 = 0; - WallSZ1 = WallTY1 + Scale (WallTY2 - WallTY1, WallTX1 + WallTY1, den); - } - - if (WallSZ1 < 32) - return; - - if (WallTX2 <= WallTY2) - { - if (WallTX2 < -WallTY2) return; // right edge is off the left side - if (WallTY2 == 0) return; - WallSX2 = (centerxfrac + Scale (WallTX2, centerxfrac, WallTY2)) >> FRACBITS; - if (WallTX2 >= 0) WallSX2 = MIN (viewwidth, WallSX2+1); // fix for signed divide - WallSZ2 = WallTY2; - } - else - { - if (WallTX1 > WallTY1) return; // wall is off the right side - fixed_t den = WallTY2 - WallTY1 - WallTX2 + WallTX1; - if (den == 0) return; - WallSX2 = viewwidth; - WallSZ2 = WallTY1 + Scale (WallTY2 - WallTY1, WallTX1 - WallTY1, den); - } - - if (WallSZ2 < 32 || WallSX2 <= WallSX1) - return; - - if (WallSX1 > WindowRight || WallSX2 < WindowLeft) - return; - if (line->linedef == NULL) - { - return; - } -*/ - - vertex_t *v1, *v2; - - v1 = line->linedef->v1; - v2 = line->linedef->v2; - - if ((v1 == line->v1 && v2 == line->v2) || (v2 == line->v1 && v1 == line->v2)) - { // The seg is the entire wall. - if (MirrorFlags & RF_XFLIP) - { - WallUoverZorg = (float)WallTX2 * WallTMapScale; - WallUoverZstep = (float)(-WallTY2) * 32.f; - WallInvZorg = (float)(WallTX2 - WallTX1) * WallTMapScale; - WallInvZstep = (float)(WallTY1 - WallTY2) * 32.f; - } - else - { - WallUoverZorg = (float)WallTX1 * WallTMapScale; - WallUoverZstep = (float)(-WallTY1) * 32.f; - WallInvZorg = (float)(WallTX1 - WallTX2) * WallTMapScale; - WallInvZstep = (float)(WallTY2 - WallTY1) * 32.f; - } - } - else - { // The seg is only part of the wall. - if (line->linedef->sidedef[0] != line->sidedef) - { - swapvalues (v1, v2); - } - tx1 = v1->x - viewx; - tx2 = v2->x - viewx; - ty1 = v1->y - viewy; - ty2 = v2->y - viewy; - - fixed_t fullx1 = DMulScale20 (tx1, viewsin, -ty1, viewcos); - fixed_t fullx2 = DMulScale20 (tx2, viewsin, -ty2, viewcos); - fixed_t fully1 = DMulScale20 (tx1, viewtancos, ty1, viewtansin); - fixed_t fully2 = DMulScale20 (tx2, viewtancos, ty2, viewtansin); - - if (MirrorFlags & RF_XFLIP) - { - fullx1 = -fullx1; - fullx2 = -fullx2; - } - - WallUoverZorg = (float)fullx1 * WallTMapScale; - WallUoverZstep = (float)(-fully1) * 32.f; - WallInvZorg = (float)(fullx1 - fullx2) * WallTMapScale; - WallInvZstep = (float)(fully2 - fully1) * 32.f; - } - WallDepthScale = WallInvZstep * WallTMapScale2; - WallDepthOrg = -WallUoverZstep * WallTMapScale2; - - backsector = line->backsector; - - rw_mustmarkfloor = rw_mustmarkceiling = false; - rw_havehigh = rw_havelow = false; - - // Single sided line? - if (backsector == NULL) - { - solid = true; - } - else - { - // killough 3/8/98, 4/4/98: hack for invisible ceilings / deep water - backsector = R_FakeFlat (backsector, &tempsec, NULL, NULL, true); - - doorclosed = 0; // killough 4/16/98 - - bcz0 = backsector->ceilingplane.ZatPoint (fnx0, fny0); - bfz0 = backsector->floorplane.ZatPoint (fnx0, fny0); - bcz1 = backsector->ceilingplane.ZatPoint (fnx1, fny1); - bfz1 = backsector->floorplane.ZatPoint (fnx1, fny1); - ocy0 = ghoriz - double(bcz0 - viewz) * ryp0; - ofy0 = ghoriz - double(bfz0 - viewz) * ryp0; - ocy1 = ghoriz - double(bcz1 - viewz) * ryp1; - ofy1 = ghoriz - double(bfz1 - viewz) * ryp1; - - if (fcz0 > bcz0 || fcz1 > bcz1) - { - rw_havehigh = true; - } - if (ffz0 < bfz0 ||ffz1 < bfz1) - { - rw_havelow = true; - } - - // Closed door. - if ((bcz0 <= ffz0 && bcz1 <= ffz1) || (bfz0 >= fcz0 && bfz1 >= fcz1)) - { - solid = true; - } - else if ( - (backsector->GetTexture(sector_t::ceiling) != skyflatnum || - frontsector->GetTexture(sector_t::ceiling) != skyflatnum) - - // if door is closed because back is shut: - && bcz0 <= bfz0 && bcz1 <= bfz1 - - // preserve a kind of transparent door/lift special effect: - && bcz0 >= fcz0 && bcz1 >= fcz1 - - && ((bfz0 <= ffz0 && bfz1 <= ffz1) || line->sidedef->GetTexture(side_t::bottom).isValid())) - { - // killough 1/18/98 -- This function is used to fix the automap bug which - // showed lines behind closed doors simply because the door had a dropoff. - // - // It assumes that Doom has already ruled out a door being closed because - // of front-back closure (e.g. front floor is taller than back ceiling). - - // This fixes the automap floor height bug -- killough 1/18/98: - // killough 4/7/98: optimize: save result in doorclosed for use in r_segs.c - doorclosed = true; - solid = true; - } - else if (frontsector->ceilingplane != backsector->ceilingplane || - frontsector->floorplane != backsector->floorplane) - { - // Window. - solid = false; - } - else if (backsector->lightlevel != frontsector->lightlevel - || backsector->GetTexture(sector_t::floor) != frontsector->GetTexture(sector_t::floor) - || backsector->GetTexture(sector_t::ceiling) != frontsector->GetTexture(sector_t::ceiling) - || curline->sidedef->GetTexture(side_t::mid).isValid() - - // killough 3/7/98: Take flats offsets into account: - || backsector->GetXOffset(sector_t::floor) != frontsector->GetXOffset(sector_t::floor) - || backsector->GetYOffset(sector_t::floor) != frontsector->GetYOffset(sector_t::floor) - || backsector->GetXOffset(sector_t::ceiling) != frontsector->GetXOffset(sector_t::ceiling) - || backsector->GetYOffset(sector_t::ceiling) != frontsector->GetYOffset(sector_t::ceiling) - - || backsector->GetPlaneLight(sector_t::floor) != frontsector->GetPlaneLight(sector_t::floor) - || backsector->GetPlaneLight(sector_t::ceiling) != frontsector->GetPlaneLight(sector_t::ceiling) - || backsector->GetFlags(sector_t::floor) != frontsector->GetFlags(sector_t::floor) - || backsector->GetFlags(sector_t::ceiling) != frontsector->GetFlags(sector_t::ceiling) - - // [RH] Also consider colormaps - || backsector->ColorMap != frontsector->ColorMap - - // [RH] and scaling - || backsector->GetXScale(sector_t::floor) != frontsector->GetXScale(sector_t::floor) - || backsector->GetYScale(sector_t::floor) != frontsector->GetYScale(sector_t::floor) - || backsector->GetXScale(sector_t::ceiling) != frontsector->GetXScale(sector_t::ceiling) - || backsector->GetYScale(sector_t::ceiling) != frontsector->GetYScale(sector_t::ceiling) - - // [RH] and rotation - || backsector->GetAngle(sector_t::floor) != frontsector->GetAngle(sector_t::floor) - || backsector->GetAngle(sector_t::ceiling) != frontsector->GetAngle(sector_t::ceiling) - ) - { - solid = false; - } - else - { - // Reject empty lines used for triggers and special events. - // Identical floor and ceiling on both sides, identical light levels - // on both sides, and no middle texture. - return; - } - } - - if (line->linedef->special == Line_Horizon) - { - // Be aware: Line_Horizon does not work properly with sloped planes - fcz1 = fcz0 = ffz1 = ffz0 = viewz; - markceiling = markfloor = true; - } - - // must be fixed in case the polymost renderer ever gets developed further! - rw_offset = line->sidedef->GetTextureXOffset(side_t::mid); - - R_NewWall (false); - if (rw_markmirror) - { - WallMirrors.Push (ds_p - drawsegs); - } - - // render it - if (markceiling) - { - Mosts.DoMost (x1, cy1, x0, cy0, wireframe, !cc||1?(void *)0xc3:(void*)0xca); - } - if (markfloor) - { - Mosts.DoMost (x0, fy0, x1, fy1, wireframe, (void *)0xd3); - } - if (midtexture) - { // one sided line - //if(line->linedef-lines==1)Printf ("%g %g %g -> %g %g %g : %g %g -> %g %g\n", yp0, x0, fy0, yp1, x1, fy1, nx0, ny0, nx1, ny1); - if (viewpitch > 0) - Mosts.DoMost (x0, -10000, x1, -10000, wireframe, !cc||1?(void *)0x83:(void*)0x93); - else - Mosts.DoMost (x1, 10000, x0, 10000, wireframe, !cc||1?(void *)0x83:(void*)0x93); - } - else - { // two sided line - if (toptexture != NULL && toptexture->UseType != FTexture::TEX_Null) - { // top wall - Mosts.DoMost (x1, ocy1, x0, ocy0, wireframe, (void *)0xa3); - } - if (bottomtexture != NULL && bottomtexture->UseType != FTexture::TEX_Null) - { // bottom wall - Mosts.DoMost (x0, ofy0, x1, ofy1, wireframe, (void *)0x93); -/* float bfz2 = float(-(rw_backfz2 - viewz)) / 65536.f; - float bfz1 = float(-(rw_backfz1 - viewz)) / 65536.f; - Mosts.DoMost (WallSX1, bfz1 * izs / sz1 + ghoriz, - WallSX2, bfz2 * izs / sz2 + ghoriz, - wireframe, (void *)0x93);*/ - } - } -} - -void RP_Subsector (subsector_t *sub) -{ - int count; - seg_t* line; - sector_t tempsec; // killough 3/7/98: deep water hack - int floorlightlevel; // killough 3/16/98: set floor lightlevel - int ceilinglightlevel; // killough 4/11/98 - - frontsector = sub->sector; - count = sub->numlines; - line = sub->firstline; - - // killough 3/8/98, 4/4/98: Deep water / fake ceiling effect - frontsector = R_FakeFlat(frontsector, &tempsec, &floorlightlevel, - &ceilinglightlevel, false); // killough 4/11/98 - - basecolormap = frontsector->ColorMap; - //R_GetExtraLight (&ceilinglightlevel, frontsector->ceilingplane, frontsector->ExtraLights); - - // [RH] set foggy flag - foggy = level.fadeto || frontsector->ColorMap->Fade || (level.flags & LEVEL_HASFADETABLE); - r_actualextralight = foggy ? 0 : extralight << 4; - basecolormap = frontsector->ColorMap; -/* ceilingplane = frontsector->ceilingplane.ZatPoint (viewx, viewy) > viewz || - frontsector->ceilingpic == skyflatnum || - (frontsector->CeilingSkyBox != NULL && frontsector->CeilingSkyBox->bAlways) || - (frontsector->heightsec && - !(frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) && - frontsector->heightsec->floorpic == skyflatnum) ? - R_FindPlane(frontsector->ceilingplane, // killough 3/8/98 - frontsector->ceilingpic, - ceilinglightlevel + r_actualextralight, // killough 4/11/98 - frontsector->ceiling_xoffs, // killough 3/7/98 - frontsector->ceiling_yoffs + frontsector->base_ceiling_yoffs, - frontsector->ceiling_xscale, - frontsector->ceiling_yscale, - frontsector->ceiling_angle + frontsector->base_ceiling_angle, - frontsector->sky, - frontsector->CeilingSkyBox, - ) : NULL;*/ - - basecolormap = frontsector->ColorMap; - //R_GetExtraLight (&floorlightlevel, frontsector->floorplane, frontsector->ExtraLights); - - // killough 3/7/98: Add (x,y) offsets to flats, add deep water check - // killough 3/16/98: add floorlightlevel - // killough 10/98: add support for skies transferred from sidedefs -/* floorplane = frontsector->floorplane.ZatPoint (viewx, viewy) < viewz || // killough 3/7/98 - frontsector->floorpic == skyflatnum || - (frontsector->FloorSkyBox != NULL && frontsector->FloorSkyBox->bAlways) || - (frontsector->heightsec && - !(frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) && - frontsector->heightsec->ceilingpic == skyflatnum) ? - R_FindPlane(frontsector->floorplane, - frontsector->floorpic, - floorlightlevel + r_actualextralight, // killough 3/16/98 - frontsector->floor_xoffs, // killough 3/7/98 - frontsector->floor_yoffs + frontsector->base_floor_yoffs, - frontsector->floor_xscale, - frontsector->floor_yscale, - frontsector->floor_angle + frontsector->base_floor_angle, - frontsector->sky, - frontsector->FloorSkyBox - ) : NULL;*/ - - // killough 9/18/98: Fix underwater slowdown, by passing real sector - // instead of fake one. Improve sprite lighting by basing sprite - // lightlevels on floor & ceiling lightlevels in the surrounding area. - // [RH] Handle sprite lighting like Duke 3D: If the ceiling is a sky, sprites are lit by - // it, otherwise they are lit by the floor. -// R_AddSprites (sub->sector, frontsector->ceilingpic == skyflatnum ? -// ceilinglightlevel : floorlightlevel, FakeSide); - - // [RH] Add particles -// int shade = LIGHT2SHADE((floorlightlevel + ceilinglightlevel)/2 + r_actualextralight); -// for (WORD i = ParticlesInSubsec[sub-subsectors]; i != NO_PARTICLE; i = Particles[i].snext) -// { -// R_ProjectParticle (Particles + i, subsectors[sub-subsectors].sector, shade, FakeSide); -// } - -#if 0 - if (sub->poly) - { // Render the polyobj in the subsector first - int polyCount = sub->poly->numsegs; - seg_t **polySeg = sub->poly->segs; - while (polyCount--) - { - RP_AddLine (*polySeg++); - } - } -#endif - - while (count--) - { - if (line->sidedef == NULL || !(line->sidedef->Flags & WALLF_POLYOBJ)) - { - RP_AddLine (line); - } - line++; - } -} - -extern "C" const int checkcoord[12][4]; - -static bool RP_CheckBBox (fixed_t *bspcoord) -{ - int boxx; - int boxy; - int boxpos; - - fixed_t x1, y1, x2, y2; - double x, y, xp0, yp0, xp1, yp1, t, sx0, sx1; - - // Find the corners of the box - // that define the edges from current viewpoint. - if (viewx <= bspcoord[BOXLEFT]) - boxx = 0; - else if (viewx < bspcoord[BOXRIGHT]) - boxx = 1; - else - boxx = 2; - - if (viewy >= bspcoord[BOXTOP]) - boxy = 0; - else if (viewy > bspcoord[BOXBOTTOM]) - boxy = 1; - else - boxy = 2; - - boxpos = (boxy<<2)+boxx; - if (boxpos == 5) - return true; - - x1 = bspcoord[checkcoord[boxpos][0]] - viewx; - y1 = bspcoord[checkcoord[boxpos][1]] - viewy; - x2 = bspcoord[checkcoord[boxpos][2]] - viewx; - y2 = bspcoord[checkcoord[boxpos][3]] - viewy; - - // check clip list for an open space - - // Sitting on a line? - if (DMulScale32 (y1, x1-x2, x1, y2-y1) >= 0) - return true; - - //Offset&Rotate 3D coordinates to screen 3D space - x = double(x1); y = double(y1); - xp0 = x*gsinang - y*gcosang; - yp0 = x*gcosang2 + y*gsinang2; - x = double(x2); y = double(y2); - xp1 = x*gsinang - y*gcosang; - yp1 = x*gcosang2 + y*gsinang2; - - //Clip to close parallel-screen plane - if (yp0 < SCISDIST) - { - if (yp1 < SCISDIST) return false; - t = (SCISDIST-yp0)/(yp1-yp0); - xp0 = (xp1-xp0)*t+xp0; - yp0 = SCISDIST; - } - if (yp1 < SCISDIST) - { - t = (SCISDIST-yp0)/(yp1-yp0); - xp1 = (xp1-xp0)*t+xp0; - yp1 = SCISDIST; - } - - //Generate screen coordinates for front side of wall - sx0 = ghalfx*xp0/yp0 + ghalfx; - sx1 = ghalfx*xp1/yp1 + ghalfx; - - // Does not cross a pixel. - if (sx1 <= sx0) - return false; - - return Mosts.TestVisibleMost (sx0, sx1); -} - -void RP_RenderBSPNode (void *node) -{ - if (numnodes == 0) - { - RP_Subsector (subsectors); - return; - } - while (!((size_t)node & 1)) // Keep going until found a subsector - { - node_t *bsp = (node_t *)node; - - // Decide which side the view point is on. - int side = R_PointOnSide (viewx, viewy, bsp); - - // Recursively divide front space (toward the viewer). - RP_RenderBSPNode (bsp->children[side]); - - // Possibly divide back space (away from the viewer). - side ^= 1; - if (!RP_CheckBBox (bsp->bbox[side])) - return; - - node = bsp->children[side]; - } - RP_Subsector ((subsector_t *)((BYTE *)node - 1)); -} - diff --git a/src/r_polymost.h b/src/r_polymost.h deleted file mode 100644 index 8afbefb22..000000000 --- a/src/r_polymost.h +++ /dev/null @@ -1,55 +0,0 @@ -/************************************************************************************************** -"POLYMOST" code written by Ken Silverman -**************************************************************************************************/ - -#include "c_cvars.h" - -typedef void (*pmostcallbacktype)(double *dpx, double *dpy, int n, void *userdata); - -class PolyClipper -{ -public: - PolyClipper(); - ~PolyClipper(); - - void InitMosts (double *px, double *py, int n); - bool TestVisibleMost (float x0, float x1); - int DoMost (float x0, float y0, float x1, float y1, pmostcallbacktype callback, void *callbackdata); - -private: - struct vsptype - { - float X, Cy[2], Fy[2]; - int Tag, CTag, FTag; - vsptype *Next, *Prev; - }; - - enum { GROUP_SIZE = 128 }; - - struct vspgroup - { - vspgroup (vsptype *sentinel); - - vspgroup *NextGroup; - vsptype vsp[GROUP_SIZE]; - }; - - vsptype EmptyList; - vsptype UsedList; - vspgroup vsps; - vsptype Solid; - - int GTag; - - vsptype *vsinsaft (vsptype *vsp); - void EmptyAll (); - void AddGroup (); - vsptype *GetVsp (); - void FreeVsp (vsptype *vsp); - - friend void drawpolymosttest(); - -}; - -extern void drawpolymosttest(); -struct event_t; void Polymost_Responder (event_t *ev); diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 56f816d6f..fb54b6f0a 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -40,7 +40,6 @@ #include "r_bsp.h" #include "r_swrenderer.h" #include "r_3dfloors.h" -#include "r_polymost.h" #include "textures/textures.h" #include "r_data/voxels.h" @@ -49,7 +48,6 @@ class FArchive; void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, int trueratio); void R_SetupColormap(player_t *); void R_SetupFreelook(); -void R_SetupPolymost(); void R_InitRenderer(); extern float LastFOV; @@ -245,7 +243,6 @@ void FSoftwareRenderer::SetupFrame(player_t *player) { R_SetupColormap(player); R_SetupFreelook(); - R_SetupPolymost(); } //========================================================================== diff --git a/zdoom.vcproj b/zdoom.vcproj index 3cbfac13a..cabc6c84f 100644 --- a/zdoom.vcproj +++ b/zdoom.vcproj @@ -2309,10 +2309,6 @@ RelativePath=".\src\r_plane.cpp" > - - @@ -2353,10 +2349,6 @@ RelativePath=".\src\r_plane.h" > - - From bc450808b29e2ebfeaf7f2e2aace8f87aab3f7e1 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 31 Jul 2014 20:11:59 -0500 Subject: [PATCH 18/54] Consolidate wall texturing vars into two structs - All transformation and clipping values go into FWallCoords. - All texture mapping values go into FWallTMapVals. --- src/r_bsp.cpp | 116 ++++++++--------- src/r_bsp.h | 22 +++- src/r_segs.cpp | 329 +++++++++++++++++++++++-------------------------- 3 files changed, 226 insertions(+), 241 deletions(-) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 31dfe9907..c1ddb2a3c 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -92,18 +92,8 @@ drawseg_t* ds_p; size_t FirstInterestingDrawseg; TArray InterestingDrawsegs; -fixed_t WallTX1, WallTX2; // x coords at left, right of wall in view space -fixed_t WallTY1, WallTY2; // y coords at left, right of wall in view space - -fixed_t WallCX1, WallCX2; // x coords at left, right of wall in camera space -fixed_t WallCY1, WallCY2; // y coords at left, right of wall in camera space - -int WallSX1, WallSX2; // x coords at left, right of wall in screen space -fixed_t WallSZ1, WallSZ2; // depth at left, right of wall in screen space - -float WallDepthOrg, WallDepthScale; -float WallUoverZorg, WallUoverZstep; -float WallInvZorg, WallInvZstep; +FWallCoords WallC; +FWallTmapVals WallT; static BYTE FakeSide; @@ -419,7 +409,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, rw_frontcz2 <= s->floorplane.ZatPoint (curline->v2->x, curline->v2->y)) { // Check that the window is actually visible - for (int z = WallSX1; z < WallSX2; ++z) + for (int z = WallC.SX1; z < WallC.SX2; ++z) { if (floorclip[z] > ceilingclip[z]) { @@ -549,66 +539,66 @@ void R_AddLine (seg_t *line) if (DMulScale32 (ty1, tx1-tx2, tx1, ty2-ty1) >= 0) return; - WallTX1 = DMulScale20 (tx1, viewsin, -ty1, viewcos); - WallTX2 = DMulScale20 (tx2, viewsin, -ty2, viewcos); + WallC.TX1 = DMulScale20 (tx1, viewsin, -ty1, viewcos); + WallC.TX2 = DMulScale20 (tx2, viewsin, -ty2, viewcos); - WallTY1 = DMulScale20 (tx1, viewtancos, ty1, viewtansin); - WallTY2 = DMulScale20 (tx2, viewtancos, ty2, viewtansin); + WallC.TY1 = DMulScale20 (tx1, viewtancos, ty1, viewtansin); + WallC.TY2 = DMulScale20 (tx2, viewtancos, ty2, viewtansin); if (MirrorFlags & RF_XFLIP) { - int t = 256-WallTX1; - WallTX1 = 256-WallTX2; - WallTX2 = t; - swapvalues (WallTY1, WallTY2); + int t = 256-WallC.TX1; + WallC.TX1 = 256-WallC.TX2; + WallC.TX2 = t; + swapvalues (WallC.TY1, WallC.TY2); } - if (WallTX1 >= -WallTY1) + if (WallC.TX1 >= -WallC.TY1) { - if (WallTX1 > WallTY1) return; // left edge is off the right side - if (WallTY1 == 0) return; - WallSX1 = (centerxfrac + Scale (WallTX1, centerxfrac, WallTY1)) >> FRACBITS; - if (WallTX1 >= 0) WallSX1 = MIN (viewwidth, WallSX1+1); // fix for signed divide - WallSZ1 = WallTY1; + if (WallC.TX1 > WallC.TY1) return; // left edge is off the right side + if (WallC.TY1 == 0) return; + WallC.SX1 = (centerxfrac + Scale (WallC.TX1, centerxfrac, WallC.TY1)) >> FRACBITS; + if (WallC.TX1 >= 0) WallC.SX1 = MIN (viewwidth, WallC.SX1+1); // fix for signed divide + WallC.SZ1 = WallC.TY1; } else { - if (WallTX2 < -WallTY2) return; // wall is off the left side - fixed_t den = WallTX1 - WallTX2 - WallTY2 + WallTY1; + if (WallC.TX2 < -WallC.TY2) return; // wall is off the left side + fixed_t den = WallC.TX1 - WallC.TX2 - WallC.TY2 + WallC.TY1; if (den == 0) return; - WallSX1 = 0; - WallSZ1 = WallTY1 + Scale (WallTY2 - WallTY1, WallTX1 + WallTY1, den); + WallC.SX1 = 0; + WallC.SZ1 = WallC.TY1 + Scale (WallC.TY2 - WallC.TY1, WallC.TX1 + WallC.TY1, den); } - if (WallSZ1 < 32) + if (WallC.SZ1 < 32) return; - if (WallTX2 <= WallTY2) + if (WallC.TX2 <= WallC.TY2) { - if (WallTX2 < -WallTY2) return; // right edge is off the left side - if (WallTY2 == 0) return; - WallSX2 = (centerxfrac + Scale (WallTX2, centerxfrac, WallTY2)) >> FRACBITS; - if (WallTX2 >= 0) WallSX2 = MIN (viewwidth, WallSX2+1); // fix for signed divide - WallSZ2 = WallTY2; + if (WallC.TX2 < -WallC.TY2) return; // right edge is off the left side + if (WallC.TY2 == 0) return; + WallC.SX2 = (centerxfrac + Scale (WallC.TX2, centerxfrac, WallC.TY2)) >> FRACBITS; + if (WallC.TX2 >= 0) WallC.SX2 = MIN (viewwidth, WallC.SX2+1); // fix for signed divide + WallC.SZ2 = WallC.TY2; } else { - if (WallTX1 > WallTY1) return; // wall is off the right side - fixed_t den = WallTY2 - WallTY1 - WallTX2 + WallTX1; + if (WallC.TX1 > WallC.TY1) return; // wall is off the right side + fixed_t den = WallC.TY2 - WallC.TY1 - WallC.TX2 + WallC.TX1; if (den == 0) return; - WallSX2 = viewwidth; - WallSZ2 = WallTY1 + Scale (WallTY2 - WallTY1, WallTX1 - WallTY1, den); + WallC.SX2 = viewwidth; + WallC.SZ2 = WallC.TY1 + Scale (WallC.TY2 - WallC.TY1, WallC.TX1 - WallC.TY1, den); } - if (WallSZ2 < 32 || WallSX2 <= WallSX1) + if (WallC.SZ2 < 32 || WallC.SX2 <= WallC.SX1) return; - if (WallSX1 > WindowRight || WallSX2 < WindowLeft) + if (WallC.SX1 > WindowRight || WallC.SX2 < WindowLeft) return; if (line->linedef == NULL) { - if (R_CheckClipWallSegment (WallSX1, WallSX2)) + if (R_CheckClipWallSegment (WallC.SX1, WallC.SX2)) { InSubsector->flags |= SSECF_DRAWN; } @@ -624,17 +614,17 @@ void R_AddLine (seg_t *line) { // The seg is the entire wall. if (MirrorFlags & RF_XFLIP) { - WallUoverZorg = (float)WallTX2 * WallTMapScale; - WallUoverZstep = (float)(-WallTY2) * 32.f; - WallInvZorg = (float)(WallTX2 - WallTX1) * WallTMapScale; - WallInvZstep = (float)(WallTY1 - WallTY2) * 32.f; + WallT.UoverZorg = (float)WallC.TX2 * WallTMapScale; + WallT.UoverZstep = (float)(-WallC.TY2) * 32.f; + WallT.InvZorg = (float)(WallC.TX2 - WallC.TX1) * WallTMapScale; + WallT.InvZstep = (float)(WallC.TY1 - WallC.TY2) * 32.f; } else { - WallUoverZorg = (float)WallTX1 * WallTMapScale; - WallUoverZstep = (float)(-WallTY1) * 32.f; - WallInvZorg = (float)(WallTX1 - WallTX2) * WallTMapScale; - WallInvZstep = (float)(WallTY2 - WallTY1) * 32.f; + WallT.UoverZorg = (float)WallC.TX1 * WallTMapScale; + WallT.UoverZstep = (float)(-WallC.TY1) * 32.f; + WallT.InvZorg = (float)(WallC.TX1 - WallC.TX2) * WallTMapScale; + WallT.InvZstep = (float)(WallC.TY2 - WallC.TY1) * 32.f; } } else @@ -659,13 +649,13 @@ void R_AddLine (seg_t *line) fullx2 = -fullx2; } - WallUoverZorg = (float)fullx1 * WallTMapScale; - WallUoverZstep = (float)(-fully1) * 32.f; - WallInvZorg = (float)(fullx1 - fullx2) * WallTMapScale; - WallInvZstep = (float)(fully2 - fully1) * 32.f; + WallT.UoverZorg = (float)fullx1 * WallTMapScale; + WallT.UoverZstep = (float)(-fully1) * 32.f; + WallT.InvZorg = (float)(fullx1 - fullx2) * WallTMapScale; + WallT.InvZstep = (float)(fully2 - fully1) * 32.f; } - WallDepthScale = WallInvZstep * WallTMapScale2; - WallDepthOrg = -WallUoverZstep * WallTMapScale2; + WallT.DepthScale = WallT.InvZstep * WallTMapScale2; + WallT.DepthOrg = -WallT.UoverZstep * WallTMapScale2; if (!(fake3D & FAKE3D_FAKEBACK)) { @@ -791,7 +781,7 @@ void R_AddLine (seg_t *line) // mark their subsectors as visible for automap texturing. if (hasglnodes && !(InSubsector->flags & SSECF_DRAWN)) { - if (R_CheckClipWallSegment(WallSX1, WallSX2)) + if (R_CheckClipWallSegment(WallC.SX1, WallC.SX2)) { InSubsector->flags |= SSECF_DRAWN; } @@ -805,8 +795,8 @@ void R_AddLine (seg_t *line) if (line->linedef->special == Line_Horizon) { // Be aware: Line_Horizon does not work properly with sloped planes - clearbufshort (walltop+WallSX1, WallSX2 - WallSX1, centery); - clearbufshort (wallbottom+WallSX1, WallSX2 - WallSX1, centery); + clearbufshort (walltop+WallC.SX1, WallC.SX2 - WallC.SX1, centery); + clearbufshort (wallbottom+WallC.SX1, WallC.SX2 - WallC.SX1, centery); } else { @@ -831,7 +821,7 @@ void R_AddLine (seg_t *line) #endif } - if (R_ClipWallSegment (WallSX1, WallSX2, solid)) + if (R_ClipWallSegment (WallC.SX1, WallC.SX2, solid)) { InSubsector->flags |= SSECF_DRAWN; } diff --git a/src/r_bsp.h b/src/r_bsp.h index da20fb90c..d2fcb67e1 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -26,6 +26,25 @@ #include "tarray.h" #include +struct FWallCoords +{ + fixed_t TX1, TX2; // x coords at left, right of wall in view space + fixed_t TY1, TY2; // y coords at left, right of wall in view space + + fixed_t CX1, CX2; // x coords at left, right of wall in camera space + fixed_t CY1, CY2; // y coords at left, right of wall in camera space + + int SX1, SX2; // x coords at left, right of wall in screen space + fixed_t SZ1, SZ2; // depth at left, right of wall in screen space +}; + +struct FWallTmapVals +{ + float DepthOrg, DepthScale; + float UoverZorg, UoverZstep; + float InvZorg, InvZstep; +}; + enum { FAKED_Center, @@ -33,7 +52,6 @@ enum FAKED_AboveCeiling }; - struct drawseg_t { seg_t* curline; @@ -58,7 +76,7 @@ struct drawseg_t int fake; // ident fake drawseg, don't draw and clip sprites // backups ptrdiff_t bkup; // sprtopclip backup, for mid and fake textures - float WallUoverZorg, WallUoverZstep, WallInvZorg, WallInvZstep, WallDepthScale, WallDepthOrg; + FWallTmapVals tmapvals; }; diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 4fec863ff..e1896b883 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -90,9 +90,8 @@ int OWallMost (short *mostbuf, fixed_t z); int WallMost (short *mostbuf, const secplane_t &plane); void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat); void PrepLWall (fixed_t *lwall, fixed_t walxrepeat); -extern fixed_t WallSZ1, WallSZ2, WallTX1, WallTX2, WallTY1, WallTY2, WallCX1, WallCX2, WallCY1, WallCY2; -extern int WallSX1, WallSX2; -extern float WallUoverZorg, WallUoverZstep, WallInvZorg, WallInvZstep, WallDepthScale, WallDepthOrg; +extern FWallCoords WallC; +extern FWallTmapVals WallT; int wallshade; @@ -389,10 +388,10 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) goto clearfog; } - WallSZ1 = ds->sz1; - WallSZ2 = ds->sz2; - WallSX1 = ds->sx1; - WallSX2 = ds->sx2; + WallC.SZ1 = ds->sz1; + WallC.SZ2 = ds->sz2; + WallC.SX1 = ds->sx1; + WallC.SX2 = ds->sx2; if (fake3D & FAKE3D_CLIPTOP) { @@ -480,10 +479,10 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) } else { // Texture does wrap vertically. - WallSZ1 = ds->sz1; - WallSZ2 = ds->sz2; - WallSX1 = ds->sx1; - WallSX2 = ds->sx2; + WallC.SZ1 = ds->sz1; + WallC.SZ2 = ds->sz2; + WallC.SX1 = ds->sx1; + WallC.SX2 = ds->sx2; if (CurrentSkybox) { // Midtex clipping doesn't work properly with skyboxes, since you're normally below the floor @@ -600,20 +599,15 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) else if (fixedcolormap != NULL) dc_colormap = fixedcolormap; - WallSZ1 = ds->sz1; - WallSZ2 = ds->sz2; - WallSX1 = ds->sx1; - WallSX2 = ds->sx2; - WallTX1 = ds->cx; - WallTY1 = ds->cy; - WallTX2 = WallTX1 + ds->cdx; - WallTY2 = WallTY1 + ds->cdy; - WallDepthScale = ds->WallDepthScale; - WallDepthOrg = ds->WallDepthOrg; - WallUoverZorg = ds->WallUoverZorg; - WallUoverZstep = ds->WallUoverZstep; - WallInvZorg = ds->WallInvZorg; - WallInvZstep = ds->WallInvZstep; + WallC.SZ1 = ds->sz1; + WallC.SZ2 = ds->sz2; + WallC.SX1 = ds->sx1; + WallC.SX2 = ds->sx2; + WallC.TX1 = ds->cx; + WallC.TY1 = ds->cy; + WallC.TX2 = ds->cx + ds->cdx; + WallC.TY2 = ds->cy + ds->cdy; + WallT = ds->tmapvals; OWallMost(wallupper, sclipTop - viewz); OWallMost(walllower, sclipBottom - viewz); @@ -1227,8 +1221,8 @@ void wallscan_striped (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, up = uwal; down = most1; - assert(WallSX1 <= x1); - assert(WallSX2 > x2); + assert(WallC.SX1 <= x1); + assert(WallC.SX2 > x2); // kg3D - fake floors instead of zdoom light list for (unsigned int i = 0; i < frontsector->e->XFloor.lightlist.Size(); i++) @@ -2048,7 +2042,7 @@ void R_NewWall (bool needlights) { if (rw_havehigh) { // front ceiling is above back ceiling - memcpy (&walltop[WallSX1], &wallupper[WallSX1], (WallSX2 - WallSX1)*sizeof(walltop[0])); + memcpy (&walltop[WallC.SX1], &wallupper[WallC.SX1], (WallC.SX2 - WallC.SX1)*sizeof(walltop[0])); rw_havehigh = false; } else if (rw_havelow && frontsector->ceilingplane != backsector->ceilingplane) @@ -2280,8 +2274,8 @@ void R_NewWall (bool needlights) wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, frontsector->lightlevel) + r_actualextralight); GlobVis = r_WallVisibility; - rw_lightleft = SafeDivScale12 (GlobVis, WallSZ1); - rw_lightstep = (SafeDivScale12 (GlobVis, WallSZ2) - rw_lightleft) / (WallSX2 - WallSX1); + rw_lightleft = SafeDivScale12 (GlobVis, WallC.SZ1); + rw_lightstep = (SafeDivScale12 (GlobVis, WallC.SZ2) - rw_lightleft) / (WallC.SX2 - WallC.SX1); } else { @@ -2355,24 +2349,19 @@ void R_StoreWallRange (int start, int stop) } rw_offset = sidedef->GetTextureXOffset(side_t::mid); - rw_light = rw_lightleft + rw_lightstep * (start - WallSX1); + rw_light = rw_lightleft + rw_lightstep * (start - WallC.SX1); - ds_p->sx1 = WallSX1; - ds_p->sx2 = WallSX2; - ds_p->sz1 = WallSZ1; - ds_p->sz2 = WallSZ2; - ds_p->cx = WallTX1; - ds_p->cy = WallTY1; - ds_p->cdx = WallTX2 - WallTX1; - ds_p->cdy = WallTY2 - WallTY1; - ds_p->WallDepthScale = WallDepthScale; - ds_p->WallDepthOrg = WallDepthOrg; - ds_p->WallUoverZorg = WallUoverZorg; - ds_p->WallUoverZstep = WallUoverZstep; - ds_p->WallInvZorg = WallInvZorg; - ds_p->WallInvZstep = WallInvZstep; - ds_p->siz1 = (DWORD)DivScale32 (1, WallSZ1) >> 1; - ds_p->siz2 = (DWORD)DivScale32 (1, WallSZ2) >> 1; + ds_p->sx1 = WallC.SX1; + ds_p->sx2 = WallC.SX2; + ds_p->sz1 = WallC.SZ1; + ds_p->sz2 = WallC.SZ2; + ds_p->cx = WallC.TX1; + ds_p->cy = WallC.TY1; + ds_p->cdx = WallC.TX2 - WallC.TX1; + ds_p->cdy = WallC.TY2 - WallC.TY1; + ds_p->tmapvals = WallT; + ds_p->siz1 = (DWORD)DivScale32 (1, WallC.SZ1) >> 1; + ds_p->siz2 = (DWORD)DivScale32 (1, WallC.SZ2) >> 1; ds_p->x1 = rw_x = start; ds_p->x2 = stop-1; ds_p->curline = curline; @@ -2465,7 +2454,7 @@ void R_StoreWallRange (int start, int stop) if ((TexMan(sidedef->GetTexture(side_t::mid), true)->UseType != FTexture::TEX_Null || ds_p->bFakeBoundary || IsFogBoundary (frontsector, backsector)) && (rw_ceilstat != 12 || !sidedef->GetTexture(side_t::top).isValid()) && (rw_floorstat != 3 || !sidedef->GetTexture(side_t::bottom).isValid()) && - (WallSZ1 >= TOO_CLOSE_Z && WallSZ2 >= TOO_CLOSE_Z)) + (WallC.SZ1 >= TOO_CLOSE_Z && WallC.SZ2 >= TOO_CLOSE_Z)) { fixed_t *swal; fixed_t *lwal; @@ -2613,59 +2602,59 @@ int OWallMost (short *mostbuf, fixed_t z) fixed_t s1, s2, s3, s4; z = -(z >> 4); - s1 = MulScale16 (globaluclip, WallSZ1); s2 = MulScale16 (globaluclip, WallSZ2); - s3 = MulScale16 (globaldclip, WallSZ1); s4 = MulScale16 (globaldclip, WallSZ2); + s1 = MulScale16 (globaluclip, WallC.SZ1); s2 = MulScale16 (globaluclip, WallC.SZ2); + s3 = MulScale16 (globaldclip, WallC.SZ1); s4 = MulScale16 (globaldclip, WallC.SZ2); bad = (zs3)<<2)+((z>s4)<<3); #if 1 if ((bad&3) == 3) { - memset (&mostbuf[WallSX1], 0, (WallSX2 - WallSX1)*sizeof(mostbuf[0])); + memset (&mostbuf[WallC.SX1], 0, (WallC.SX2 - WallC.SX1)*sizeof(mostbuf[0])); return bad; } if ((bad&12) == 12) { - clearbufshort (&mostbuf[WallSX1], WallSX2 - WallSX1, viewheight); + clearbufshort (&mostbuf[WallC.SX1], WallC.SX2 - WallC.SX1, viewheight); return bad; } #endif - ix1 = WallSX1; iy1 = WallSZ1; - ix2 = WallSX2; iy2 = WallSZ2; + ix1 = WallC.SX1; iy1 = WallC.SZ1; + ix2 = WallC.SX2; iy2 = WallC.SZ2; #if 1 if (bad & 3) { int t = DivScale30 (z-s1, s2-s1); - int inty = WallSZ1 + MulScale30 (WallSZ2 - WallSZ1, t); - int xcross = WallSX1 + Scale (MulScale30 (WallSZ2, t), WallSX2 - WallSX1, inty); + int inty = WallC.SZ1 + MulScale30 (WallC.SZ2 - WallC.SZ1, t); + int xcross = WallC.SX1 + Scale (MulScale30 (WallC.SZ2, t), WallC.SX2 - WallC.SX1, inty); if ((bad & 3) == 2) { - if (WallSX1 <= xcross) { iy2 = inty; ix2 = xcross; } - if (WallSX2 > xcross) memset (&mostbuf[xcross], 0, (WallSX2-xcross)*sizeof(mostbuf[0])); + if (WallC.SX1 <= xcross) { iy2 = inty; ix2 = xcross; } + if (WallC.SX2 > xcross) memset (&mostbuf[xcross], 0, (WallC.SX2-xcross)*sizeof(mostbuf[0])); } else { - if (xcross <= WallSX2) { iy1 = inty; ix1 = xcross; } - if (xcross > WallSX1) memset (&mostbuf[WallSX1], 0, (xcross-WallSX1)*sizeof(mostbuf[0])); + if (xcross <= WallC.SX2) { iy1 = inty; ix1 = xcross; } + if (xcross > WallC.SX1) memset (&mostbuf[WallC.SX1], 0, (xcross-WallC.SX1)*sizeof(mostbuf[0])); } } if (bad & 12) { int t = DivScale30 (z-s3, s4-s3); - int inty = WallSZ1 + MulScale30 (WallSZ2 - WallSZ1, t); - int xcross = WallSX1 + Scale (MulScale30 (WallSZ2, t), WallSX2 - WallSX1, inty); + int inty = WallC.SZ1 + MulScale30 (WallC.SZ2 - WallC.SZ1, t); + int xcross = WallC.SX1 + Scale (MulScale30 (WallC.SZ2, t), WallC.SX2 - WallC.SX1, inty); if ((bad & 12) == 8) { - if (WallSX1 <= xcross) { iy2 = inty; ix2 = xcross; } - if (WallSX2 > xcross) clearbufshort (&mostbuf[xcross], WallSX2 - xcross, viewheight); + if (WallC.SX1 <= xcross) { iy2 = inty; ix2 = xcross; } + if (WallC.SX2 > xcross) clearbufshort (&mostbuf[xcross], WallC.SX2 - xcross, viewheight); } else { - if (xcross <= WallSX2) { iy1 = inty; ix1 = xcross; } - if (xcross > WallSX1) clearbufshort (&mostbuf[WallSX1], xcross - WallSX1, viewheight); + if (xcross <= WallC.SX2) { iy1 = inty; ix1 = xcross; } + if (xcross > WallC.SX1) clearbufshort (&mostbuf[WallC.SX1], xcross - WallC.SX1, viewheight); } } @@ -2683,12 +2672,12 @@ int OWallMost (short *mostbuf, fixed_t z) double max = viewheight; double zz = z / 65536.0; #if 0 - double z1 = zz * InvZtoScale / WallSZ1; - double z2 = zz * InvZtoScale / WallSZ2 - z1; - z2 /= (WallSX2 - WallSX1); + double z1 = zz * InvZtoScale / WallC.SZ1; + double z2 = zz * InvZtoScale / WallC.SZ2 - z1; + z2 /= (WallC.SX2 - WallC.SX1); z1 += centeryfrac / 65536.0; - for (int x = WallSX1; x < WallSX2; ++x) + for (int x = WallC.SX1; x < WallC.SX2; ++x) { mostbuf[x] = xs_RoundToInt(clamp(z1, 0.0, max)); z1 += z2; @@ -2696,18 +2685,18 @@ int OWallMost (short *mostbuf, fixed_t z) #else double top, bot, i; - i = WallSX1 - centerx; - top = WallUoverZorg + WallUoverZstep * i; - bot = WallInvZorg + WallInvZstep * i; + i = WallC.SX1 - centerx; + top = WallT.UoverZorg + WallT.UoverZstep * i; + bot = WallT.InvZorg + WallT.InvZstep * i; double cy = centeryfrac / 65536.0; - for (int x = WallSX1; x < WallSX2; x++) + for (int x = WallC.SX1; x < WallC.SX2; x++) { double frac = top / bot; - double scale = frac * WallDepthScale + WallDepthOrg; + double scale = frac * WallT.DepthScale + WallT.DepthOrg; mostbuf[x] = xs_RoundToInt(clamp(zz / scale + cy, 0.0, max)); - top += WallUoverZstep; - bot += WallInvZstep; + top += WallT.UoverZstep; + bot += WallT.InvZstep; } #endif #endif @@ -2734,21 +2723,21 @@ int WallMost (short *mostbuf, const secplane_t &plane) { x = curline->v2->x; y = curline->v2->y; - if (WallSX1 == 0 && 0 != (den = WallTX1 - WallTX2 + WallTY1 - WallTY2)) + if (WallC.SX1 == 0 && 0 != (den = WallC.TX1 - WallC.TX2 + WallC.TY1 - WallC.TY2)) { - int frac = SafeDivScale30 (WallTY1 + WallTX1, den); + int frac = SafeDivScale30 (WallC.TY1 + WallC.TX1, den); x -= MulScale30 (frac, x - curline->v1->x); y -= MulScale30 (frac, y - curline->v1->y); } z1 = viewz - plane.ZatPoint (x, y); - if (WallSX2 > WallSX1 + 1) + if (WallC.SX2 > WallC.SX1 + 1) { x = curline->v1->x; y = curline->v1->y; - if (WallSX2 == viewwidth && 0 != (den = WallTX1 - WallTX2 - WallTY1 + WallTY2)) + if (WallC.SX2 == viewwidth && 0 != (den = WallC.TX1 - WallC.TX2 - WallC.TY1 + WallC.TY2)) { - int frac = SafeDivScale30 (WallTY2 - WallTX2, den); + int frac = SafeDivScale30 (WallC.TY2 - WallC.TX2, den); x += MulScale30 (frac, curline->v2->x - x); y += MulScale30 (frac, curline->v2->y - y); } @@ -2763,21 +2752,21 @@ int WallMost (short *mostbuf, const secplane_t &plane) { x = curline->v1->x; y = curline->v1->y; - if (WallSX1 == 0 && 0 != (den = WallTX1 - WallTX2 + WallTY1 - WallTY2)) + if (WallC.SX1 == 0 && 0 != (den = WallC.TX1 - WallC.TX2 + WallC.TY1 - WallC.TY2)) { - int frac = SafeDivScale30 (WallTY1 + WallTX1, den); + int frac = SafeDivScale30 (WallC.TY1 + WallC.TX1, den); x += MulScale30 (frac, curline->v2->x - x); y += MulScale30 (frac, curline->v2->y - y); } z1 = viewz - plane.ZatPoint (x, y); - if (WallSX2 > WallSX1 + 1) + if (WallC.SX2 > WallC.SX1 + 1) { x = curline->v2->x; y = curline->v2->y; - if (WallSX2 == viewwidth && 0 != (den = WallTX1 - WallTX2 - WallTY1 + WallTY2)) + if (WallC.SX2 == viewwidth && 0 != (den = WallC.TX1 - WallC.TX2 - WallC.TY1 + WallC.TY2)) { - int frac = SafeDivScale30 (WallTY2 - WallTX2, den); + int frac = SafeDivScale30 (WallC.TY2 - WallC.TX2, den); x -= MulScale30 (frac, x - curline->v1->x); y -= MulScale30 (frac, y - curline->v1->y); } @@ -2789,12 +2778,12 @@ int WallMost (short *mostbuf, const secplane_t &plane) } } - s1 = MulScale12 (globaluclip, WallSZ1); s2 = MulScale12 (globaluclip, WallSZ2); - s3 = MulScale12 (globaldclip, WallSZ1); s4 = MulScale12 (globaldclip, WallSZ2); + s1 = MulScale12 (globaluclip, WallC.SZ1); s2 = MulScale12 (globaluclip, WallC.SZ2); + s3 = MulScale12 (globaldclip, WallC.SZ1); s4 = MulScale12 (globaldclip, WallC.SZ2); bad = (z1s3)<<2)+((z2>s4)<<3); - ix1 = WallSX1; ix2 = WallSX2; - iy1 = WallSZ1; iy2 = WallSZ2; + ix1 = WallC.SX1; ix2 = WallC.SX2; + iy1 = WallC.SZ1; iy2 = WallC.SZ2; oz1 = z1; oz2 = z2; if ((bad&3) == 3) @@ -2814,9 +2803,9 @@ int WallMost (short *mostbuf, const secplane_t &plane) { //inty = intz / (globaluclip>>16) int t = SafeDivScale30 (oz1-s1, s2-s1+oz1-oz2); - int inty = WallSZ1 + MulScale30 (WallSZ2-WallSZ1,t); + int inty = WallC.SZ1 + MulScale30 (WallC.SZ2-WallC.SZ1,t); int intz = oz1 + MulScale30 (oz2-oz1,t); - int xcross = WallSX1 + Scale (MulScale30 (WallSZ2, t), WallSX2-WallSX1, inty); + int xcross = WallC.SX1 + Scale (MulScale30 (WallC.SZ2, t), WallC.SX2-WallC.SX1, inty); //t = divscale30((x1<<4)-xcross*yb1[w],xcross*(yb2[w]-yb1[w])-((x2-x1)<<4)); //inty = yb1[w] + mulscale30(yb2[w]-yb1[w],t); @@ -2824,13 +2813,13 @@ int WallMost (short *mostbuf, const secplane_t &plane) if ((bad&3) == 2) { - if (WallSX1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; } - memset (&mostbuf[xcross], 0, (WallSX2-xcross)*sizeof(mostbuf[0])); + if (WallC.SX1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; } + memset (&mostbuf[xcross], 0, (WallC.SX2-xcross)*sizeof(mostbuf[0])); } else { - if (xcross <= WallSX2) { z1 = intz; iy1 = inty; ix1 = xcross; } - memset (&mostbuf[WallSX1], 0, (xcross-WallSX1)*sizeof(mostbuf[0])); + if (xcross <= WallC.SX2) { z1 = intz; iy1 = inty; ix1 = xcross; } + memset (&mostbuf[WallC.SX1], 0, (xcross-WallC.SX1)*sizeof(mostbuf[0])); } } @@ -2838,9 +2827,9 @@ int WallMost (short *mostbuf, const secplane_t &plane) { //inty = intz / (globaldclip>>16) int t = SafeDivScale30 (oz1-s3, s4-s3+oz1-oz2); - int inty = WallSZ1 + MulScale30 (WallSZ2-WallSZ1,t); + int inty = WallC.SZ1 + MulScale30 (WallC.SZ2-WallC.SZ1,t); int intz = oz1 + MulScale30 (oz2-oz1,t); - int xcross = WallSX1 + Scale (MulScale30 (WallSZ2, t), WallSX2-WallSX1,inty); + int xcross = WallC.SX1 + Scale (MulScale30 (WallC.SZ2, t), WallC.SX2-WallC.SX1,inty); //t = divscale30((x1<<4)-xcross*yb1[w],xcross*(yb2[w]-yb1[w])-((x2-x1)<<4)); //inty = yb1[w] + mulscale30(yb2[w]-yb1[w],t); @@ -2848,13 +2837,13 @@ int WallMost (short *mostbuf, const secplane_t &plane) if ((bad&12) == 8) { - if (WallSX1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; } - if (WallSX2 > xcross) clearbufshort (&mostbuf[xcross], WallSX2-xcross, viewheight); + if (WallC.SX1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; } + if (WallC.SX2 > xcross) clearbufshort (&mostbuf[xcross], WallC.SX2-xcross, viewheight); } else { - if (xcross <= WallSX2) { z1 = intz; iy1 = inty; ix1 = xcross; } - if (xcross > WallSX1) clearbufshort (&mostbuf[WallSX1], xcross-WallSX1, viewheight); + if (xcross <= WallC.SX2) { z1 = intz; iy1 = inty; ix1 = xcross; } + if (xcross > WallC.SX1) clearbufshort (&mostbuf[WallC.SX1], xcross-WallC.SX1, viewheight); } } @@ -2884,9 +2873,9 @@ static void PrepWallRoundFix(fixed_t *lwall, fixed_t walxrepeat) fixed_t fix = (MirrorFlags & RF_XFLIP) ? walxrepeat-1 : 0; int x; - if (WallSX1 > 0) + if (WallC.SX1 > 0) { - for (x = WallSX1; x < WallSX2; x++) + for (x = WallC.SX1; x < WallC.SX2; x++) { if ((unsigned)lwall[x] >= (unsigned)walxrepeat) { @@ -2899,7 +2888,7 @@ static void PrepWallRoundFix(fixed_t *lwall, fixed_t walxrepeat) } } fix = walxrepeat - 1 - fix; - for (x = WallSX2-1; x >= WallSX1; x--) + for (x = WallC.SX2-1; x >= WallC.SX1; x--) { if ((unsigned)lwall[x] >= (unsigned)walxrepeat) { @@ -2917,11 +2906,11 @@ void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat) double top, bot, i; double xrepeat = fabs((double)walxrepeat); - i = WallSX1 - centerx; - top = WallUoverZorg + WallUoverZstep * i; - bot = WallInvZorg + WallInvZstep * i; + i = WallC.SX1 - centerx; + top = WallT.UoverZorg + WallT.UoverZstep * i; + bot = WallT.InvZorg + WallT.InvZstep * i; - for (int x = WallSX1; x < WallSX2; x++) + for (int x = WallC.SX1; x < WallC.SX2; x++) { double frac = top / bot; if (walxrepeat < 0) @@ -2932,9 +2921,9 @@ void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat) { lwall[x] = xs_RoundToInt(frac * xrepeat); } - swall[x] = xs_RoundToInt(frac * WallDepthScale + WallDepthOrg); - top += WallUoverZstep; - bot += WallInvZstep; + swall[x] = xs_RoundToInt(frac * WallT.DepthScale + WallT.DepthOrg); + top += WallT.UoverZstep; + bot += WallT.InvZstep; } PrepWallRoundFix(lwall, walxrepeat); } @@ -2945,14 +2934,14 @@ void PrepLWall (fixed_t *lwall, fixed_t walxrepeat) double xrepeat = fabs((double)walxrepeat); double topstep; - i = WallSX1 - centerx; - top = WallUoverZorg + WallUoverZstep * i; - bot = WallInvZorg + WallInvZstep * i; + i = WallC.SX1 - centerx; + top = WallT.UoverZorg + WallT.UoverZstep * i; + bot = WallT.InvZorg + WallT.InvZstep * i; top *= xrepeat; - topstep = WallUoverZstep * xrepeat; + topstep = WallT.UoverZstep * xrepeat; - for (int x = WallSX1; x < WallSX2; x++) + for (int x = WallC.SX1; x < WallC.SX2; x++) { if (walxrepeat < 0) { @@ -2963,7 +2952,7 @@ void PrepLWall (fixed_t *lwall, fixed_t walxrepeat) lwall[x] = xs_RoundToInt(top / bot); } top += topstep; - bot += WallInvZstep; + bot += WallT.InvZstep; } PrepWallRoundFix(lwall, walxrepeat); } @@ -3044,14 +3033,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, // to a wall, we use the wall's angle instead of the decal's. This is // pretty much the same as what R_AddLine() does. - fixed_t savetx1, savetx2, savety1, savety2, savesz1, savesz2; - - savetx1 = WallTX1; - savetx2 = WallTX2; - savety1 = WallTY1; - savety2 = WallTY2; - savesz1 = WallSZ1; - savesz2 = WallSZ2; + FWallCoords savecoord = WallC; x2 = WallSpriteTile->GetWidth(); x1 = WallSpriteTile->LeftOffset; @@ -3068,76 +3050,76 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, ly = decaly - FixedMul (x1, finesine[ang]) - viewy; ly2 = decaly + FixedMul (x2, finesine[ang]) - viewy; - WallTX1 = DMulScale20 (lx, viewsin, -ly, viewcos); - WallTX2 = DMulScale20 (lx2, viewsin, -ly2, viewcos); + WallC.TX1 = DMulScale20 (lx, viewsin, -ly, viewcos); + WallC.TX2 = DMulScale20 (lx2, viewsin, -ly2, viewcos); - WallTY1 = DMulScale20 (lx, viewtancos, ly, viewtansin); - WallTY2 = DMulScale20 (lx2, viewtancos, ly2, viewtansin); + WallC.TY1 = DMulScale20 (lx, viewtancos, ly, viewtansin); + WallC.TY2 = DMulScale20 (lx2, viewtancos, ly2, viewtansin); if (MirrorFlags & RF_XFLIP) { - int t = 256-WallTX1; - WallTX1 = 256-WallTX2; - WallTX2 = t; - swapvalues (WallTY1, WallTY2); + int t = 256-WallC.TX1; + WallC.TX1 = 256-WallC.TX2; + WallC.TX2 = t; + swapvalues (WallC.TY1, WallC.TY2); } - if (WallTX1 >= -WallTY1) + if (WallC.TX1 >= -WallC.TY1) { - if (WallTX1 > WallTY1) goto done; // left edge is off the right side - if (WallTY1 == 0) goto done; - x1 = (centerxfrac + Scale (WallTX1, centerxfrac, WallTY1)) >> FRACBITS; - if (WallTX1 >= 0) x1 = MIN (viewwidth, x1+1); // fix for signed divide - WallSZ1 = WallTY1; + if (WallC.TX1 > WallC.TY1) goto done; // left edge is off the right side + if (WallC.TY1 == 0) goto done; + x1 = (centerxfrac + Scale (WallC.TX1, centerxfrac, WallC.TY1)) >> FRACBITS; + if (WallC.TX1 >= 0) x1 = MIN (viewwidth, x1+1); // fix for signed divide + WallC.SZ1 = WallC.TY1; } else { - if (WallTX2 < -WallTY2) goto done; // wall is off the left side - fixed_t den = WallTX1 - WallTX2 - WallTY2 + WallTY1; + if (WallC.TX2 < -WallC.TY2) goto done; // wall is off the left side + fixed_t den = WallC.TX1 - WallC.TX2 - WallC.TY2 + WallC.TY1; if (den == 0) goto done; x1 = 0; - WallSZ1 = WallTY1 + Scale (WallTY2 - WallTY1, WallTX1 + WallTY1, den); + WallC.SZ1 = WallC.TY1 + Scale (WallC.TY2 - WallC.TY1, WallC.TX1 + WallC.TY1, den); } - if (WallSZ1 < TOO_CLOSE_Z) + if (WallC.SZ1 < TOO_CLOSE_Z) goto done; - if (WallTX2 <= WallTY2) + if (WallC.TX2 <= WallC.TY2) { - if (WallTX2 < -WallTY2) goto done; // right edge is off the left side - if (WallTY2 == 0) goto done; - x2 = (centerxfrac + Scale (WallTX2, centerxfrac, WallTY2)) >> FRACBITS; - if (WallTX2 >= 0) x2 = MIN (viewwidth, x2+1); // fix for signed divide - WallSZ2 = WallTY2; + if (WallC.TX2 < -WallC.TY2) goto done; // right edge is off the left side + if (WallC.TY2 == 0) goto done; + x2 = (centerxfrac + Scale (WallC.TX2, centerxfrac, WallC.TY2)) >> FRACBITS; + if (WallC.TX2 >= 0) x2 = MIN (viewwidth, x2+1); // fix for signed divide + WallC.SZ2 = WallC.TY2; } else { - if (WallTX1 > WallTY1) goto done; // wall is off the right side - fixed_t den = WallTY2 - WallTY1 - WallTX2 + WallTX1; + if (WallC.TX1 > WallC.TY1) goto done; // wall is off the right side + fixed_t den = WallC.TY2 - WallC.TY1 - WallC.TX2 + WallC.TX1; if (den == 0) goto done; x2 = viewwidth; - WallSZ2 = WallTY1 + Scale (WallTY2 - WallTY1, WallTX1 - WallTY1, den); + WallC.SZ2 = WallC.TY1 + Scale (WallC.TY2 - WallC.TY1, WallC.TX1 - WallC.TY1, den); } - if (x1 >= x2 || x1 > clipper->x2 || x2 <= clipper->x1 || WallSZ2 < TOO_CLOSE_Z) + if (x1 >= x2 || x1 > clipper->x2 || x2 <= clipper->x1 || WallC.SZ2 < TOO_CLOSE_Z) goto done; if (MirrorFlags & RF_XFLIP) { - WallUoverZorg = (float)WallTX2 * WallTMapScale; - WallUoverZstep = (float)(-WallTY2) * 32.f; - WallInvZorg = (float)(WallTX2 - WallTX1) * WallTMapScale; - WallInvZstep = (float)(WallTY1 - WallTY2) * 32.f; + WallT.UoverZorg = (float)WallC.TX2 * WallTMapScale; + WallT.UoverZstep = (float)(-WallC.TY2) * 32.f; + WallT.InvZorg = (float)(WallC.TX2 - WallC.TX1) * WallTMapScale; + WallT.InvZstep = (float)(WallC.TY1 - WallC.TY2) * 32.f; } else { - WallUoverZorg = (float)WallTX1 * WallTMapScale; - WallUoverZstep = (float)(-WallTY1) * 32.f; - WallInvZorg = (float)(WallTX1 - WallTX2) * WallTMapScale; - WallInvZstep = (float)(WallTY2 - WallTY1) * 32.f; + WallT.UoverZorg = (float)WallC.TX1 * WallTMapScale; + WallT.UoverZstep = (float)(-WallC.TY1) * 32.f; + WallT.InvZorg = (float)(WallC.TX1 - WallC.TX2) * WallTMapScale; + WallT.InvZstep = (float)(WallC.TY2 - WallC.TY1) * 32.f; } - WallDepthScale = WallInvZstep * WallTMapScale2; - WallDepthOrg = -WallUoverZstep * WallTMapScale2; + WallT.DepthScale = WallT.InvZstep * WallTMapScale2; + WallT.DepthOrg = -WallT.UoverZstep * WallTMapScale2; // Get the top and bottom clipping arrays switch (decal->RenderFlags & RF_CLIPMASK) @@ -3210,11 +3192,11 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, goto done; } - swapvalues (x1, WallSX1); - swapvalues (x2, WallSX2); + swapvalues (x1, WallC.SX1); + swapvalues (x2, WallC.SX2); PrepWall (swall, lwall, WallSpriteTile->GetWidth() << FRACBITS); - swapvalues (x1, WallSX1); - swapvalues (x2, WallSX2); + swapvalues (x1, WallC.SX1); + swapvalues (x2, WallC.SX2); if (flipx) { @@ -3239,7 +3221,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, rereadcolormap = false; } - rw_light = rw_lightleft + (x1 - WallSX1) * rw_lightstep; + rw_light = rw_lightleft + (x1 - WallC.SX1) * rw_lightstep; if (fixedlightlev >= 0) dc_colormap = usecolormap->Maps + fixedlightlev; else if (fixedcolormap != NULL) @@ -3346,12 +3328,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, R_FinishSetPatchStyle (); done: - WallTX1 = savetx1; - WallTX2 = savetx2; - WallTY1 = savety1; - WallTY2 = savety2; - WallSZ1 = savesz1; - WallSZ2 = savesz2; + WallC = savecoord; } static void WallSpriteColumn (void (*drawfunc)(const BYTE *column, const FTexture::Span *spans)) From fc63e9db3ca384e8d6228d56739f7bc95646ffc8 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 31 Jul 2014 20:23:04 -0500 Subject: [PATCH 19/54] Pass WallC as a parameter to (O)WallMost instead of referencing it globally --- src/r_bsp.cpp | 11 ++-- src/r_segs.cpp | 136 ++++++++++++++++++++++++------------------------- src/r_segs.h | 3 ++ 3 files changed, 75 insertions(+), 75 deletions(-) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index c1ddb2a3c..97938bf79 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -51,13 +51,12 @@ #include "doomstat.h" #include "r_state.h" #include "r_bsp.h" +#include "r_segs.h" #include "v_palette.h" #include "r_sky.h" #include "po_man.h" #include "r_data/colormaps.h" -int WallMost (short *mostbuf, const secplane_t &plane); - seg_t* curline; side_t* sidedef; line_t* linedef; @@ -693,12 +692,12 @@ void R_AddLine (seg_t *line) if (rw_frontcz1 > rw_backcz1 || rw_frontcz2 > rw_backcz2) { rw_havehigh = true; - WallMost (wallupper, backsector->ceilingplane); + WallMost (wallupper, backsector->ceilingplane, &WallC); } if (rw_frontfz1 < rw_backfz1 || rw_frontfz2 < rw_backfz2) { rw_havelow = true; - WallMost (walllower, backsector->floorplane); + WallMost (walllower, backsector->floorplane, &WallC); } // Closed door. @@ -800,8 +799,8 @@ void R_AddLine (seg_t *line) } else { - rw_ceilstat = WallMost (walltop, frontsector->ceilingplane); - rw_floorstat = WallMost (wallbottom, frontsector->floorplane); + rw_ceilstat = WallMost (walltop, frontsector->ceilingplane, &WallC); + rw_floorstat = WallMost (wallbottom, frontsector->floorplane, &WallC); // [RH] treat off-screen walls as solid #if 0 // Maybe later... diff --git a/src/r_segs.cpp b/src/r_segs.cpp index e1896b883..9567e0874 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -86,8 +86,6 @@ fixed_t rw_offset_top; fixed_t rw_offset_mid; fixed_t rw_offset_bottom; -int OWallMost (short *mostbuf, fixed_t z); -int WallMost (short *mostbuf, const secplane_t &plane); void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat); void PrepLWall (fixed_t *lwall, fixed_t walxrepeat); extern FWallCoords WallC; @@ -217,13 +215,13 @@ void ClipMidtex(int x1, int x2) { short most[MAXWIDTH]; - WallMost(most, curline->frontsector->ceilingplane); + WallMost(most, curline->frontsector->ceilingplane, &WallC); for (int i = x1; i <= x2; ++i) { if (wallupper[i] < most[i]) wallupper[i] = most[i]; } - WallMost(most, curline->frontsector->floorplane); + WallMost(most, curline->frontsector->floorplane, &WallC); for (int i = x1; i <= x2; ++i) { if (walllower[i] > most[i]) @@ -395,19 +393,19 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) if (fake3D & FAKE3D_CLIPTOP) { - OWallMost (wallupper, textop < sclipTop - viewz ? textop : sclipTop - viewz); + OWallMost(wallupper, textop < sclipTop - viewz ? textop : sclipTop - viewz, &WallC); } else { - OWallMost (wallupper, textop); + OWallMost(wallupper, textop, &WallC); } if (fake3D & FAKE3D_CLIPBOTTOM) { - OWallMost (walllower, textop - texheight > sclipBottom - viewz ? textop - texheight : sclipBottom - viewz); + OWallMost(walllower, textop - texheight > sclipBottom - viewz ? textop - texheight : sclipBottom - viewz, &WallC); } else { - OWallMost (walllower, textop - texheight); + OWallMost(walllower, textop - texheight, &WallC); } for (i = x1; i <= x2; i++) @@ -497,7 +495,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) if (fake3D & FAKE3D_CLIPTOP) { - OWallMost (wallupper, sclipTop - viewz); + OWallMost(wallupper, sclipTop - viewz, &WallC); for (i = x1; i <= x2; i++) { if (wallupper[i] < mceilingclip[i]) @@ -507,7 +505,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) } if (fake3D & FAKE3D_CLIPBOTTOM) { - OWallMost (walllower, sclipBottom - viewz); + OWallMost(walllower, sclipBottom - viewz, &WallC); for (i = x1; i <= x2; i++) { if (walllower[i] > mfloorclip[i]) @@ -609,8 +607,8 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) WallC.TY2 = ds->cy + ds->cdy; WallT = ds->tmapvals; - OWallMost(wallupper, sclipTop - viewz); - OWallMost(walllower, sclipBottom - viewz); + OWallMost(wallupper, sclipTop - viewz, &WallC); + OWallMost(walllower, sclipBottom - viewz, &WallC); for (i = x1; i <= x2; i++) { @@ -1227,7 +1225,7 @@ void wallscan_striped (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, // kg3D - fake floors instead of zdoom light list for (unsigned int i = 0; i < frontsector->e->XFloor.lightlist.Size(); i++) { - int j = WallMost (most3, frontsector->e->XFloor.lightlist[i].plane); + int j = WallMost (most3, frontsector->e->XFloor.lightlist[i].plane, &WallC); if (j != 3) { for (int j = x1; j <= x2; ++j) @@ -1309,7 +1307,7 @@ void wallscan_np2(int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed dc_texturemid = FixedMul(partition - viewz, yrepeat) + texheight; while (partition > bot) { - int j = OWallMost(most3, partition - viewz); + int j = OWallMost(most3, partition - viewz, &WallC); if (j != 3) { for (int j = x1; j <= x2; ++j) @@ -1333,7 +1331,7 @@ void wallscan_np2(int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed dc_texturemid = FixedMul(partition - viewz, yrepeat) + texheight; while (partition < top) { - int j = OWallMost(most3, partition - viewz); + int j = OWallMost(most3, partition - viewz, &WallC); if (j != 12) { for (int j = x1; j <= x2; ++j) @@ -2052,7 +2050,7 @@ void R_NewWall (bool needlights) // wall but nothing to draw for it. // Recalculate walltop so that the wall is clipped by the back sector's // ceiling instead of the front sector's ceiling. - WallMost (walltop, backsector->ceilingplane); + WallMost (walltop, backsector->ceilingplane, &WallC); } // Putting sky ceilings on the front and back of a line alters the way unpegged // positioning works. @@ -2596,65 +2594,65 @@ void R_StoreWallRange (int start, int stop) ds_p++; } -int OWallMost (short *mostbuf, fixed_t z) +int OWallMost (short *mostbuf, fixed_t z, const FWallCoords *wallc) { int bad, y, ix1, ix2, iy1, iy2; fixed_t s1, s2, s3, s4; z = -(z >> 4); - s1 = MulScale16 (globaluclip, WallC.SZ1); s2 = MulScale16 (globaluclip, WallC.SZ2); - s3 = MulScale16 (globaldclip, WallC.SZ1); s4 = MulScale16 (globaldclip, WallC.SZ2); + s1 = MulScale16 (globaluclip, wallc->SZ1); s2 = MulScale16 (globaluclip, wallc->SZ2); + s3 = MulScale16 (globaldclip, wallc->SZ1); s4 = MulScale16 (globaldclip, wallc->SZ2); bad = (zs3)<<2)+((z>s4)<<3); #if 1 if ((bad&3) == 3) { - memset (&mostbuf[WallC.SX1], 0, (WallC.SX2 - WallC.SX1)*sizeof(mostbuf[0])); + memset (&mostbuf[wallc->SX1], 0, (wallc->SX2 - wallc->SX1)*sizeof(mostbuf[0])); return bad; } if ((bad&12) == 12) { - clearbufshort (&mostbuf[WallC.SX1], WallC.SX2 - WallC.SX1, viewheight); + clearbufshort (&mostbuf[wallc->SX1], wallc->SX2 - wallc->SX1, viewheight); return bad; } #endif - ix1 = WallC.SX1; iy1 = WallC.SZ1; - ix2 = WallC.SX2; iy2 = WallC.SZ2; + ix1 = wallc->SX1; iy1 = wallc->SZ1; + ix2 = wallc->SX2; iy2 = wallc->SZ2; #if 1 if (bad & 3) { int t = DivScale30 (z-s1, s2-s1); - int inty = WallC.SZ1 + MulScale30 (WallC.SZ2 - WallC.SZ1, t); - int xcross = WallC.SX1 + Scale (MulScale30 (WallC.SZ2, t), WallC.SX2 - WallC.SX1, inty); + int inty = wallc->SZ1 + MulScale30 (wallc->SZ2 - wallc->SZ1, t); + int xcross = wallc->SX1 + Scale (MulScale30 (wallc->SZ2, t), wallc->SX2 - wallc->SX1, inty); if ((bad & 3) == 2) { - if (WallC.SX1 <= xcross) { iy2 = inty; ix2 = xcross; } - if (WallC.SX2 > xcross) memset (&mostbuf[xcross], 0, (WallC.SX2-xcross)*sizeof(mostbuf[0])); + if (wallc->SX1 <= xcross) { iy2 = inty; ix2 = xcross; } + if (wallc->SX2 > xcross) memset (&mostbuf[xcross], 0, (wallc->SX2-xcross)*sizeof(mostbuf[0])); } else { - if (xcross <= WallC.SX2) { iy1 = inty; ix1 = xcross; } - if (xcross > WallC.SX1) memset (&mostbuf[WallC.SX1], 0, (xcross-WallC.SX1)*sizeof(mostbuf[0])); + if (xcross <= wallc->SX2) { iy1 = inty; ix1 = xcross; } + if (xcross > wallc->SX1) memset (&mostbuf[wallc->SX1], 0, (xcross-wallc->SX1)*sizeof(mostbuf[0])); } } if (bad & 12) { int t = DivScale30 (z-s3, s4-s3); - int inty = WallC.SZ1 + MulScale30 (WallC.SZ2 - WallC.SZ1, t); - int xcross = WallC.SX1 + Scale (MulScale30 (WallC.SZ2, t), WallC.SX2 - WallC.SX1, inty); + int inty = wallc->SZ1 + MulScale30 (wallc->SZ2 - wallc->SZ1, t); + int xcross = wallc->SX1 + Scale (MulScale30 (wallc->SZ2, t), wallc->SX2 - wallc->SX1, inty); if ((bad & 12) == 8) { - if (WallC.SX1 <= xcross) { iy2 = inty; ix2 = xcross; } - if (WallC.SX2 > xcross) clearbufshort (&mostbuf[xcross], WallC.SX2 - xcross, viewheight); + if (wallc->SX1 <= xcross) { iy2 = inty; ix2 = xcross; } + if (wallc->SX2 > xcross) clearbufshort (&mostbuf[xcross], wallc->SX2 - xcross, viewheight); } else { - if (xcross <= WallC.SX2) { iy1 = inty; ix1 = xcross; } - if (xcross > WallC.SX1) clearbufshort (&mostbuf[WallC.SX1], xcross - WallC.SX1, viewheight); + if (xcross <= wallc->SX2) { iy1 = inty; ix1 = xcross; } + if (xcross > wallc->SX1) clearbufshort (&mostbuf[wallc->SX1], xcross - wallc->SX1, viewheight); } } @@ -2672,12 +2670,12 @@ int OWallMost (short *mostbuf, fixed_t z) double max = viewheight; double zz = z / 65536.0; #if 0 - double z1 = zz * InvZtoScale / WallC.SZ1; - double z2 = zz * InvZtoScale / WallC.SZ2 - z1; - z2 /= (WallC.SX2 - WallC.SX1); + double z1 = zz * InvZtoScale / wallc->SZ1; + double z2 = zz * InvZtoScale / wallc->SZ2 - z1; + z2 /= (wallc->SX2 - wallc->SX1); z1 += centeryfrac / 65536.0; - for (int x = WallC.SX1; x < WallC.SX2; ++x) + for (int x = wallc->SX1; x < wallc->SX2; ++x) { mostbuf[x] = xs_RoundToInt(clamp(z1, 0.0, max)); z1 += z2; @@ -2685,12 +2683,12 @@ int OWallMost (short *mostbuf, fixed_t z) #else double top, bot, i; - i = WallC.SX1 - centerx; + i = wallc->SX1 - centerx; top = WallT.UoverZorg + WallT.UoverZstep * i; bot = WallT.InvZorg + WallT.InvZstep * i; double cy = centeryfrac / 65536.0; - for (int x = WallC.SX1; x < WallC.SX2; x++) + for (int x = wallc->SX1; x < wallc->SX2; x++) { double frac = top / bot; double scale = frac * WallT.DepthScale + WallT.DepthOrg; @@ -2708,11 +2706,11 @@ int OWallMost (short *mostbuf, fixed_t z) return bad; } -int WallMost (short *mostbuf, const secplane_t &plane) +int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) { if ((plane.a | plane.b) == 0) { - return OWallMost (mostbuf, ((plane.c < 0) ? plane.d : -plane.d) - viewz); + return OWallMost (mostbuf, ((plane.c < 0) ? plane.d : -plane.d) - viewz, wallc); } fixed_t x, y, den, z1, z2, oz1, oz2; @@ -2723,21 +2721,21 @@ int WallMost (short *mostbuf, const secplane_t &plane) { x = curline->v2->x; y = curline->v2->y; - if (WallC.SX1 == 0 && 0 != (den = WallC.TX1 - WallC.TX2 + WallC.TY1 - WallC.TY2)) + if (wallc->SX1 == 0 && 0 != (den = wallc->TX1 - wallc->TX2 + wallc->TY1 - wallc->TY2)) { - int frac = SafeDivScale30 (WallC.TY1 + WallC.TX1, den); + int frac = SafeDivScale30 (wallc->TY1 + wallc->TX1, den); x -= MulScale30 (frac, x - curline->v1->x); y -= MulScale30 (frac, y - curline->v1->y); } z1 = viewz - plane.ZatPoint (x, y); - if (WallC.SX2 > WallC.SX1 + 1) + if (wallc->SX2 > wallc->SX1 + 1) { x = curline->v1->x; y = curline->v1->y; - if (WallC.SX2 == viewwidth && 0 != (den = WallC.TX1 - WallC.TX2 - WallC.TY1 + WallC.TY2)) + if (wallc->SX2 == viewwidth && 0 != (den = wallc->TX1 - wallc->TX2 - wallc->TY1 + wallc->TY2)) { - int frac = SafeDivScale30 (WallC.TY2 - WallC.TX2, den); + int frac = SafeDivScale30 (wallc->TY2 - wallc->TX2, den); x += MulScale30 (frac, curline->v2->x - x); y += MulScale30 (frac, curline->v2->y - y); } @@ -2752,21 +2750,21 @@ int WallMost (short *mostbuf, const secplane_t &plane) { x = curline->v1->x; y = curline->v1->y; - if (WallC.SX1 == 0 && 0 != (den = WallC.TX1 - WallC.TX2 + WallC.TY1 - WallC.TY2)) + if (wallc->SX1 == 0 && 0 != (den = wallc->TX1 - wallc->TX2 + wallc->TY1 - wallc->TY2)) { - int frac = SafeDivScale30 (WallC.TY1 + WallC.TX1, den); + int frac = SafeDivScale30 (wallc->TY1 + wallc->TX1, den); x += MulScale30 (frac, curline->v2->x - x); y += MulScale30 (frac, curline->v2->y - y); } z1 = viewz - plane.ZatPoint (x, y); - if (WallC.SX2 > WallC.SX1 + 1) + if (wallc->SX2 > wallc->SX1 + 1) { x = curline->v2->x; y = curline->v2->y; - if (WallC.SX2 == viewwidth && 0 != (den = WallC.TX1 - WallC.TX2 - WallC.TY1 + WallC.TY2)) + if (wallc->SX2 == viewwidth && 0 != (den = wallc->TX1 - wallc->TX2 - wallc->TY1 + wallc->TY2)) { - int frac = SafeDivScale30 (WallC.TY2 - WallC.TX2, den); + int frac = SafeDivScale30 (wallc->TY2 - wallc->TX2, den); x -= MulScale30 (frac, x - curline->v1->x); y -= MulScale30 (frac, y - curline->v1->y); } @@ -2778,12 +2776,12 @@ int WallMost (short *mostbuf, const secplane_t &plane) } } - s1 = MulScale12 (globaluclip, WallC.SZ1); s2 = MulScale12 (globaluclip, WallC.SZ2); - s3 = MulScale12 (globaldclip, WallC.SZ1); s4 = MulScale12 (globaldclip, WallC.SZ2); + s1 = MulScale12 (globaluclip, wallc->SZ1); s2 = MulScale12 (globaluclip, wallc->SZ2); + s3 = MulScale12 (globaldclip, wallc->SZ1); s4 = MulScale12 (globaldclip, wallc->SZ2); bad = (z1s3)<<2)+((z2>s4)<<3); - ix1 = WallC.SX1; ix2 = WallC.SX2; - iy1 = WallC.SZ1; iy2 = WallC.SZ2; + ix1 = wallc->SX1; ix2 = wallc->SX2; + iy1 = wallc->SZ1; iy2 = wallc->SZ2; oz1 = z1; oz2 = z2; if ((bad&3) == 3) @@ -2803,9 +2801,9 @@ int WallMost (short *mostbuf, const secplane_t &plane) { //inty = intz / (globaluclip>>16) int t = SafeDivScale30 (oz1-s1, s2-s1+oz1-oz2); - int inty = WallC.SZ1 + MulScale30 (WallC.SZ2-WallC.SZ1,t); + int inty = wallc->SZ1 + MulScale30 (wallc->SZ2-wallc->SZ1,t); int intz = oz1 + MulScale30 (oz2-oz1,t); - int xcross = WallC.SX1 + Scale (MulScale30 (WallC.SZ2, t), WallC.SX2-WallC.SX1, inty); + int xcross = wallc->SX1 + Scale (MulScale30 (wallc->SZ2, t), wallc->SX2-wallc->SX1, inty); //t = divscale30((x1<<4)-xcross*yb1[w],xcross*(yb2[w]-yb1[w])-((x2-x1)<<4)); //inty = yb1[w] + mulscale30(yb2[w]-yb1[w],t); @@ -2813,13 +2811,13 @@ int WallMost (short *mostbuf, const secplane_t &plane) if ((bad&3) == 2) { - if (WallC.SX1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; } - memset (&mostbuf[xcross], 0, (WallC.SX2-xcross)*sizeof(mostbuf[0])); + if (wallc->SX1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; } + memset (&mostbuf[xcross], 0, (wallc->SX2-xcross)*sizeof(mostbuf[0])); } else { - if (xcross <= WallC.SX2) { z1 = intz; iy1 = inty; ix1 = xcross; } - memset (&mostbuf[WallC.SX1], 0, (xcross-WallC.SX1)*sizeof(mostbuf[0])); + if (xcross <= wallc->SX2) { z1 = intz; iy1 = inty; ix1 = xcross; } + memset (&mostbuf[wallc->SX1], 0, (xcross-wallc->SX1)*sizeof(mostbuf[0])); } } @@ -2827,9 +2825,9 @@ int WallMost (short *mostbuf, const secplane_t &plane) { //inty = intz / (globaldclip>>16) int t = SafeDivScale30 (oz1-s3, s4-s3+oz1-oz2); - int inty = WallC.SZ1 + MulScale30 (WallC.SZ2-WallC.SZ1,t); + int inty = wallc->SZ1 + MulScale30 (wallc->SZ2-wallc->SZ1,t); int intz = oz1 + MulScale30 (oz2-oz1,t); - int xcross = WallC.SX1 + Scale (MulScale30 (WallC.SZ2, t), WallC.SX2-WallC.SX1,inty); + int xcross = wallc->SX1 + Scale (MulScale30 (wallc->SZ2, t), wallc->SX2-wallc->SX1,inty); //t = divscale30((x1<<4)-xcross*yb1[w],xcross*(yb2[w]-yb1[w])-((x2-x1)<<4)); //inty = yb1[w] + mulscale30(yb2[w]-yb1[w],t); @@ -2837,13 +2835,13 @@ int WallMost (short *mostbuf, const secplane_t &plane) if ((bad&12) == 8) { - if (WallC.SX1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; } - if (WallC.SX2 > xcross) clearbufshort (&mostbuf[xcross], WallC.SX2-xcross, viewheight); + if (wallc->SX1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; } + if (wallc->SX2 > xcross) clearbufshort (&mostbuf[xcross], wallc->SX2-xcross, viewheight); } else { - if (xcross <= WallC.SX2) { z1 = intz; iy1 = inty; ix1 = xcross; } - if (xcross > WallC.SX1) clearbufshort (&mostbuf[WallC.SX1], xcross-WallC.SX1, viewheight); + if (xcross <= wallc->SX2) { z1 = intz; iy1 = inty; ix1 = xcross; } + if (xcross > wallc->SX1) clearbufshort (&mostbuf[wallc->SX1], xcross-wallc->SX1, viewheight); } } diff --git a/src/r_segs.h b/src/r_segs.h index d46a3a523..838b019a9 100644 --- a/src/r_segs.h +++ b/src/r_segs.h @@ -31,6 +31,9 @@ extern short *openings; extern ptrdiff_t lastopening; extern size_t maxopenings; +int OWallMost (short *mostbuf, fixed_t z, const FWallCoords *wallc); +int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc); + ptrdiff_t R_NewOpening (ptrdiff_t len); void R_CheckDrawSegs (); From b0b9c57e8525bdfb2a0cb8d5c152168c8b52ca96 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 31 Jul 2014 20:32:21 -0500 Subject: [PATCH 20/54] Pass x1 and x2 to Prep(L)Wall as params --- src/r_segs.cpp | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 9567e0874..b2a5d930f 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -86,8 +86,8 @@ fixed_t rw_offset_top; fixed_t rw_offset_mid; fixed_t rw_offset_bottom; -void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat); -void PrepLWall (fixed_t *lwall, fixed_t walxrepeat); +void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat, int x1, int x2); +void PrepLWall (fixed_t *lwall, fixed_t walxrepeat, int x1, int x2); extern FWallCoords WallC; extern FWallTmapVals WallT; @@ -621,7 +621,7 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) walllower[i] = mfloorclip[i]; } - PrepLWall (lwall, curline->sidedef->TexelLength*xscale); + PrepLWall (lwall, curline->sidedef->TexelLength*xscale, ds->sx1, ds->sx2); wallscan_np2_ds(ds, x1, x2, wallupper, walllower, MaskedSWall, lwall, yscale); R_FinishSetPatchStyle(); } @@ -1831,7 +1831,7 @@ void R_RenderSegLoop () yscale = FixedMul(rw_pic->yScale, rw_midtexturescaley); if (xscale != lwallscale) { - PrepLWall (lwall, curline->sidedef->TexelLength*xscale); + PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.SX1, WallC.SX2); lwallscale = xscale; } if (midtexture->bWorldPanning) @@ -1874,7 +1874,7 @@ void R_RenderSegLoop () yscale = FixedMul(rw_pic->yScale, rw_toptexturescaley); if (xscale != lwallscale) { - PrepLWall (lwall, curline->sidedef->TexelLength*xscale); + PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.SX1, WallC.SX2); lwallscale = xscale; } if (toptexture->bWorldPanning) @@ -1920,7 +1920,7 @@ void R_RenderSegLoop () yscale = FixedMul(rw_pic->yScale, rw_bottomtexturescaley); if (xscale != lwallscale) { - PrepLWall (lwall, curline->sidedef->TexelLength*xscale); + PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.SX1, WallC.SX2); lwallscale = xscale; } if (bottomtexture->bWorldPanning) @@ -2265,7 +2265,7 @@ void R_NewWall (bool needlights) bottomtexture ? FixedMul(bottomtexture->xScale, sidedef->GetTextureXScale(side_t::bottom)) : FRACUNIT; - PrepWall (swall, lwall, sidedef->TexelLength * lwallscale); + PrepWall (swall, lwall, sidedef->TexelLength * lwallscale, WallC.SX1, WallC.SX2); if (fixedcolormap == NULL && fixedlightlev < 0) { @@ -2864,16 +2864,16 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) return bad; } -static void PrepWallRoundFix(fixed_t *lwall, fixed_t walxrepeat) +static void PrepWallRoundFix(fixed_t *lwall, fixed_t walxrepeat, int x1, int x2) { // fix for rounding errors walxrepeat = abs(walxrepeat); fixed_t fix = (MirrorFlags & RF_XFLIP) ? walxrepeat-1 : 0; int x; - if (WallC.SX1 > 0) + if (x1 > 0) { - for (x = WallC.SX1; x < WallC.SX2; x++) + for (x = x1; x < x2; x++) { if ((unsigned)lwall[x] >= (unsigned)walxrepeat) { @@ -2886,7 +2886,7 @@ static void PrepWallRoundFix(fixed_t *lwall, fixed_t walxrepeat) } } fix = walxrepeat - 1 - fix; - for (x = WallC.SX2-1; x >= WallC.SX1; x--) + for (x = x2-1; x >= x1; x--) { if ((unsigned)lwall[x] >= (unsigned)walxrepeat) { @@ -2899,16 +2899,16 @@ static void PrepWallRoundFix(fixed_t *lwall, fixed_t walxrepeat) } } -void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat) +void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat, int x1, int x2) { // swall = scale, lwall = texturecolumn double top, bot, i; double xrepeat = fabs((double)walxrepeat); - i = WallC.SX1 - centerx; + i = x1 - centerx; top = WallT.UoverZorg + WallT.UoverZstep * i; bot = WallT.InvZorg + WallT.InvZstep * i; - for (int x = WallC.SX1; x < WallC.SX2; x++) + for (int x = x1; x < x2; x++) { double frac = top / bot; if (walxrepeat < 0) @@ -2923,23 +2923,23 @@ void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat) top += WallT.UoverZstep; bot += WallT.InvZstep; } - PrepWallRoundFix(lwall, walxrepeat); + PrepWallRoundFix(lwall, walxrepeat, x1, x2); } -void PrepLWall (fixed_t *lwall, fixed_t walxrepeat) +void PrepLWall (fixed_t *lwall, fixed_t walxrepeat, int x1, int x2) { // lwall = texturecolumn double top, bot, i; double xrepeat = fabs((double)walxrepeat); double topstep; - i = WallC.SX1 - centerx; + i = x1 - centerx; top = WallT.UoverZorg + WallT.UoverZstep * i; bot = WallT.InvZorg + WallT.InvZstep * i; top *= xrepeat; topstep = WallT.UoverZstep * xrepeat; - for (int x = WallC.SX1; x < WallC.SX2; x++) + for (int x = x1; x < x2; x++) { if (walxrepeat < 0) { @@ -2952,7 +2952,7 @@ void PrepLWall (fixed_t *lwall, fixed_t walxrepeat) top += topstep; bot += WallT.InvZstep; } - PrepWallRoundFix(lwall, walxrepeat); + PrepWallRoundFix(lwall, walxrepeat, x1, x2); } // pass = 0: when seg is first drawn @@ -3190,11 +3190,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, goto done; } - swapvalues (x1, WallC.SX1); - swapvalues (x2, WallC.SX2); - PrepWall (swall, lwall, WallSpriteTile->GetWidth() << FRACBITS); - swapvalues (x1, WallC.SX1); - swapvalues (x2, WallC.SX2); + PrepWall (swall, lwall, WallSpriteTile->GetWidth() << FRACBITS, x1, x2); if (flipx) { From a600a816c3587db91a06b71ec3cbff6b40f4360c Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 31 Jul 2014 21:02:22 -0500 Subject: [PATCH 21/54] Consolidate some common code for texture mapping setup - R_AddLine() and R_RenderDecal() had nearly identical code for setting up texture mapping. These have now been spun off into methods of FWallCoords and FWallTmapVals. --- src/r_bsp.cpp | 199 +++++++++++++++++++++++++++---------------------- src/r_bsp.h | 6 ++ src/r_segs.cpp | 70 ++--------------- 3 files changed, 122 insertions(+), 153 deletions(-) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 97938bf79..02a89f371 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -538,58 +538,7 @@ void R_AddLine (seg_t *line) if (DMulScale32 (ty1, tx1-tx2, tx1, ty2-ty1) >= 0) return; - WallC.TX1 = DMulScale20 (tx1, viewsin, -ty1, viewcos); - WallC.TX2 = DMulScale20 (tx2, viewsin, -ty2, viewcos); - - WallC.TY1 = DMulScale20 (tx1, viewtancos, ty1, viewtansin); - WallC.TY2 = DMulScale20 (tx2, viewtancos, ty2, viewtansin); - - if (MirrorFlags & RF_XFLIP) - { - int t = 256-WallC.TX1; - WallC.TX1 = 256-WallC.TX2; - WallC.TX2 = t; - swapvalues (WallC.TY1, WallC.TY2); - } - - if (WallC.TX1 >= -WallC.TY1) - { - if (WallC.TX1 > WallC.TY1) return; // left edge is off the right side - if (WallC.TY1 == 0) return; - WallC.SX1 = (centerxfrac + Scale (WallC.TX1, centerxfrac, WallC.TY1)) >> FRACBITS; - if (WallC.TX1 >= 0) WallC.SX1 = MIN (viewwidth, WallC.SX1+1); // fix for signed divide - WallC.SZ1 = WallC.TY1; - } - else - { - if (WallC.TX2 < -WallC.TY2) return; // wall is off the left side - fixed_t den = WallC.TX1 - WallC.TX2 - WallC.TY2 + WallC.TY1; - if (den == 0) return; - WallC.SX1 = 0; - WallC.SZ1 = WallC.TY1 + Scale (WallC.TY2 - WallC.TY1, WallC.TX1 + WallC.TY1, den); - } - - if (WallC.SZ1 < 32) - return; - - if (WallC.TX2 <= WallC.TY2) - { - if (WallC.TX2 < -WallC.TY2) return; // right edge is off the left side - if (WallC.TY2 == 0) return; - WallC.SX2 = (centerxfrac + Scale (WallC.TX2, centerxfrac, WallC.TY2)) >> FRACBITS; - if (WallC.TX2 >= 0) WallC.SX2 = MIN (viewwidth, WallC.SX2+1); // fix for signed divide - WallC.SZ2 = WallC.TY2; - } - else - { - if (WallC.TX1 > WallC.TY1) return; // wall is off the right side - fixed_t den = WallC.TY2 - WallC.TY1 - WallC.TX2 + WallC.TX1; - if (den == 0) return; - WallC.SX2 = viewwidth; - WallC.SZ2 = WallC.TY1 + Scale (WallC.TY2 - WallC.TY1, WallC.TX1 - WallC.TY1, den); - } - - if (WallC.SZ2 < 32 || WallC.SX2 <= WallC.SX1) + if (WallC.Init(tx1, ty1, tx2, ty2, 32)) return; if (WallC.SX1 > WindowRight || WallC.SX2 < WindowLeft) @@ -611,20 +560,7 @@ void R_AddLine (seg_t *line) if ((v1 == line->v1 && v2 == line->v2) || (v2 == line->v1 && v1 == line->v2)) { // The seg is the entire wall. - if (MirrorFlags & RF_XFLIP) - { - WallT.UoverZorg = (float)WallC.TX2 * WallTMapScale; - WallT.UoverZstep = (float)(-WallC.TY2) * 32.f; - WallT.InvZorg = (float)(WallC.TX2 - WallC.TX1) * WallTMapScale; - WallT.InvZstep = (float)(WallC.TY1 - WallC.TY2) * 32.f; - } - else - { - WallT.UoverZorg = (float)WallC.TX1 * WallTMapScale; - WallT.UoverZstep = (float)(-WallC.TY1) * 32.f; - WallT.InvZorg = (float)(WallC.TX1 - WallC.TX2) * WallTMapScale; - WallT.InvZstep = (float)(WallC.TY2 - WallC.TY1) * 32.f; - } + WallT.InitFromWallCoords(&WallC); } else { // The seg is only part of the wall. @@ -632,29 +568,8 @@ void R_AddLine (seg_t *line) { swapvalues (v1, v2); } - tx1 = v1->x - viewx; - tx2 = v2->x - viewx; - ty1 = v1->y - viewy; - ty2 = v2->y - viewy; - - fixed_t fullx1 = DMulScale20 (tx1, viewsin, -ty1, viewcos); - fixed_t fullx2 = DMulScale20 (tx2, viewsin, -ty2, viewcos); - fixed_t fully1 = DMulScale20 (tx1, viewtancos, ty1, viewtansin); - fixed_t fully2 = DMulScale20 (tx2, viewtancos, ty2, viewtansin); - - if (MirrorFlags & RF_XFLIP) - { - fullx1 = -fullx1; - fullx2 = -fullx2; - } - - WallT.UoverZorg = (float)fullx1 * WallTMapScale; - WallT.UoverZstep = (float)(-fully1) * 32.f; - WallT.InvZorg = (float)(fullx1 - fullx2) * WallTMapScale; - WallT.InvZstep = (float)(fully2 - fully1) * 32.f; + WallT.InitFromLine(v1->x - viewx, v1->y - viewy, v2->x - viewx, v2->y - viewy); } - WallT.DepthScale = WallT.InvZstep * WallTMapScale2; - WallT.DepthOrg = -WallT.UoverZstep * WallTMapScale2; if (!(fake3D & FAKE3D_FAKEBACK)) { @@ -826,6 +741,114 @@ void R_AddLine (seg_t *line) } } +// +// FWallCoords :: Init +// +// Transform and clip coordinates. Returns true if it was clipped away +// +bool FWallCoords::Init(int x1, int y1, int x2, int y2, int too_close) +{ + TX1 = DMulScale20(x1, viewsin, -y1, viewcos); + TX2 = DMulScale20(x2, viewsin, -y2, viewcos); + + TY1 = DMulScale20(x1, viewtancos, y1, viewtansin); + TY2 = DMulScale20(x2, viewtancos, y2, viewtansin); + + if (MirrorFlags & RF_XFLIP) + { + int t = 256 - TX1; + TX1 = 256 - TX2; + TX2 = t; + swapvalues(TY1, TY2); + } + + if (TX1 >= -TY1) + { + if (TX1 > TY1) return true; // left edge is off the right side + if (TY1 == 0) return true; + SX1 = (centerxfrac + Scale(TX1, centerxfrac, TY1)) >> FRACBITS; + if (TX1 >= 0) SX1 = MIN(viewwidth, SX1+1); // fix for signed divide + SZ1 = TY1; + } + else + { + if (TX2 < -TY2) return true; // wall is off the left side + fixed_t den = TX1 - TX2 - TY2 + TY1; + if (den == 0) return true; + SX1 = 0; + SZ1 = TY1 + Scale(TY2 - TY1, TX1 + TY1, den); + } + + if (SZ1 < too_close) + return true; + + if (TX2 <= TY2) + { + if (TX2 < -TY2) return true; // right edge is off the left side + if (TY2 == 0) return true; + SX2 = (centerxfrac + Scale(TX2, centerxfrac, TY2)) >> FRACBITS; + if (TX2 >= 0) SX2 = MIN(viewwidth, SX2+1); // fix for signed divide + SZ2 = TY2; + } + else + { + if (TX1 > TY1) return true; // wall is off the right side + fixed_t den = TY2 - TY1 - TX2 + TX1; + if (den == 0) return true; + SX2 = viewwidth; + SZ2 = TY1 + Scale(TY2 - TY1, TX1 - TY1, den); + } + + if (SZ2 < too_close || SX2 <= SX1) + return true; + + return false; +} + +void FWallTmapVals::InitFromWallCoords(const FWallCoords *wallc) +{ + if (MirrorFlags & RF_XFLIP) + { + UoverZorg = (float)wallc->TX2 * WallTMapScale; + UoverZstep = (float)(-wallc->TY2) * 32.f; + InvZorg = (float)(wallc->TX2 - wallc->TX1) * WallTMapScale; + InvZstep = (float)(wallc->TY1 - wallc->TY2) * 32.f; + } + else + { + UoverZorg = (float)wallc->TX1 * WallTMapScale; + UoverZstep = (float)(-wallc->TY1) * 32.f; + InvZorg = (float)(wallc->TX1 - wallc->TX2) * WallTMapScale; + InvZstep = (float)(wallc->TY2 - wallc->TY1) * 32.f; + } + InitDepth(); +} + +void FWallTmapVals::InitFromLine(int tx1, int ty1, int tx2, int ty2) +{ // Coordinates should have already had viewx,viewy subtracted + fixed_t fullx1 = DMulScale20 (tx1, viewsin, -ty1, viewcos); + fixed_t fullx2 = DMulScale20 (tx2, viewsin, -ty2, viewcos); + fixed_t fully1 = DMulScale20 (tx1, viewtancos, ty1, viewtansin); + fixed_t fully2 = DMulScale20 (tx2, viewtancos, ty2, viewtansin); + + if (MirrorFlags & RF_XFLIP) + { + fullx1 = -fullx1; + fullx2 = -fullx2; + } + + UoverZorg = (float)fullx1 * WallTMapScale; + UoverZstep = (float)(-fully1) * 32.f; + InvZorg = (float)(fullx1 - fullx2) * WallTMapScale; + InvZstep = (float)(fully2 - fully1) * 32.f; + InitDepth(); +} + +void FWallTmapVals::InitDepth() +{ + DepthScale = InvZstep * WallTMapScale2; + DepthOrg = -UoverZstep * WallTMapScale2; +} // // R_CheckBBox diff --git a/src/r_bsp.h b/src/r_bsp.h index d2fcb67e1..53a0b2b0b 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -36,6 +36,8 @@ struct FWallCoords int SX1, SX2; // x coords at left, right of wall in screen space fixed_t SZ1, SZ2; // depth at left, right of wall in screen space + + bool Init(int x1, int y1, int x2, int y2, int too_close); }; struct FWallTmapVals @@ -43,6 +45,10 @@ struct FWallTmapVals float DepthOrg, DepthScale; float UoverZorg, UoverZstep; float InvZorg, InvZstep; + + void InitFromWallCoords(const FWallCoords *wallc); + void InitFromLine(int x1, int y1, int x2, int y2); + void InitDepth(); }; enum diff --git a/src/r_segs.cpp b/src/r_segs.cpp index b2a5d930f..f985a732d 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -3048,76 +3048,16 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, ly = decaly - FixedMul (x1, finesine[ang]) - viewy; ly2 = decaly + FixedMul (x2, finesine[ang]) - viewy; - WallC.TX1 = DMulScale20 (lx, viewsin, -ly, viewcos); - WallC.TX2 = DMulScale20 (lx2, viewsin, -ly2, viewcos); - - WallC.TY1 = DMulScale20 (lx, viewtancos, ly, viewtansin); - WallC.TY2 = DMulScale20 (lx2, viewtancos, ly2, viewtansin); - - if (MirrorFlags & RF_XFLIP) - { - int t = 256-WallC.TX1; - WallC.TX1 = 256-WallC.TX2; - WallC.TX2 = t; - swapvalues (WallC.TY1, WallC.TY2); - } - - if (WallC.TX1 >= -WallC.TY1) - { - if (WallC.TX1 > WallC.TY1) goto done; // left edge is off the right side - if (WallC.TY1 == 0) goto done; - x1 = (centerxfrac + Scale (WallC.TX1, centerxfrac, WallC.TY1)) >> FRACBITS; - if (WallC.TX1 >= 0) x1 = MIN (viewwidth, x1+1); // fix for signed divide - WallC.SZ1 = WallC.TY1; - } - else - { - if (WallC.TX2 < -WallC.TY2) goto done; // wall is off the left side - fixed_t den = WallC.TX1 - WallC.TX2 - WallC.TY2 + WallC.TY1; - if (den == 0) goto done; - x1 = 0; - WallC.SZ1 = WallC.TY1 + Scale (WallC.TY2 - WallC.TY1, WallC.TX1 + WallC.TY1, den); - } - - if (WallC.SZ1 < TOO_CLOSE_Z) + if (WallC.Init(lx, ly, lx2, ly2, TOO_CLOSE_Z)) goto done; - if (WallC.TX2 <= WallC.TY2) - { - if (WallC.TX2 < -WallC.TY2) goto done; // right edge is off the left side - if (WallC.TY2 == 0) goto done; - x2 = (centerxfrac + Scale (WallC.TX2, centerxfrac, WallC.TY2)) >> FRACBITS; - if (WallC.TX2 >= 0) x2 = MIN (viewwidth, x2+1); // fix for signed divide - WallC.SZ2 = WallC.TY2; - } - else - { - if (WallC.TX1 > WallC.TY1) goto done; // wall is off the right side - fixed_t den = WallC.TY2 - WallC.TY1 - WallC.TX2 + WallC.TX1; - if (den == 0) goto done; - x2 = viewwidth; - WallC.SZ2 = WallC.TY1 + Scale (WallC.TY2 - WallC.TY1, WallC.TX1 - WallC.TY1, den); - } + x1 = WallC.SX1; + x2 = WallC.SX2; - if (x1 >= x2 || x1 > clipper->x2 || x2 <= clipper->x1 || WallC.SZ2 < TOO_CLOSE_Z) + if (x1 > clipper->x2 || x2 <= clipper->x1) goto done; - if (MirrorFlags & RF_XFLIP) - { - WallT.UoverZorg = (float)WallC.TX2 * WallTMapScale; - WallT.UoverZstep = (float)(-WallC.TY2) * 32.f; - WallT.InvZorg = (float)(WallC.TX2 - WallC.TX1) * WallTMapScale; - WallT.InvZstep = (float)(WallC.TY1 - WallC.TY2) * 32.f; - } - else - { - WallT.UoverZorg = (float)WallC.TX1 * WallTMapScale; - WallT.UoverZstep = (float)(-WallC.TY1) * 32.f; - WallT.InvZorg = (float)(WallC.TX1 - WallC.TX2) * WallTMapScale; - WallT.InvZstep = (float)(WallC.TY2 - WallC.TY1) * 32.f; - } - WallT.DepthScale = WallT.InvZstep * WallTMapScale2; - WallT.DepthOrg = -WallT.UoverZstep * WallTMapScale2; + WallT.InitFromWallCoords(&WallC); // Get the top and bottom clipping arrays switch (decal->RenderFlags & RF_CLIPMASK) From 15251e7a2167ab4e8ff54f6a9a9910ccf3140f7a Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 31 Jul 2014 22:18:08 -0500 Subject: [PATCH 22/54] Set face/wall/floor flags from Build sprites --- src/p_buildmap.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index 54bf92527..32651b5bb 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -732,11 +732,10 @@ static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites, if (sprites[i].xrepeat == 0 || sprites[i].yrepeat == 0) continue; mapthings[count].type = 9988; - mapthings[count].args[0] = sprites[i].picnum & 255; - mapthings[count].args[1] = sprites[i].picnum >> 8; + mapthings[count].args[0] = sprites[i].picnum; mapthings[count].args[2] = sprites[i].xrepeat; mapthings[count].args[3] = sprites[i].yrepeat; - mapthings[count].args[4] = (sprites[i].cstat & 14) | ((sprites[i].cstat >> 9) & 1); + mapthings[count].args[4] = sprites[i].cstat; } count++; } @@ -874,22 +873,22 @@ void ACustomSprite::BeginPlay () char name[9]; Super::BeginPlay (); - mysnprintf (name, countof(name), "BTIL%04d", (args[0] + args[1]*256) & 0xffff); + mysnprintf (name, countof(name), "BTIL%04d", args[0] & 0xffff); picnum = TexMan.GetTexture (name, FTexture::TEX_Build); scaleX = args[2] * (FRACUNIT/64); scaleY = args[3] * (FRACUNIT/64); - if (args[4] & 2) + int cstat = args[4]; + if (cstat & 2) { RenderStyle = STYLE_Translucent; - if (args[4] & 1) - alpha = TRANSLUC66; - else - alpha = TRANSLUC33; + alpha = (cstat & 512) ? TRANSLUC66 : TRANSLUC33; } - if (args[4] & 4) + if (cstat & 4) renderflags |= RF_XFLIP; - if (args[4] & 8) + if (cstat & 8) renderflags |= RF_YFLIP; + // set face/wall/floor flags + renderflags |= ((cstat >> 4) & 3) << 12; } From 9716a61219d7cd26225ccbf18605bd2766a29632 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Sat, 2 Aug 2014 19:32:38 +1200 Subject: [PATCH 23/54] Add CVar for drawing weapons in the althud --- src/g_shared/shared_hud.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index 964a28e2b..3806e5f9d 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -70,6 +70,7 @@ CVAR (Bool, hud_showmonsters, true,CVAR_ARCHIVE); // Show monster stats on HUD CVAR (Bool, hud_showitems, false,CVAR_ARCHIVE); // Show item stats on HUD CVAR (Bool, hud_showstats, false, CVAR_ARCHIVE); // for stamina and accuracy. CVAR (Bool, hud_showscore, false, CVAR_ARCHIVE); // for user maintained score +CVAR (Bool, hud_showweapons, true, CVAR_ARCHIVE); // Show weapons collected CVAR (Int , hud_showtime, 0, CVAR_ARCHIVE); // Show time on HUD CVAR (Int , hud_timecolor, CR_GOLD,CVAR_ARCHIVE); // Color of in-game time on HUD @@ -972,7 +973,7 @@ void DrawHUD() CPlayer->mo->FindInventory(), 5, hudheight-20); i=DrawKeys(CPlayer, hudwidth-4, hudheight-10); i=DrawAmmo(CPlayer, hudwidth-5, i); - DrawWeapons(CPlayer, hudwidth-5, i); + if (hud_showweapons) DrawWeapons(CPlayer, hudwidth - 5, i); DrawInventory(CPlayer, 144, hudheight-28); if (CPlayer->camera && CPlayer->camera->player) { From 6ef67e1d3e078c193245e3d9bc96e1931704d4f6 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 2 Aug 2014 13:14:25 +0300 Subject: [PATCH 24/54] Fixed build on compilers other than MSVC No more "Call to 'LittleShort' is ambiguous" error --- src/p_acs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 16e511b23..2ca6fe909 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -1677,7 +1677,7 @@ 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; + unsigned count = (LittleShort(static_cast(((unsigned *)chunk)[1]) - 2)) / 4; int *sizes = (int *)((BYTE *)chunk + 10); arrays->Count = count; if (count > 0) From a1b579e5fccd16b7aaf73d0bb0c8c4018fc11830 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Aug 2014 01:20:12 +0200 Subject: [PATCH 25/54] - added menu entry for newly added hud_showweapons CVAR. --- wadsrc/static/menudef.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 7099e6cc7..324c94e6b 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -816,6 +816,7 @@ OptionMenu "AltHUDOptions" Option "Show item count", "hud_showitems", "OnOff" Option "Show stamina and accuracy", "hud_showstats", "OnOff" Option "Show berserk", "hud_berserk_health", "OnOff" + Option "Show weapons", "hud_showweapons", "OnOff" Option "Show time", "hud_showtime", "AltHUDTime" Option "Time color", "hud_timecolor", "TextColors" Slider "Red ammo display below %", "hud_ammo_red", 0, 100, 1, 0 From d0043bed78082c7faf749236c9939d90a081b25e Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 2 Aug 2014 22:35:57 -0500 Subject: [PATCH 26/54] Q&D port of decal code to draw generic wall sprites - This still doesn't use all the sprite properties correctly. It also looks like they're going to need different code to build the clipping arrays. But at least wall sprites are drawn at the proper angle now! --- src/r_bsp.h | 8 ++ src/r_segs.cpp | 36 +------ src/r_segs.h | 9 ++ src/r_things.cpp | 252 +++++++++++++++++++++++++++++++++++++++++++++-- src/r_things.h | 21 +++- 5 files changed, 279 insertions(+), 47 deletions(-) diff --git a/src/r_bsp.h b/src/r_bsp.h index 53a0b2b0b..d15beca0c 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -26,6 +26,11 @@ #include "tarray.h" #include +// The 3072 below is just an arbitrary value picked to avoid +// drawing lines the player is too close to that would overflow +// the texture calculations. +#define TOO_CLOSE_Z 3072 + struct FWallCoords { fixed_t TX1, TX2; // x coords at left, right of wall in view space @@ -51,6 +56,9 @@ struct FWallTmapVals void InitDepth(); }; +extern FWallCoords WallC; +extern FWallTmapVals WallT; + enum { FAKED_Center, diff --git a/src/r_segs.cpp b/src/r_segs.cpp index f985a732d..25395a596 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -64,11 +64,6 @@ CVAR(Bool, r_np2, true, 0) #define HEIGHTBITS 12 #define HEIGHTSHIFT (FRACBITS-HEIGHTBITS) -// The 3072 below is just an arbitrary value picked to avoid -// drawing lines the player is too close to that would overflow -// the texture calculations. -#define TOO_CLOSE_Z 3072 - extern fixed_t globaluclip, globaldclip; @@ -86,10 +81,6 @@ fixed_t rw_offset_top; fixed_t rw_offset_mid; fixed_t rw_offset_bottom; -void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat, int x1, int x2); -void PrepLWall (fixed_t *lwall, fixed_t walxrepeat, int x1, int x2); -extern FWallCoords WallC; -extern FWallTmapVals WallT; int wallshade; @@ -139,7 +130,6 @@ static fixed_t rw_bottomtexturescaley; FTexture *rw_pic; static fixed_t *maskedtexturecol; -static FTexture *WallSpriteTile; static void R_RenderDecal (side_t *wall, DBaseDecal *first, drawseg_t *clipper, int pass); static void WallSpriteColumn (void (*drawfunc)(const BYTE *column, const FTexture::Span *spans)); @@ -3216,8 +3206,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { // calculate lighting dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); } - - WallSpriteColumn (R_DrawMaskedColumn); + R_WallSpriteColumn (R_DrawMaskedColumn); dc_x++; } @@ -3230,7 +3219,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, rt_initcols(); for (int zz = 4; zz; --zz) { - WallSpriteColumn (R_DrawMaskedColumnHoriz); + R_WallSpriteColumn (R_DrawMaskedColumnHoriz); dc_x++; } rt_draw4cols (dc_x - 4); @@ -3242,8 +3231,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { // calculate lighting dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); } - - WallSpriteColumn (R_DrawMaskedColumn); + R_WallSpriteColumn (R_DrawMaskedColumn); dc_x++; } } @@ -3264,21 +3252,3 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, done: WallC = savecoord; } - -static void WallSpriteColumn (void (*drawfunc)(const BYTE *column, const FTexture::Span *spans)) -{ - unsigned int texturecolumn = lwall[dc_x] >> FRACBITS; - dc_iscale = MulScale16 (swall[dc_x], rw_offset); - spryscale = SafeDivScale32 (1, dc_iscale); - if (sprflipvert) - sprtopscreen = centeryfrac + FixedMul (dc_texturemid, spryscale); - else - sprtopscreen = centeryfrac - FixedMul (dc_texturemid, spryscale); - - const BYTE *column; - const FTexture::Span *spans; - column = WallSpriteTile->GetColumn (texturecolumn, &spans); - dc_texturefrac = 0; - drawfunc (column, spans); - rw_light += rw_lightstep; -} diff --git a/src/r_segs.h b/src/r_segs.h index 838b019a9..b8bf96511 100644 --- a/src/r_segs.h +++ b/src/r_segs.h @@ -33,6 +33,8 @@ extern size_t maxopenings; int OWallMost (short *mostbuf, fixed_t z, const FWallCoords *wallc); int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc); +void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat, int x1, int x2); +void PrepLWall (fixed_t *lwall, fixed_t walxrepeat, int x1, int x2); ptrdiff_t R_NewOpening (ptrdiff_t len); @@ -40,4 +42,11 @@ void R_CheckDrawSegs (); void R_RenderSegLoop (); +extern fixed_t swall[MAXWIDTH]; +extern fixed_t lwall[MAXWIDTH]; +extern fixed_t rw_light; // [RH] Scale lights with viewsize adjustments +extern fixed_t rw_lightstep; +extern fixed_t rw_lightleft; +extern fixed_t rw_offset; + #endif diff --git a/src/r_things.cpp b/src/r_things.cpp index 7243ac6f9..1d2c07a2a 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -114,6 +114,8 @@ FDynamicColormap *VisPSpritesBaseColormap[NUMPSPRITES]; static int spriteshade; +FTexture *WallSpriteTile; + // constant arrays // used for psprite clipping and initializing clipping short zeroarray[MAXWIDTH]; @@ -145,6 +147,8 @@ static vissprite_t **spritesorter; static int spritesortersize = 0; static int vsprcount; +static void R_ProjectWallSprite(AActor *thing, fixed_t fx, fixed_t fy, fixed_t fz, FTextureID picnum, fixed_t xscale, fixed_t yscale, INTBOOL flip); + void R_DeinitSprites() { @@ -401,6 +405,151 @@ void R_DrawVisSprite (vissprite_t *vis) NetUpdate (); } +void R_DrawWallSprite(vissprite_t *spr) +{ + int x1, x2; + fixed_t yscale; + int shade = LIGHT2SHADE(140); + + x1 = MAX(spr->x1, spr->wallc.SX1); + x2 = MIN(spr->x2, spr->wallc.SX2 + 1); + if (x1 >= x2) + return; + WallT.InitFromWallCoords(&spr->wallc); + PrepWall(swall, lwall, spr->pic->GetWidth() << FRACBITS, x1, x2); + dc_texturemid = spr->gzt - viewz; + yscale = FRACUNIT; + if (spr->renderflags & RF_XFLIP) + { + int right = (spr->pic->GetWidth() << FRACBITS) - 1; + + for (int i = x1; i < x2; i++) + { + lwall[i] = right - lwall[i]; + } + } + // Prepare lighting + bool calclighting = false; + FDynamicColormap *usecolormap = basecolormap; + bool rereadcolormap = true; + + // Decals that are added to the scene must fade to black. + if (spr->Style.RenderStyle == LegacyRenderStyles[STYLE_Add] && usecolormap->Fade != 0) + { + usecolormap = GetSpecialLights(usecolormap->Color, 0, usecolormap->Desaturate); + rereadcolormap = false; + } + + rw_light = rw_lightleft + (x1 - spr->wallc.SX1) * rw_lightstep; + if (fixedlightlev >= 0) + dc_colormap = usecolormap->Maps + fixedlightlev; + else if (fixedcolormap != NULL) + dc_colormap = fixedcolormap; + else if (!foggy && (spr->renderflags & RF_FULLBRIGHT)) + dc_colormap = usecolormap->Maps; + else + calclighting = true; + + // Draw it + WallSpriteTile = spr->pic; + if (spr->renderflags & RF_YFLIP) + { + sprflipvert = true; + yscale = -yscale; + dc_texturemid = dc_texturemid - (spr->pic->GetHeight() << FRACBITS); + } + else + { + sprflipvert = false; + } + + // rw_offset is used as the texture's vertical scale + rw_offset = SafeDivScale30(1, yscale); + + dc_x = x1; + ESPSResult mode; + + mode = R_SetPatchStyle (spr->Style.RenderStyle, spr->Style.alpha, spr->Translation, spr->FillColor); + + // R_SetPatchStyle can modify basecolormap. + if (rereadcolormap) + { + usecolormap = basecolormap; + } + + if (mode == DontDraw) + { + return; + } + else + { + int stop4; + + if (mode == DoDraw0) + { // 1 column at a time + stop4 = dc_x; + } + else // DoDraw1 + { // up to 4 columns at a time + stop4 = x2 & ~3; + } + + while ((dc_x < stop4) && (dc_x & 3)) + { + if (calclighting) + { // calculate lighting + dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT); + } + R_WallSpriteColumn(R_DrawMaskedColumn); + dc_x++; + } + + while (dc_x < stop4) + { + if (calclighting) + { // calculate lighting + dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT); + } + rt_initcols(); + for (int zz = 4; zz; --zz) + { + R_WallSpriteColumn(R_DrawMaskedColumnHoriz); + dc_x++; + } + rt_draw4cols(dc_x - 4); + } + + while (dc_x < x2) + { + if (calclighting) + { // calculate lighting + dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT); + } + R_WallSpriteColumn(R_DrawMaskedColumn); + dc_x++; + } + } + R_FinishSetPatchStyle(); +} + +void R_WallSpriteColumn (void (*drawfunc)(const BYTE *column, const FTexture::Span *spans)) +{ + unsigned int texturecolumn = lwall[dc_x] >> FRACBITS; + dc_iscale = MulScale16 (swall[dc_x], rw_offset); + spryscale = SafeDivScale32 (1, dc_iscale); + if (sprflipvert) + sprtopscreen = centeryfrac + FixedMul (dc_texturemid, spryscale); + else + sprtopscreen = centeryfrac - FixedMul (dc_texturemid, spryscale); + + const BYTE *column; + const FTexture::Span *spans; + column = WallSpriteTile->GetColumn (texturecolumn, &spans); + dc_texturefrac = 0; + drawfunc (column, spans); + rw_light += rw_lightstep; +} + void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop, short *clipbot) { ESPSResult mode; @@ -521,12 +670,6 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor fy = thing->PrevY + FixedMul (r_TicFrac, thing->y - thing->PrevY); fz = thing->PrevZ + FixedMul (r_TicFrac, thing->z - thing->PrevZ) + thing->GetBobOffset(r_TicFrac); - // transform the origin point - tr_x = fx - viewx; - tr_y = fy - viewy; - - tz = DMulScale20 (tr_x, viewtancos, tr_y, viewtansin); - tex = NULL; voxel = NULL; @@ -618,6 +761,18 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor return; } + if ((thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) + { + R_ProjectWallSprite(thing, fx, fy, fz, picnum, spritescaleX, spritescaleY, flip); + return; + } + + // transform the origin point + tr_x = fx - viewx; + tr_y = fy - viewy; + + tz = DMulScale20 (tr_x, viewtancos, tr_y, viewtansin); + // thing is behind view plane? if (voxel == NULL && tz < MINZ) return; @@ -782,7 +937,6 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor vis->heightsec = heightsec; vis->sector = thing->Sector; - vis->cx = tx2; vis->depth = tz; vis->gx = fx; vis->gy = fy; @@ -807,12 +961,14 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor { vis->voxel = voxel->Voxel; vis->bIsVoxel = true; + vis->bWallSprite = false; DrewAVoxel = true; } else { vis->pic = tex; vis->bIsVoxel = false; + vis->bWallSprite = false; } // The software renderer cannot invert the source without inverting the overlay @@ -874,6 +1030,78 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor } } +static void R_ProjectWallSprite(AActor *thing, fixed_t fx, fixed_t fy, fixed_t fz, FTextureID picnum, fixed_t xscale, fixed_t yscale, INTBOOL flip) +{ + FWallCoords wallc; + int x1, x2; + fixed_t lx1, lx2, ly1, ly2; + fixed_t gzb, gzt, tz; + FTexture *pic = TexMan(picnum, true); + angle_t ang = (thing->angle + ANGLE_90) >> ANGLETOFINESHIFT; + vissprite_t *vis; + + // Determine left and right edges of sprite. The sprite's angle is its normal, + // so the edges are 90 degrees each side of it. + x2 = pic->GetScaledWidth(); + x1 = pic->GetScaledLeftOffset(); + + x1 *= xscale; + x2 *= xscale; + + lx1 = fx - FixedMul(x1, finecosine[ang]) - viewx; + ly1 = fy - FixedMul(x1, finesine[ang]) - viewy; + lx2 = lx1 + FixedMul(x2, finecosine[ang]); + ly2 = ly1 + FixedMul(x2, finesine[ang]); + + // Is it off-screen? + if (wallc.Init(lx1, ly1, lx2, ly2, TOO_CLOSE_Z)) + return; + + if (wallc.SX1 > WindowRight || wallc.SX2 <= WindowLeft) + return; + + // Sprite sorting should probably treat these as walls, not sprites, + // but right now, I just want to get them drawing. + tz = DMulScale20(fx - viewx, viewtancos, fy - viewy, viewtansin); + + int scaled_to = pic->GetScaledTopOffset(); + int scaled_bo = scaled_to - pic->GetScaledHeight(); + gzt = fz + yscale * scaled_to; + gzb = fz + yscale * scaled_bo; + + vis = R_NewVisSprite(); + vis->x1 = wallc.SX1 < WindowLeft ? WindowLeft : wallc.SX1; + vis->x2 = wallc.SX2 >= WindowRight ? WindowRight-1 : wallc.SX2-1; + vis->idepth = (unsigned)DivScale32(1, tz) >> 1; + vis->depth = tz; + vis->sector = thing->Sector; + vis->heightsec = NULL; + vis->gx = fx; + vis->gy = fy; + vis->gz = fz; + vis->gzb = gzb; + vis->gzt = gzt; + vis->deltax = fx - viewx; + vis->deltay = fy - viewy; + vis->renderflags = thing->renderflags; + if(thing->flags5 & MF5_BRIGHT) vis->renderflags |= RF_FULLBRIGHT; // kg3D + vis->Style.RenderStyle = thing->RenderStyle; + vis->FillColor = thing->fillcolor; + vis->Translation = thing->Translation; + vis->FakeFlatStat = 0; + vis->Style.alpha = thing->alpha; + vis->fakefloor = NULL; + vis->fakeceiling = NULL; + vis->ColormapNum = 0; + vis->bInMirror = MirrorFlags & RF_XFLIP; + vis->pic = pic; + vis->bIsVoxel = false; + vis->bWallSprite = true; + vis->ColormapNum = GETPALOOKUP( + (fixed_t)DivScale12 (r_SpriteVisibility, MAX(tz, MINZ)), spriteshade); + vis->Style.colormap = basecolormap->Maps + (vis->ColormapNum << COLORMAPSHIFT); + vis->wallc = wallc; +} // // R_AddSprites @@ -1904,7 +2132,14 @@ void R_DrawSprite (vissprite_t *spr) { mfloorclip = clipbot; mceilingclip = cliptop; - R_DrawVisSprite (spr); + if (!spr->bWallSprite) + { + R_DrawVisSprite(spr); + } + else + { + R_DrawWallSprite(spr); + } } else { @@ -2161,7 +2396,6 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade, vis->yscale = xscale; vis->depth = tz; vis->idepth = (DWORD)DivScale32 (1, tz) >> 1; - vis->cx = tx; vis->gx = particle->x; vis->gy = particle->y; vis->gz = particle->z; // kg3D diff --git a/src/r_things.h b/src/r_things.h index 2219eee20..3ce1a4d4d 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -23,6 +23,7 @@ #ifndef __R_THINGS__ #define __R_THINGS__ +#include "r_bsp.h" // A vissprite_t is a thing // that will be drawn during a refresh. @@ -31,7 +32,6 @@ struct vissprite_t { short x1, x2; - fixed_t cx; // for line side calculation fixed_t gx, gy, gz; // origin in world coordinates angle_t angle; fixed_t gzb, gzt; // global bottom / top for silhouette clipping @@ -43,18 +43,26 @@ struct vissprite_t fixed_t floorclip; union { - // Used by regular sprites + FTexture *pic; + struct FVoxel *voxel; + }; + union + { + // Used by face sprites struct { - FTexture *pic; fixed_t texturemid; fixed_t startfrac; // horizontal position of x1 fixed_t xiscale; // negative if flipped }; + // Used by wall sprites + struct + { + FWallCoords wallc; + }; // Used by voxels struct { - struct FVoxel *voxel; fixed_t vx, vy, vz; // view origin angle_t vang; // view angle }; @@ -64,6 +72,7 @@ struct vissprite_t F3DFloor *fakefloor; F3DFloor *fakeceiling; BYTE bIsVoxel:1; // [RH] Use voxel instead of pic + BYTE bWallSprite:1; // [RH] This is a wall sprite BYTE bSplitSprite:1; // [RH] Sprite was split by a drawseg BYTE bInMirror:1; // [RH] Sprite is "inside" a mirror BYTE FakeFlatStat; // [RH] which side of fake/floor ceiling sprite is on @@ -99,9 +108,11 @@ extern fixed_t pspritexscale; extern fixed_t pspriteyscale; extern fixed_t pspritexiscale; +extern FTexture *WallSpriteTile; + void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *spans); - +void R_WallSpriteColumn (void (*drawfunc)(const BYTE *column, const FTexture::Span *spans)); void R_CacheSprite (spritedef_t *sprite); void R_SortVisSprites (int (STACK_ARGS *compare)(const void *, const void *), size_t first); From 5400ce1a218d3391b20953b9837ae356ac7c163a Mon Sep 17 00:00:00 2001 From: Leonard2 Date: Thu, 7 Aug 2014 15:50:21 +0200 Subject: [PATCH 27/54] +MTHRUSPECIES on puffs --- src/p_map.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index 96b2b6195..8aeab1a84 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -3466,7 +3466,29 @@ fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **p // //========================================================================== -static ETraceStatus CheckForGhost (FTraceResults &res, void *userdata) +struct Origin +{ + AActor *Caller; +}; + +static ETraceStatus CheckForSameSpecie(FTraceResults &res, void *userdata) +{ + if (res.HitType != TRACE_HitActor) + { + return TRACE_Stop; + } + + Origin *data = (Origin *)userdata; + + // check for physical attacks on the same specie + if (res.Actor->GetSpecies() == data->Caller->GetSpecies() || res.Actor->flags4 & MF4_SPECTRAL) + { + return TRACE_Skip; + } + + return TRACE_Stop; +} +static ETraceStatus CheckForGhost(FTraceResults &res, void *userdata) { if (res.HitType != TRACE_HitActor) { @@ -3481,8 +3503,24 @@ static ETraceStatus CheckForGhost (FTraceResults &res, void *userdata) return TRACE_Stop; } +static ETraceStatus CheckForSpecieAndGhost(FTraceResults &res, void *userdata) +{ + if (res.HitType != TRACE_HitActor) + { + return TRACE_Stop; + } -static ETraceStatus CheckForSpectral (FTraceResults &res, void *userdata) + Origin *data = (Origin *)userdata; + + // check for physical attacks + if (res.Actor->GetSpecies() == data->Caller->GetSpecies() || res.Actor->flags3 & MF3_GHOST || res.Actor->flags4 & MF4_SPECTRAL) + { + return TRACE_Skip; + } + + return TRACE_Stop; +} +static ETraceStatus CheckForSpectral(FTraceResults &res, void *userdata) { if (res.HitType != TRACE_HitActor) { @@ -3511,9 +3549,12 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, { fixed_t vx, vy, vz, shootz; FTraceResults trace; + Origin TData; + TData.Caller = t1; angle_t srcangle = angle; int srcpitch = pitch; bool hitGhosts; + bool hitSameSpecie; bool killPuff = false; AActor *puff = NULL; int pflag = 0; @@ -3561,6 +3602,8 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, (t1->player->ReadyWeapon->flags2 & MF2_THRUGHOST)) || (puffDefaults && (puffDefaults->flags2 & MF2_THRUGHOST)); + hitSameSpecie = (puffDefaults && (puffDefaults->flags6 & MF6_MTHRUSPECIES)); + // if the puff uses a non-standard damage type, this will override default, hitscan and melee damage type. // All other explicitly passed damage types (currenty only MDK) will be preserved. if ((damageType == NAME_None || damageType == NAME_Melee || damageType == NAME_Hitscan) && @@ -3575,7 +3618,7 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, if (!Trace (t1->x, t1->y, shootz, t1->Sector, vx, vy, vz, distance, MF_SHOOTABLE, ML_BLOCKEVERYTHING|ML_BLOCKHITSCAN, t1, trace, - tflags, hitGhosts ? CheckForGhost : CheckForSpectral)) + tflags, hitGhosts ? (hitSameSpecie ? CheckForSpecieAndGhost : CheckForGhost) : hitSameSpecie ? CheckForSameSpecie : CheckForSpectral, &TData)) { // hit nothing if (puffDefaults == NULL) { From 8c4c011ca217210a2806ef9f9847215644845a75 Mon Sep 17 00:00:00 2001 From: Leonard2 Date: Thu, 7 Aug 2014 18:05:39 +0200 Subject: [PATCH 28/54] MTHRUSPECIES on puffs You were right it's cleaner that way --- src/p_map.cpp | 1735 ++++++++++++++++++++++++------------------------- 1 file changed, 849 insertions(+), 886 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index 8aeab1a84..68c2c1530 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -53,19 +53,19 @@ #include "r_data/r_translate.h" #include "g_level.h" -CVAR (Bool, cl_bloodsplats, true, CVAR_ARCHIVE) -CVAR (Int, sv_smartaim, 0, CVAR_ARCHIVE|CVAR_SERVERINFO) -CVAR (Bool, cl_doautoaim, false, CVAR_ARCHIVE) +CVAR(Bool, cl_bloodsplats, true, CVAR_ARCHIVE) +CVAR(Int, sv_smartaim, 0, CVAR_ARCHIVE | CVAR_SERVERINFO) +CVAR(Bool, cl_doautoaim, false, CVAR_ARCHIVE) -static void CheckForPushSpecial (line_t *line, int side, AActor *mobj, bool windowcheck); -static void SpawnShootDecal (AActor *t1, const FTraceResults &trace); -static void SpawnDeepSplash (AActor *t1, const FTraceResults &trace, AActor *puff, - fixed_t vx, fixed_t vy, fixed_t vz, fixed_t shootz, bool ffloor = false); +static void CheckForPushSpecial(line_t *line, int side, AActor *mobj, bool windowcheck); +static void SpawnShootDecal(AActor *t1, const FTraceResults &trace); +static void SpawnDeepSplash(AActor *t1, const FTraceResults &trace, AActor *puff, + fixed_t vx, fixed_t vy, fixed_t vz, fixed_t shootz, bool ffloor = false); -static FRandom pr_tracebleed ("TraceBleed"); -static FRandom pr_checkthing ("CheckThing"); -static FRandom pr_lineattack ("LineAttack"); -static FRandom pr_crunch ("DoCrunch"); +static FRandom pr_tracebleed("TraceBleed"); +static FRandom pr_checkthing("CheckThing"); +static FRandom pr_lineattack("LineAttack"); +static FRandom pr_crunch("DoCrunch"); // keep track of special lines as they are hit, // but don't process them until the move is proven valid @@ -82,19 +82,19 @@ msecnode_t* sector_list = NULL; // phares 3/16/98 // //========================================================================== -static bool PIT_FindFloorCeiling (line_t *ld, const FBoundingBox &box, FCheckPosition &tmf, int flags) +static bool PIT_FindFloorCeiling(line_t *ld, const FBoundingBox &box, FCheckPosition &tmf, int flags) { if (box.Right() <= ld->bbox[BOXLEFT] || box.Left() >= ld->bbox[BOXRIGHT] || box.Top() <= ld->bbox[BOXBOTTOM] - || box.Bottom() >= ld->bbox[BOXTOP] ) + || box.Bottom() >= ld->bbox[BOXTOP]) return true; - if (box.BoxOnLineSide (ld) != -1) + if (box.BoxOnLineSide(ld) != -1) return true; // A line has been hit - + if (!ld->backsector) { // One sided line return true; @@ -105,33 +105,33 @@ static bool PIT_FindFloorCeiling (line_t *ld, const FBoundingBox &box, FCheckPos // set openrange, opentop, openbottom if ((((ld->frontsector->floorplane.a | ld->frontsector->floorplane.b) | - (ld->backsector->floorplane.a | ld->backsector->floorplane.b) | - (ld->frontsector->ceilingplane.a | ld->frontsector->ceilingplane.b) | - (ld->backsector->ceilingplane.a | ld->backsector->ceilingplane.b)) == 0) - && ld->backsector->e->XFloor.ffloors.Size()==0 && ld->frontsector->e->XFloor.ffloors.Size()==0) + (ld->backsector->floorplane.a | ld->backsector->floorplane.b) | + (ld->frontsector->ceilingplane.a | ld->frontsector->ceilingplane.b) | + (ld->backsector->ceilingplane.a | ld->backsector->ceilingplane.b)) == 0) + && ld->backsector->e->XFloor.ffloors.Size() == 0 && ld->frontsector->e->XFloor.ffloors.Size() == 0) { - P_LineOpening (open, tmf.thing, ld, sx=tmf.x, sy=tmf.y, tmf.x, tmf.y, flags); + P_LineOpening(open, tmf.thing, ld, sx = tmf.x, sy = tmf.y, tmf.x, tmf.y, flags); } else { // Find the point on the line closest to the actor's center, and use - // that to calculate openings + // that to calculate openings double dx = ld->dx; double dy = ld->dy; fixed_t r = xs_CRoundToInt(((double)(tmf.x - ld->v1->x) * dx + - (double)(tmf.y - ld->v1->y) * dy) / - (dx*dx + dy*dy) * 16777216.f); + (double)(tmf.y - ld->v1->y) * dy) / + (dx*dx + dy*dy) * 16777216.f); if (r <= 0) { - P_LineOpening (open, tmf.thing, ld, sx=ld->v1->x, sy=ld->v1->y, tmf.x, tmf.y, flags); + P_LineOpening(open, tmf.thing, ld, sx = ld->v1->x, sy = ld->v1->y, tmf.x, tmf.y, flags); } - else if (r >= (1<<24)) + else if (r >= (1 << 24)) { - P_LineOpening (open, tmf.thing, ld, sx=ld->v2->x, sy=ld->v2->y, tmf.thing->x, tmf.thing->y, flags); + P_LineOpening(open, tmf.thing, ld, sx = ld->v2->x, sy = ld->v2->y, tmf.thing->x, tmf.thing->y, flags); } else { - P_LineOpening (open, tmf.thing, ld, sx=ld->v1->x + MulScale24 (r, ld->dx), - sy=ld->v1->y + MulScale24 (r, ld->dy), tmf.x, tmf.y, flags); + P_LineOpening(open, tmf.thing, ld, sx = ld->v1->x + MulScale24(r, ld->dx), + sy = ld->v1->y + MulScale24(r, ld->dy), tmf.x, tmf.y, flags); } } @@ -156,7 +156,7 @@ static bool PIT_FindFloorCeiling (line_t *ld, const FBoundingBox &box, FCheckPos if (open.lowfloor < tmf.dropoffz) tmf.dropoffz = open.lowfloor; - + return true; } @@ -172,12 +172,12 @@ void P_GetFloorCeilingZ(FCheckPosition &tmf, int flags) sector_t *sec; if (!(flags & FFCF_ONLYSPAWNPOS)) { - sec = !(flags & FFCF_SAMESECTOR) ? P_PointInSector (tmf.x, tmf.y) : tmf.thing->Sector; + sec = !(flags & FFCF_SAMESECTOR) ? P_PointInSector(tmf.x, tmf.y) : tmf.thing->Sector; tmf.floorsector = sec; tmf.ceilingsector = sec; - tmf.floorz = tmf.dropoffz = sec->floorplane.ZatPoint (tmf.x, tmf.y); - tmf.ceilingz = sec->ceilingplane.ZatPoint (tmf.x, tmf.y); + tmf.floorz = tmf.dropoffz = sec->floorplane.ZatPoint(tmf.x, tmf.y); + tmf.ceilingz = sec->ceilingplane.ZatPoint(tmf.x, tmf.y); tmf.floorpic = sec->GetTexture(sector_t::floor); tmf.ceilingpic = sec->GetTexture(sector_t::ceiling); } @@ -187,7 +187,7 @@ void P_GetFloorCeilingZ(FCheckPosition &tmf, int flags) } #ifdef _3DFLOORS - for(unsigned int i=0;ie->XFloor.ffloors.Size();i++) + for (unsigned int i = 0; ie->XFloor.ffloors.Size(); i++) { F3DFloor* rover = sec->e->XFloor.ffloors[i]; @@ -204,7 +204,7 @@ void P_GetFloorCeilingZ(FCheckPosition &tmf, int flags) tmf.floorpic = *rover->top.texture; } } - if (ff_bottom <= tmf.ceilingz && ff_bottom > tmf.z + tmf.thing->height) + if (ff_bottom <= tmf.ceilingz && ff_bottom > tmf.z + tmf.thing->height) { tmf.ceilingz = ff_bottom; tmf.ceilingpic = *rover->bottom.texture; @@ -219,7 +219,7 @@ void P_GetFloorCeilingZ(FCheckPosition &tmf, int flags) // //========================================================================== -void P_FindFloorCeiling (AActor *actor, int flags) +void P_FindFloorCeiling(AActor *actor, int flags) { FCheckPosition tmf; @@ -309,14 +309,14 @@ void P_FindFloorCeiling (AActor *actor, int flags) // //========================================================================== -bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefrag) +bool P_TeleportMove(AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefrag) { FCheckPosition tmf; sector_t *oldsec = thing->Sector; - + // kill anything occupying the position - - + + // The base floor/ceiling is from the subsector that contains the point. // Any contacted lines the step closer together will adjust them. tmf.thing = thing; @@ -326,8 +326,8 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr tmf.touchmidtex = false; tmf.abovemidtex = false; P_GetFloorCeilingZ(tmf, 0); - - spechit.Clear (); + + spechit.Clear(); bool StompAlwaysFrags = ((thing->flags2 & MF2_TELESTOMP) || (level.flags & LEVEL_MONSTERSTELEFRAG) || telefrag) && !(thing->flags7 & MF7_NOTELESTOMP); @@ -359,7 +359,7 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr continue; fixed_t blockdist = th->radius + tmf.thing->radius; - if ( abs(th->x - tmf.x) >= blockdist || abs(th->y - tmf.y) >= blockdist) + if (abs(th->x - tmf.x) >= blockdist || abs(th->y - tmf.y) >= blockdist) continue; // [RH] Z-Check @@ -370,7 +370,7 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr if (!(th->flags3 & thing->flags3 & MF3_DONTOVERLAP)) { if (z > th->z + th->height || // overhead - z+thing->height < th->z) // underneath + z + thing->height < th->z) // underneath continue; } } @@ -380,14 +380,14 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr // ... and some items can never be telefragged while others will be telefragged by everything that teleports upon them. if ((StompAlwaysFrags && !(th->flags6 & MF6_NOTELEFRAG)) || (th->flags7 & MF7_ALWAYSTELEFRAG)) { - P_DamageMobj (th, thing, thing, TELEFRAG_DAMAGE, NAME_Telefrag, DMG_THRUSTLESS); + P_DamageMobj(th, thing, thing, TELEFRAG_DAMAGE, NAME_Telefrag, DMG_THRUSTLESS); continue; } return false; } - + // the move is ok, so link the thing into its new position - thing->SetOrigin (x, y, z); + thing->SetOrigin(x, y, z); thing->floorz = tmf.floorz; thing->ceilingz = tmf.ceilingz; thing->floorsector = tmf.floorsector; @@ -399,12 +399,12 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr if (thing->flags2 & MF2_FLOORCLIP) { - thing->AdjustFloorClip (); + thing->AdjustFloorClip(); } if (thing == players[consoleplayer].camera) { - R_ResetViewInterpolation (); + R_ResetViewInterpolation(); } thing->PrevX = x; @@ -430,7 +430,7 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr // //========================================================================== -void P_PlayerStartStomp (AActor *actor) +void P_PlayerStartStomp(AActor *actor) { AActor *th; FBlockThingsIterator it(FBoundingBox(actor->x, actor->y, actor->radius)); @@ -456,7 +456,7 @@ void P_PlayerStartStomp (AActor *actor) if (actor->z + actor->height < th->z) continue; // underneath - P_DamageMobj (th, actor, actor, TELEFRAG_DAMAGE, NAME_Telefrag); + P_DamageMobj(th, actor, actor, TELEFRAG_DAMAGE, NAME_Telefrag); } } @@ -466,13 +466,13 @@ void P_PlayerStartStomp (AActor *actor) // //========================================================================== -inline fixed_t secfriction (const sector_t *sec) +inline fixed_t secfriction(const sector_t *sec) { fixed_t friction = Terrains[TerrainTypes[sec->GetTexture(sector_t::floor)]].Friction; return friction != 0 ? friction : sec->friction; } -inline fixed_t secmovefac (const sector_t *sec) +inline fixed_t secmovefac(const sector_t *sec) { fixed_t movefactor = Terrains[TerrainTypes[sec->GetTexture(sector_t::floor)]].MoveFactor; return movefactor != 0 ? movefactor : sec->movefactor; @@ -488,7 +488,7 @@ inline fixed_t secmovefac (const sector_t *sec) // //========================================================================== -int P_GetFriction (const AActor *mo, int *frictionfactor) +int P_GetFriction(const AActor *mo, int *frictionfactor) { int friction = ORIG_FRICTION; int movefactor = ORIG_FRICTION_FACTOR; @@ -505,12 +505,12 @@ int P_GetFriction (const AActor *mo, int *frictionfactor) friction = FRICTION_FLY; } else if ((!(mo->flags & MF_NOGRAVITY) && mo->waterlevel > 1) || - (mo->waterlevel == 1 && mo->z > mo->floorz + 6*FRACUNIT)) + (mo->waterlevel == 1 && mo->z > mo->floorz + 6 * FRACUNIT)) { friction = secfriction(mo->Sector); movefactor = secmovefac(mo->Sector) >> 1; } - else if (var_friction && !(mo->flags & (MF_NOCLIP|MF_NOGRAVITY))) + else if (var_friction && !(mo->flags & (MF_NOCLIP | MF_NOGRAVITY))) { // When the object is straddling sectors with the same // floor height that have different frictions, use the lowest // friction value (muddy has precedence over icy). @@ -528,7 +528,7 @@ int P_GetFriction (const AActor *mo, int *frictionfactor) if (!(rover->flags & FF_SOLID)) continue; // Player must be on top of the floor to be affected... - if (mo->z != rover->top.plane->ZatPoint(mo->x,mo->y)) continue; + if (mo->z != rover->top.plane->ZatPoint(mo->x, mo->y)) continue; newfriction = secfriction(rover->model); if (newfriction < friction || friction == ORIG_FRICTION) { @@ -547,14 +547,14 @@ int P_GetFriction (const AActor *mo, int *frictionfactor) if ((newfriction < friction || friction == ORIG_FRICTION) && (mo->z <= sec->floorplane.ZatPoint(mo->x, mo->y) || (sec->GetHeightSec() != NULL && - mo->z <= sec->heightsec->floorplane.ZatPoint(mo->x, mo->y)))) + mo->z <= sec->heightsec->floorplane.ZatPoint(mo->x, mo->y)))) { friction = newfriction; movefactor = secmovefac(sec); } } } - + if (mo->Friction != FRACUNIT) { friction = clamp(FixedMul(friction, mo->Friction), 0, FRACUNIT); @@ -577,7 +577,7 @@ int P_GetFriction (const AActor *mo, int *frictionfactor) // //========================================================================== -int P_GetMoveFactor (const AActor *mo, int *frictionp) +int P_GetMoveFactor(const AActor *mo, int *frictionp) { int movefactor, friction; @@ -592,9 +592,9 @@ int P_GetMoveFactor (const AActor *mo, int *frictionp) int velocity = P_AproxDistance(mo->velx, mo->vely); - if (velocity > MORE_FRICTION_VELOCITY<<2) + if (velocity > MORE_FRICTION_VELOCITY << 2) movefactor <<= 3; - else if (velocity > MORE_FRICTION_VELOCITY<<1) + else if (velocity > MORE_FRICTION_VELOCITY << 1) movefactor <<= 2; else if (velocity > MORE_FRICTION_VELOCITY) movefactor <<= 1; @@ -620,37 +620,37 @@ int P_GetMoveFactor (const AActor *mo, int *frictionp) //========================================================================== static // killough 3/26/98: make static -bool PIT_CheckLine (line_t *ld, const FBoundingBox &box, FCheckPosition &tm) +bool PIT_CheckLine(line_t *ld, const FBoundingBox &box, FCheckPosition &tm) { bool rail = false; if (box.Right() <= ld->bbox[BOXLEFT] || box.Left() >= ld->bbox[BOXRIGHT] || box.Top() <= ld->bbox[BOXBOTTOM] - || box.Bottom() >= ld->bbox[BOXTOP] ) + || box.Bottom() >= ld->bbox[BOXTOP]) return true; - if (box.BoxOnLineSide (ld) != -1) + if (box.BoxOnLineSide(ld) != -1) return true; // A line has been hit -/* -= -= The moving thing's destination position will cross the given line. -= If this should not be allowed, return false. -= If the line is special, keep track of it to process later if the move -= is proven ok. NOTE: specials are NOT sorted by order, so two special lines -= that are only 8 pixels apart could be crossed in either order. -*/ - + /* + = + = The moving thing's destination position will cross the given line. + = If this should not be allowed, return false. + = If the line is special, keep track of it to process later if the move + = is proven ok. NOTE: specials are NOT sorted by order, so two special lines + = that are only 8 pixels apart could be crossed in either order. + */ + if (!ld->backsector) { // One sided line if (tm.thing->flags2 & MF2_BLASTED) { - P_DamageMobj (tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee); + P_DamageMobj(tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee); } tm.thing->BlockingLine = ld; - CheckForPushSpecial (ld, 0, tm.thing, false); + CheckForPushSpecial(ld, 0, tm.thing, false); return false; } @@ -663,13 +663,13 @@ bool PIT_CheckLine (line_t *ld, const FBoundingBox &box, FCheckPosition &tm) bool NotBlocked = ((tm.thing->flags3 & MF3_NOBLOCKMONST) || ((i_compatflags & COMPATF_NOBLOCKFRIENDS) && (tm.thing->flags & MF_FRIENDLY))); - if (!(Projectile) || (ld->flags & (ML_BLOCKEVERYTHING|ML_BLOCKPROJECTILE))) + if (!(Projectile) || (ld->flags & (ML_BLOCKEVERYTHING | ML_BLOCKPROJECTILE))) { if (ld->flags & ML_RAILING) { rail = true; } - else if ((ld->flags & (ML_BLOCKING|ML_BLOCKEVERYTHING)) || // explicitly blocking everything + else if ((ld->flags & (ML_BLOCKING | ML_BLOCKEVERYTHING)) || // explicitly blocking everything (!(NotBlocked) && (ld->flags & ML_BLOCKMONSTERS)) || // block monsters only (tm.thing->player != NULL && (ld->flags & ML_BLOCK_PLAYERS)) || // block players ((Projectile) && (ld->flags & ML_BLOCKPROJECTILE)) || // block projectiles @@ -677,21 +677,21 @@ bool PIT_CheckLine (line_t *ld, const FBoundingBox &box, FCheckPosition &tm) { if (tm.thing->flags2 & MF2_BLASTED) { - P_DamageMobj (tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee); + P_DamageMobj(tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee); } tm.thing->BlockingLine = ld; // Calculate line side based on the actor's original position, not the new one. - CheckForPushSpecial (ld, P_PointOnLineSide(tm.thing->x, tm.thing->y, ld), tm.thing, false); + CheckForPushSpecial(ld, P_PointOnLineSide(tm.thing->x, tm.thing->y, ld), tm.thing, false); return false; } } // [RH] Steep sectors count as dropoffs (unless already in one) if (!(tm.thing->flags & MF_DROPOFF) && - !(tm.thing->flags & (MF_NOGRAVITY|MF_NOCLIP))) + !(tm.thing->flags & (MF_NOGRAVITY | MF_NOCLIP))) { secplane_t frontplane = ld->frontsector->floorplane; - secplane_t backplane = ld->backsector->floorplane; + secplane_t backplane = ld->backsector->floorplane; #ifdef _3DFLOORS // Check 3D floors as well frontplane = P_FindFloorPlane(ld->frontsector, tm.thing->x, tm.thing->y, tm.thing->floorz); @@ -719,57 +719,57 @@ bool PIT_CheckLine (line_t *ld, const FBoundingBox &box, FCheckPosition &tm) } } - fixed_t sx=0, sy=0; + fixed_t sx = 0, sy = 0; FLineOpening open; // set openrange, opentop, openbottom if ((((ld->frontsector->floorplane.a | ld->frontsector->floorplane.b) | - (ld->backsector->floorplane.a | ld->backsector->floorplane.b) | - (ld->frontsector->ceilingplane.a | ld->frontsector->ceilingplane.b) | - (ld->backsector->ceilingplane.a | ld->backsector->ceilingplane.b)) == 0) - && ld->backsector->e->XFloor.ffloors.Size()==0 && ld->frontsector->e->XFloor.ffloors.Size()==0) + (ld->backsector->floorplane.a | ld->backsector->floorplane.b) | + (ld->frontsector->ceilingplane.a | ld->frontsector->ceilingplane.b) | + (ld->backsector->ceilingplane.a | ld->backsector->ceilingplane.b)) == 0) + && ld->backsector->e->XFloor.ffloors.Size() == 0 && ld->frontsector->e->XFloor.ffloors.Size() == 0) { - P_LineOpening (open, tm.thing, ld, sx=tm.x, sy=tm.y, tm.x, tm.y); + P_LineOpening(open, tm.thing, ld, sx = tm.x, sy = tm.y, tm.x, tm.y); } else { // Find the point on the line closest to the actor's center, and use - // that to calculate openings + // that to calculate openings float dx = (float)ld->dx; float dy = (float)ld->dy; fixed_t r = (fixed_t)(((float)(tm.x - ld->v1->x) * dx + - (float)(tm.y - ld->v1->y) * dy) / - (dx*dx + dy*dy) * 16777216.f); -/* Printf ("%d:%d: %d (%d %d %d %d) (%d %d %d %d)\n", level.time, ld-lines, r, - ld->frontsector->floorplane.a, - ld->frontsector->floorplane.b, - ld->frontsector->floorplane.c, - ld->frontsector->floorplane.ic, - ld->backsector->floorplane.a, - ld->backsector->floorplane.b, - ld->backsector->floorplane.c, - ld->backsector->floorplane.ic);*/ + (float)(tm.y - ld->v1->y) * dy) / + (dx*dx + dy*dy) * 16777216.f); + /* Printf ("%d:%d: %d (%d %d %d %d) (%d %d %d %d)\n", level.time, ld-lines, r, + ld->frontsector->floorplane.a, + ld->frontsector->floorplane.b, + ld->frontsector->floorplane.c, + ld->frontsector->floorplane.ic, + ld->backsector->floorplane.a, + ld->backsector->floorplane.b, + ld->backsector->floorplane.c, + ld->backsector->floorplane.ic);*/ if (r <= 0) { - P_LineOpening (open, tm.thing, ld, sx=ld->v1->x, sy=ld->v1->y, tm.x, tm.y); + P_LineOpening(open, tm.thing, ld, sx = ld->v1->x, sy = ld->v1->y, tm.x, tm.y); } - else if (r >= (1<<24)) + else if (r >= (1 << 24)) { - P_LineOpening (open, tm.thing, ld, sx=ld->v2->x, sy=ld->v2->y, tm.thing->x, tm.thing->y); + P_LineOpening(open, tm.thing, ld, sx = ld->v2->x, sy = ld->v2->y, tm.thing->x, tm.thing->y); } else { - P_LineOpening (open, tm.thing, ld, sx=ld->v1->x + MulScale24 (r, ld->dx), - sy=ld->v1->y + MulScale24 (r, ld->dy), tm.x, tm.y); + P_LineOpening(open, tm.thing, ld, sx = ld->v1->x + MulScale24(r, ld->dx), + sy = ld->v1->y + MulScale24(r, ld->dy), tm.x, tm.y); } // the floorplane on both sides is identical with the current one // so don't mess around with the z-position - if (ld->frontsector->floorplane==ld->backsector->floorplane && - ld->frontsector->floorplane==tm.thing->Sector->floorplane && + if (ld->frontsector->floorplane == ld->backsector->floorplane && + ld->frontsector->floorplane == tm.thing->Sector->floorplane && !ld->frontsector->e->XFloor.ffloors.Size() && !ld->backsector->e->XFloor.ffloors.Size() && !open.abovemidtex) { - open.bottom=INT_MIN; + open.bottom = INT_MIN; } /* Printf (" %d %d %d\n", sx, sy, openbottom);*/ } @@ -783,9 +783,9 @@ bool PIT_CheckLine (line_t *ld, const FBoundingBox &box, FCheckPosition &tm) // from either side. How long until somebody reports this as a bug and I'm // forced to say, "It's not a bug. It's a feature?" Ugh. (!(level.flags2 & LEVEL2_RAILINGHACK) || - open.bottom == tm.thing->Sector->floorplane.ZatPoint (sx, sy))) + open.bottom == tm.thing->Sector->floorplane.ZatPoint(sx, sy))) { - open.bottom += 32*FRACUNIT; + open.bottom += 32 * FRACUNIT; } // adjust floor / ceiling heights @@ -815,11 +815,11 @@ bool PIT_CheckLine (line_t *ld, const FBoundingBox &box, FCheckPosition &tm) if (open.lowfloor < tm.dropoffz) tm.dropoffz = open.lowfloor; - + // if contacted a special line, add it to the list if (ld->special) { - spechit.Push (ld); + spechit.Push(ld); } return true; @@ -831,24 +831,24 @@ bool PIT_CheckLine (line_t *ld, const FBoundingBox &box, FCheckPosition &tm) // //========================================================================== -bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) +bool PIT_CheckThing(AActor *thing, FCheckPosition &tm) { fixed_t topz; bool solid; int damage; - if (!((thing->flags & (MF_SOLID|MF_SPECIAL|MF_SHOOTABLE)) || thing->flags6 & MF6_TOUCHY)) + if (!((thing->flags & (MF_SOLID | MF_SPECIAL | MF_SHOOTABLE)) || thing->flags6 & MF6_TOUCHY)) return true; // can't hit thing fixed_t blockdist = thing->radius + tm.thing->radius; - if ( abs(thing->x - tm.x) >= blockdist || abs(thing->y - tm.y) >= blockdist) + if (abs(thing->x - tm.x) >= blockdist || abs(thing->y - tm.y) >= blockdist) return true; // don't clip against self if (thing == tm.thing) return true; - if ((thing->flags2 | tm.thing->flags2) & MF2_THRUACTORS) + if ((thing->flags2 | tm.thing->flags2) & MF2_THRUACTORS) return true; if ((tm.thing->flags6 & MF6_THRUSPECIES) && (tm.thing->GetSpecies() == thing->GetSpecies())) @@ -856,7 +856,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) tm.thing->BlockingMobj = thing; topz = thing->z + thing->height; - if (!(i_compatflags & COMPATF_NO_PASSMOBJ) && !(tm.thing->flags & (MF_FLOAT|MF_MISSILE|MF_SKULLFLY|MF_NOGRAVITY)) && + if (!(i_compatflags & COMPATF_NO_PASSMOBJ) && !(tm.thing->flags & (MF_FLOAT | MF_MISSILE | MF_SKULLFLY | MF_NOGRAVITY)) && (thing->flags & MF_SOLID) && (thing->flags4 & MF4_ACTLIKEBRIDGE)) { // [RH] Let monsters walk on actors as well as floors @@ -868,8 +868,8 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) // way to do this, so I restrict them to only walking on bridges instead. // Uncommenting the if here makes it almost impossible for them to walk on // anything, bridge or otherwise. -// if (abs(thing->x - tmx) <= thing->radius && -// abs(thing->y - tmy) <= thing->radius) + // if (abs(thing->x - tmx) <= thing->radius && + // abs(thing->y - tmy) <= thing->radius) { tm.stepthing = thing; tm.floorz = topz; @@ -897,7 +897,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) { // ... but not if they did not overlap in z-direction before but would after the move. unblocking = !((tm.thing->z >= thing->z + thing->height && tm.z < thing->z + thing->height) || - (tm.thing->z + tm.thing->height <= thing->z && tm.z + tm.thing->height > thing->z)); + (tm.thing->z + tm.thing->height <= thing->z && tm.z + tm.thing->height > thing->z)); } } } @@ -957,7 +957,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) // Check for skulls slamming into things if (tm.thing->flags & MF_SKULLFLY) { - bool res = tm.thing->Slam (tm.thing->BlockingMobj); + bool res = tm.thing->Slam(tm.thing->BlockingMobj); tm.thing->BlockingMobj = NULL; return res; } @@ -980,15 +980,15 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) // ideally this should take the mass factor into account thing->velx += tm.thing->velx; thing->vely += tm.thing->vely; - if ((thing->velx + thing->vely) > 3*FRACUNIT) + if ((thing->velx + thing->vely) > 3 * FRACUNIT) { int newdam; damage = (tm.thing->Mass / 100) + 1; - newdam = P_DamageMobj (thing, tm.thing, tm.thing, damage, tm.thing->DamageType); - P_TraceBleed (newdam > 0 ? newdam : damage, thing, tm.thing); + newdam = P_DamageMobj(thing, tm.thing, tm.thing, damage, tm.thing->DamageType); + P_TraceBleed(newdam > 0 ? newdam : damage, thing, tm.thing); damage = (thing->Mass / 100) + 1; - newdam = P_DamageMobj (tm.thing, thing, thing, damage >> 2, tm.thing->DamageType); - P_TraceBleed (newdam > 0 ? newdam : damage, tm.thing, thing); + newdam = P_DamageMobj(tm.thing, thing, thing, damage >> 2, tm.thing->DamageType); + P_TraceBleed(newdam > 0 ? newdam : damage, tm.thing, thing); } return false; } @@ -1007,7 +1007,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) return true; } - if ((tm.thing->flags6 & MF6_MTHRUSPECIES) + if ((tm.thing->flags6 & MF6_MTHRUSPECIES) && tm.thing->target // NULL pointer check && (tm.thing->target->GetSpecies() == thing->GetSpecies())) return true; @@ -1019,8 +1019,8 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) } int clipheight; - - if (thing->projectilepassheight > 0) + + if (thing->projectilepassheight > 0) { clipheight = thing->projectilepassheight; } @@ -1038,7 +1038,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) { // Over thing return true; } - if (tm.thing->z+tm.thing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) { // Under thing return true; } @@ -1051,7 +1051,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) return (tm.thing->target == thing || !(thing->flags & MF_SOLID)); } - switch (tm.thing->SpecialMissileHit (thing)) + switch (tm.thing->SpecialMissileHit(thing)) { case 0: return false; case 1: return true; @@ -1063,7 +1063,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) // [Graf Zahl] Why do I have the feeling that this didn't really work anymore now // that ZDoom supports friendly monsters? - + if (tm.thing->target != NULL) { @@ -1077,10 +1077,10 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) if (!thing->player && !tm.thing->target->player) { int infight; - if (level.flags2 & LEVEL2_TOTALINFIGHTING) infight=1; - else if (level.flags2 & LEVEL2_NOINFIGHTING) infight=-1; + if (level.flags2 & LEVEL2_TOTALINFIGHTING) infight = 1; + else if (level.flags2 & LEVEL2_NOINFIGHTING) infight = -1; else infight = infighting; - + if (infight < 0) { // -1: Monsters cannot hurt each other, but make exceptions for @@ -1092,7 +1092,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) if (thing->flags3 & MF3_ISMONSTER) { // Monsters that are clearly hostile can always hurt each other - if (!thing->IsHostile (tm.thing->target)) + if (!thing->IsHostile(tm.thing->target)) { // The same if the shooter hates the target if (thing->tid == 0 || tm.thing->target->TIDtoHate != thing->tid) @@ -1107,7 +1107,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) { // 0: Monsters cannot hurt same species except // cases where they are clearly supposed to do that - if (thing->IsFriend (tm.thing->target)) + if (thing->IsFriend(tm.thing->target)) { // Friends never harm each other return false; @@ -1121,7 +1121,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) { // Don't hurt same species or any relative - // but only if the target isn't one's hostile. - if (!thing->IsHostile (tm.thing->target)) + if (!thing->IsHostile(tm.thing->target)) { // Allow hurting monsters the shooter hates. if (thing->tid == 0 || tm.thing->target->TIDtoHate != thing->tid) @@ -1152,11 +1152,11 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) if (!(thing->flags & MF_NOBLOOD) && !(thing->flags2 & MF2_REFLECTIVE) && !(tm.thing->flags3 & MF3_BLOODLESSIMPACT) && - !(thing->flags2 & (MF2_INVULNERABLE|MF2_DORMANT))) + !(thing->flags2 & (MF2_INVULNERABLE | MF2_DORMANT))) { // Ok to spawn blood - P_RipperBlood (tm.thing, thing); + P_RipperBlood(tm.thing, thing); } - S_Sound (tm.thing, CHAN_BODY, "misc/ripslop", 1, ATTN_IDLE); + S_Sound(tm.thing, CHAN_BODY, "misc/ripslop", 1, ATTN_IDLE); // Do poisoning (if using new style poison) if (tm.thing->PoisonDamage > 0 && tm.thing->PoisonDuration != INT_MIN) @@ -1164,11 +1164,11 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) P_PoisonMobj(thing, tm.thing, tm.thing->target, tm.thing->PoisonDamage, tm.thing->PoisonDuration, tm.thing->PoisonPeriod, tm.thing->PoisonDamageType); } - damage = tm.thing->GetMissileDamage (3, 2); - int newdam = P_DamageMobj (thing, tm.thing, tm.thing->target, damage, tm.thing->DamageType); + damage = tm.thing->GetMissileDamage(3, 2); + int newdam = P_DamageMobj(thing, tm.thing, tm.thing->target, damage, tm.thing->DamageType); if (!(tm.thing->flags3 & MF3_BLOODLESSIMPACT)) { - P_TraceBleed (newdam > 0 ? newdam : damage, thing, tm.thing); + P_TraceBleed(newdam > 0 ? newdam : damage, thing, tm.thing); } if (thing->flags2 & MF2_PUSHABLE && !(tm.thing->flags2 & MF2_CANNOTPUSH)) @@ -1181,7 +1181,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) } } } - spechit.Clear (); + spechit.Clear(); return true; } } @@ -1193,30 +1193,30 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) } // Do damage - damage = tm.thing->GetMissileDamage ((tm.thing->flags4 & MF4_STRIFEDAMAGE) ? 3 : 7, 1); - if ((damage > 0) || (tm.thing->flags6 & MF6_FORCEPAIN)) + damage = tm.thing->GetMissileDamage((tm.thing->flags4 & MF4_STRIFEDAMAGE) ? 3 : 7, 1); + if ((damage > 0) || (tm.thing->flags6 & MF6_FORCEPAIN)) { - int newdam = P_DamageMobj (thing, tm.thing, tm.thing->target, damage, tm.thing->DamageType); + int newdam = P_DamageMobj(thing, tm.thing, tm.thing->target, damage, tm.thing->DamageType); if (damage > 0) { if ((tm.thing->flags5 & MF5_BLOODSPLATTER) && !(thing->flags & MF_NOBLOOD) && !(thing->flags2 & MF2_REFLECTIVE) && - !(thing->flags2 & (MF2_INVULNERABLE|MF2_DORMANT)) && + !(thing->flags2 & (MF2_INVULNERABLE | MF2_DORMANT)) && !(tm.thing->flags3 & MF3_BLOODLESSIMPACT) && (pr_checkthing() < 192)) { - P_BloodSplatter (tm.thing->x, tm.thing->y, tm.thing->z, thing); + P_BloodSplatter(tm.thing->x, tm.thing->y, tm.thing->z, thing); } if (!(tm.thing->flags3 & MF3_BLOODLESSIMPACT)) { - P_TraceBleed (newdam > 0 ? newdam : damage, thing, tm.thing); + P_TraceBleed(newdam > 0 ? newdam : damage, thing, tm.thing); } } } else { - P_GiveBody (thing, -damage); + P_GiveBody(thing, -damage); } return false; // don't traverse any more } @@ -1230,8 +1230,8 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) } } solid = (thing->flags & MF_SOLID) && - !(thing->flags & MF_NOCLIP) && - ((tm.thing->flags & MF_SOLID) || (tm.thing->flags6 & MF6_BLOCKEDBYSOLIDACTORS)); + !(thing->flags & MF_NOCLIP) && + ((tm.thing->flags & MF_SOLID) || (tm.thing->flags6 & MF6_BLOCKEDBYSOLIDACTORS)); // Check for special pickup if ((thing->flags & MF_SPECIAL) && (tm.thing->flags & MF_PICKUP) @@ -1240,7 +1240,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) // up things that are above your true height. && thing->z < tm.thing->z + tm.thing->height - tm.thing->MaxStepHeight) { // Can be picked up by tmthing - P_TouchSpecialThing (thing, tm.thing); // can remove thing + P_TouchSpecialThing(thing, tm.thing); // can remove thing } // killough 3/16/98: Allow non-solid moving objects to move through solid @@ -1258,7 +1258,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) /* =============================================================================== - MOVEMENT CLIPPING +MOVEMENT CLIPPING =============================================================================== */ @@ -1290,7 +1290,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) // //========================================================================== -bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, bool actorsonly) +bool P_CheckPosition(AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, bool actorsonly) { sector_t *newsec; AActor *thingblocker; @@ -1301,13 +1301,13 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, b tm.x = x; tm.y = y; - newsec = P_PointInSector (x,y); + newsec = P_PointInSector(x, y); tm.ceilingline = thing->BlockingLine = NULL; - -// The base floor / ceiling is from the subsector that contains the point. -// Any contacted lines the step closer together will adjust them. - tm.floorz = tm.dropoffz = newsec->floorplane.ZatPoint (x, y); - tm.ceilingz = newsec->ceilingplane.ZatPoint (x, y); + + // The base floor / ceiling is from the subsector that contains the point. + // Any contacted lines the step closer together will adjust them. + tm.floorz = tm.dropoffz = newsec->floorplane.ZatPoint(x, y); + tm.ceilingz = newsec->ceilingplane.ZatPoint(x, y); tm.floorpic = newsec->GetTexture(sector_t::floor); tm.floorsector = newsec; tm.ceilingpic = newsec->GetTexture(sector_t::ceiling); @@ -1317,7 +1317,7 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, b //Added by MC: Fill the tmsector. tm.sector = newsec; - + #ifdef _3DFLOORS //Check 3D floors if (!thing->IsNoClip2() && newsec->e->XFloor.ffloors.Size()) @@ -1325,25 +1325,25 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, b F3DFloor* rover; fixed_t delta1; fixed_t delta2; - int thingtop = thing->z + (thing->height==0? 1:thing->height); - - for(unsigned i=0;ie->XFloor.ffloors.Size();i++) + int thingtop = thing->z + (thing->height == 0 ? 1 : thing->height); + + for (unsigned i = 0; ie->XFloor.ffloors.Size(); i++) { rover = newsec->e->XFloor.ffloors[i]; - if(!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; + if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(x, y); - fixed_t ff_top=rover->top.plane->ZatPoint(x, y); - - delta1 = thing->z - (ff_bottom + ((ff_top-ff_bottom)/2)); - delta2 = thingtop - (ff_bottom + ((ff_top-ff_bottom)/2)); + fixed_t ff_bottom = rover->bottom.plane->ZatPoint(x, y); + fixed_t ff_top = rover->top.plane->ZatPoint(x, y); - if(ff_top > tm.floorz && abs(delta1) < abs(delta2)) + delta1 = thing->z - (ff_bottom + ((ff_top - ff_bottom) / 2)); + delta2 = thingtop - (ff_bottom + ((ff_top - ff_bottom) / 2)); + + if (ff_top > tm.floorz && abs(delta1) < abs(delta2)) { tm.floorz = tm.dropoffz = ff_top; tm.floorpic = *rover->top.texture; } - if(ff_bottom < tm.ceilingz && abs(delta1) >= abs(delta2)) + if (ff_bottom < tm.ceilingz && abs(delta1) >= abs(delta2)) { tm.ceilingz = ff_bottom; tm.ceilingpic = *rover->bottom.texture; @@ -1351,13 +1351,13 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, b } } #endif - + validcount++; - spechit.Clear (); + spechit.Clear(); if ((thing->flags & MF_NOCLIP) && !(thing->flags & MF_SKULLFLY)) return true; - + // Check things first, possibly picking things up. thing->BlockingMobj = NULL; thingblocker = NULL; @@ -1376,9 +1376,9 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, b { if (!PIT_CheckThing(th, tm)) { // [RH] If a thing can be stepped up on, we need to continue checking - // other things in the blocks and see if we hit something that is - // definitely blocking. Otherwise, we need to check the lines, or we - // could end up stuck inside a wall. + // other things in the blocks and see if we hit something that is + // definitely blocking. Otherwise, we need to check the lines, or we + // could end up stuck inside a wall. AActor *BlockingMobj = thing->BlockingMobj; if (BlockingMobj == NULL || (i_compatflags & COMPATF_NO_PASSMOBJ)) @@ -1386,8 +1386,8 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, b thing->height = realheight; return false; } - else if (!BlockingMobj->player && !(thing->flags & (MF_FLOAT|MF_MISSILE|MF_SKULLFLY)) && - BlockingMobj->z+BlockingMobj->height-thing->z <= thing->MaxStepHeight) + else if (!BlockingMobj->player && !(thing->flags & (MF_FLOAT | MF_MISSILE | MF_SKULLFLY)) && + BlockingMobj->z + BlockingMobj->height - thing->z <= thing->MaxStepHeight) { if (thingblocker == NULL || BlockingMobj->z > thingblocker->z) @@ -1401,7 +1401,7 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, b { if (thingblocker) { // There is something to step up on. Return this thing as - // the blocker so that we don't step up. + // the blocker so that we don't step up. thing->height = realheight; return false; } @@ -1469,7 +1469,7 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, b return (thing->BlockingMobj = thingblocker) == NULL; } -bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, bool actorsonly) +bool P_CheckPosition(AActor *thing, fixed_t x, fixed_t y, bool actorsonly) { FCheckPosition tm; return P_CheckPosition(thing, x, y, tm, actorsonly); @@ -1484,7 +1484,7 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, bool actorsonly) // //---------------------------------------------------------------------------- -bool P_TestMobjLocation (AActor *mobj) +bool P_TestMobjLocation(AActor *mobj) { int flags; @@ -1511,15 +1511,15 @@ bool P_TestMobjLocation (AActor *mobj) // Checks if the new Z position is legal //============================================================================= -AActor *P_CheckOnmobj (AActor *thing) +AActor *P_CheckOnmobj(AActor *thing) { fixed_t oldz; bool good; AActor *onmobj; oldz = thing->z; - P_FakeZMovement (thing); - good = P_TestMobjZ (thing, false, &onmobj); + P_FakeZMovement(thing); + good = P_TestMobjZ(thing, false, &onmobj); thing->z = oldz; return good ? NULL : onmobj; @@ -1531,7 +1531,7 @@ AActor *P_CheckOnmobj (AActor *thing) // //============================================================================= -bool P_TestMobjZ (AActor *actor, bool quick, AActor **pOnmobj) +bool P_TestMobjZ(AActor *actor, bool quick, AActor **pOnmobj) { AActor *onmobj = NULL; if (actor->flags & MF_NOCLIP) @@ -1561,7 +1561,7 @@ bool P_TestMobjZ (AActor *actor, bool quick, AActor **pOnmobj) { // Can't hit thing continue; } - if (thing->flags & (MF_SPECIAL|MF_NOCLIP)) + if (thing->flags & (MF_SPECIAL | MF_NOCLIP)) { // [RH] Specials and noclippers don't block moves continue; } @@ -1582,11 +1582,11 @@ bool P_TestMobjZ (AActor *actor, bool quick, AActor **pOnmobj) { // Don't clip against whoever shot the missile. continue; } - if (actor->z > thing->z+thing->height) + if (actor->z > thing->z + thing->height) { // over thing continue; } - else if (actor->z+actor->height <= thing->z) + else if (actor->z + actor->height <= thing->z) { // under thing continue; } @@ -1609,32 +1609,32 @@ bool P_TestMobjZ (AActor *actor, bool quick, AActor **pOnmobj) // Fake the zmovement so that we can check if a move is legal //============================================================================= -void P_FakeZMovement (AActor *mo) +void P_FakeZMovement(AActor *mo) { -// -// adjust height -// + // + // adjust height + // mo->z += mo->velz; if ((mo->flags&MF_FLOAT) && mo->target) { // float down towards target if too close if (!(mo->flags & MF_SKULLFLY) && !(mo->flags & MF_INFLOAT)) { - fixed_t dist = P_AproxDistance (mo->x - mo->target->x, mo->y - mo->target->y); - fixed_t delta = (mo->target->z + (mo->height>>1)) - mo->z; - if (delta < 0 && dist < -(delta*3)) + fixed_t dist = P_AproxDistance(mo->x - mo->target->x, mo->y - mo->target->y); + fixed_t delta = (mo->target->z + (mo->height >> 1)) - mo->z; + if (delta < 0 && dist < -(delta * 3)) mo->z -= mo->FloatSpeed; - else if (delta > 0 && dist < (delta*3)) + else if (delta > 0 && dist < (delta * 3)) mo->z += mo->FloatSpeed; } } if (mo->player && mo->flags&MF_NOGRAVITY && (mo->z > mo->floorz) && !mo->IsNoClip2()) { - mo->z += finesine[(FINEANGLES/80*level.maptime)&FINEMASK]/8; + mo->z += finesine[(FINEANGLES / 80 * level.maptime)&FINEMASK] / 8; } -// -// clip movement -// + // + // clip movement + // if (mo->z <= mo->floorz) { // hit the floor mo->z = mo->floorz; @@ -1652,13 +1652,13 @@ void P_FakeZMovement (AActor *mo) // //=========================================================================== -static void CheckForPushSpecial (line_t *line, int side, AActor *mobj, bool windowcheck) +static void CheckForPushSpecial(line_t *line, int side, AActor *mobj, bool windowcheck) { if (line->special && !(mobj->flags6 & MF6_NOTRIGGER)) { if (windowcheck && !(ib_compatflags & BCOMPATF_NOWINDOWCHECK) && line->backsector != NULL) { // Make sure this line actually blocks us and is not a window - // or similar construct we are standing inside of. + // or similar construct we are standing inside of. fixed_t fzt = line->frontsector->ceilingplane.ZatPoint(mobj->x, mobj->y); fixed_t fzb = line->frontsector->floorplane.ZatPoint(mobj->x, mobj->y); fixed_t bzt = line->backsector->ceilingplane.ZatPoint(mobj->x, mobj->y); @@ -1667,29 +1667,29 @@ static void CheckForPushSpecial (line_t *line, int side, AActor *mobj, bool wind fzb <= mobj->z && bzb <= mobj->z) { // we must also check if some 3D floor in the backsector may be blocking - #ifdef _3DFLOORS - for(unsigned int i=0;ibacksector->e->XFloor.ffloors.Size();i++) +#ifdef _3DFLOORS + for (unsigned int i = 0; ibacksector->e->XFloor.ffloors.Size(); i++) + { + F3DFloor* rover = line->backsector->e->XFloor.ffloors[i]; + + if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; + + fixed_t ff_bottom = rover->bottom.plane->ZatPoint(mobj->x, mobj->y); + fixed_t ff_top = rover->top.plane->ZatPoint(mobj->x, mobj->y); + + if (ff_bottom < mobj->z + mobj->height && ff_top > mobj->z) { - F3DFloor* rover = line->backsector->e->XFloor.ffloors[i]; - - if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; - - fixed_t ff_bottom = rover->bottom.plane->ZatPoint(mobj->x, mobj->y); - fixed_t ff_top = rover->top.plane->ZatPoint(mobj->x, mobj->y); - - if (ff_bottom < mobj->z + mobj->height && ff_top > mobj->z) - { - goto isblocking; - } + goto isblocking; } - #endif + } +#endif return; } } -isblocking: + isblocking: if (mobj->flags2 & MF2_PUSHWALL) { - P_ActivateLine (line, mobj, side, SPAC_Push); + P_ActivateLine(line, mobj, side, SPAC_Push); } else if (mobj->flags2 & MF2_IMPACT) { @@ -1697,13 +1697,13 @@ isblocking: !(mobj->flags & MF_MISSILE) || (mobj->target == NULL)) { - P_ActivateLine (line, mobj, side, SPAC_Impact); + P_ActivateLine(line, mobj, side, SPAC_Impact); } else { - P_ActivateLine (line, mobj->target, side, SPAC_Impact); + P_ActivateLine(line, mobj->target, side, SPAC_Impact); } - } + } } } @@ -1715,11 +1715,11 @@ isblocking: // //========================================================================== -bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, - int dropoff, // killough 3/15/98: allow dropoff as option - const secplane_t *onfloor, // [RH] Let P_TryMove keep the thing on the floor - FCheckPosition &tm, - bool missileCheck) // [GZ] Fired missiles ignore the drop-off test +bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, + int dropoff, // killough 3/15/98: allow dropoff as option + const secplane_t *onfloor, // [RH] Let P_TryMove keep the thing on the floor + FCheckPosition &tm, + bool missileCheck) // [GZ] Fired missiles ignore the drop-off test { fixed_t oldx; fixed_t oldy; @@ -1734,10 +1734,10 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, oldz = thing->z; if (onfloor) { - thing->z = onfloor->ZatPoint (x, y); + thing->z = onfloor->ZatPoint(x, y); } thing->flags6 |= MF6_INTRYMOVE; - if (!P_CheckPosition (thing, x, y, tm)) + if (!P_CheckPosition(thing, x, y, tm)) { AActor *BlockingMobj = thing->BlockingMobj; // Solid wall or thing @@ -1751,11 +1751,11 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, { goto pushline; } - else if (BlockingMobj->z+BlockingMobj->height-thing->z + else if (BlockingMobj->z + BlockingMobj->height - thing->z > thing->MaxStepHeight - || (BlockingMobj->Sector->ceilingplane.ZatPoint (x, y) - - (BlockingMobj->z+BlockingMobj->height) < thing->height) - || (tm.ceilingz-(BlockingMobj->z+BlockingMobj->height) + || (BlockingMobj->Sector->ceilingplane.ZatPoint(x, y) + - (BlockingMobj->z + BlockingMobj->height) < thing->height) + || (tm.ceilingz - (BlockingMobj->z + BlockingMobj->height) < thing->height)) { goto pushline; @@ -1790,7 +1790,7 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, } tm.floatok = true; - + if (!(thing->flags & MF_TELEPORT) && tm.ceilingz - thing->z < thing->height && !(thing->flags3 & MF3_CEILINGHUGGER) @@ -1801,19 +1801,19 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, if (thing->flags2 & MF2_FLY && thing->flags & MF_NOGRAVITY) { #if 1 - if (thing->z+thing->height > tm.ceilingz) + if (thing->z + thing->height > tm.ceilingz) goto pushline; #else // When flying, slide up or down blocking lines until the actor // is not blocked. - if (thing->z+thing->height > tm.ceilingz) + if (thing->z + thing->height > tm.ceilingz) { - thing->velz = -8*FRACUNIT; + thing->velz = -8 * FRACUNIT; goto pushline; } - else if (thing->z < tm.floorz && tm.floorz-tm.dropoffz > thing->MaxDropOffHeight) + else if (thing->z < tm.floorz && tm.floorz - tm.dropoffz > thing->MaxDropOffHeight) { - thing->velz = 8*FRACUNIT; + thing->velz = 8 * FRACUNIT; goto pushline; } #endif @@ -1824,7 +1824,7 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, { // [RH] Don't let normal missiles climb steps goto pushline; } - if (tm.floorz-thing->z > thing->MaxStepHeight) + if (tm.floorz - thing->z > thing->MaxStepHeight) { // too big a step up goto pushline; } @@ -1833,7 +1833,7 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, fixed_t savedz = thing->z; bool good; thing->z = tm.floorz; - good = P_TestMobjZ (thing); + good = P_TestMobjZ(thing); thing->z = savedz; if (!good) { @@ -1848,7 +1848,7 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, // If it's a bouncer, let it bounce off its new floor, too. if (thing->BounceFlags & BOUNCE_Floors) { - thing->FloorBounceMissile (tm.floorsector->floorplane); + thing->FloorBounceMissile(tm.floorsector->floorplane); } else { @@ -1866,15 +1866,15 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, dropoff = false; } - if (dropoff==2 && // large jump down (e.g. dogs) - (tm.floorz-tm.dropoffz > 128*FRACUNIT || thing->target == NULL || thing->target->z >tm.dropoffz)) + if (dropoff == 2 && // large jump down (e.g. dogs) + (tm.floorz - tm.dropoffz > 128 * FRACUNIT || thing->target == NULL || thing->target->z >tm.dropoffz)) { dropoff = false; } // killough 3/15/98: Allow certain objects to drop off - if ((!dropoff && !(thing->flags & (MF_DROPOFF|MF_FLOAT|MF_MISSILE))) || (thing->flags5&MF5_NODROPOFF)) + if ((!dropoff && !(thing->flags & (MF_DROPOFF | MF_FLOAT | MF_MISSILE))) || (thing->flags5&MF5_NODROPOFF)) { if (!(thing->flags5&MF5_AVOIDINGDROPOFF)) { @@ -1885,11 +1885,11 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, { floorz = MAX(thing->z, tm.floorz); } - + if (floorz - tm.dropoffz > thing->MaxDropOffHeight && - !(thing->flags2 & MF2_BLASTED) && !missileCheck) + !(thing->flags2 & MF2_BLASTED) && !missileCheck) { // Can't move over a dropoff unless it's been blasted - // [GZ] Or missile-spawned + // [GZ] Or missile-spawned thing->z = oldz; thing->flags6 &= ~MF6_INTRYMOVE; return false; @@ -1909,18 +1909,18 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, } if (thing->flags2 & MF2_CANTLEAVEFLOORPIC && (tm.floorpic != thing->floorpic - || tm.floorz - thing->z != 0)) + || tm.floorz - thing->z != 0)) { // must stay within a sector of a certain floor type thing->z = oldz; thing->flags6 &= ~MF6_INTRYMOVE; return false; } - + //Added by MC: To prevent bot from getting into dangerous sectors. if (thing->player && thing->player->isbot && thing->flags & MF_SHOOTABLE) { if (tm.sector != thing->Sector - && bglobal.IsDangerous (tm.sector)) + && bglobal.IsDangerous(tm.sector)) { thing->player->prev = thing->player->dest; thing->player->dest = NULL; @@ -1930,7 +1930,7 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, thing->flags6 &= ~MF6_INTRYMOVE; return false; } - } + } } // [RH] Check status of eyes against fake floor/ceiling in case @@ -1938,7 +1938,7 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, bool oldAboveFakeFloor, oldAboveFakeCeiling; fixed_t viewheight; - + viewheight = thing->player ? thing->player->viewheight : thing->height / 2; oldAboveFakeFloor = oldAboveFakeCeiling = false; // pacify GCC @@ -1946,21 +1946,21 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, { fixed_t eyez = oldz + viewheight; - oldAboveFakeFloor = eyez > oldsec->heightsec->floorplane.ZatPoint (thing->x, thing->y); - oldAboveFakeCeiling = eyez > oldsec->heightsec->ceilingplane.ZatPoint (thing->x, thing->y); + oldAboveFakeFloor = eyez > oldsec->heightsec->floorplane.ZatPoint(thing->x, thing->y); + oldAboveFakeCeiling = eyez > oldsec->heightsec->ceilingplane.ZatPoint(thing->x, thing->y); } // Borrowed from MBF: if (thing->BounceFlags & BOUNCE_MBF && // killough 8/13/98 - !(thing->flags & (MF_MISSILE|MF_NOGRAVITY)) && - !thing->IsSentient() && tm.floorz - thing->z > 16*FRACUNIT) + !(thing->flags & (MF_MISSILE | MF_NOGRAVITY)) && + !thing->IsSentient() && tm.floorz - thing->z > 16 * FRACUNIT) { // too big a step up for MBF bouncers under gravity thing->flags6 &= ~MF6_INTRYMOVE; return false; } // the move is ok, so link the thing into its new position - thing->UnlinkFromWorld (); + thing->UnlinkFromWorld(); oldx = thing->x; oldy = thing->y; @@ -1974,11 +1974,11 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, thing->x = x; thing->y = y; - thing->LinkToWorld (); + thing->LinkToWorld(); if (thing->flags2 & MF2_FLOORCLIP) { - thing->AdjustFloorClip (); + thing->AdjustFloorClip(); } // [RH] Don't activate anything if just predicting @@ -1989,36 +1989,36 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, } // if any special lines were hit, do the effect - if (!(thing->flags & (MF_TELEPORT|MF_NOCLIP))) + if (!(thing->flags & (MF_TELEPORT | MF_NOCLIP))) { - while (spechit.Pop (ld)) + while (spechit.Pop(ld)) { // see if the line was crossed - side = P_PointOnLineSide (thing->x, thing->y, ld); - oldside = P_PointOnLineSide (oldx, oldy, ld); + side = P_PointOnLineSide(thing->x, thing->y, ld); + oldside = P_PointOnLineSide(oldx, oldy, ld); if (side != oldside && ld->special && !(thing->flags6 & MF6_NOTRIGGER)) { if (thing->player) { - P_ActivateLine (ld, thing, oldside, SPAC_Cross); + P_ActivateLine(ld, thing, oldside, SPAC_Cross); } else if (thing->flags2 & MF2_MCROSS) { - P_ActivateLine (ld, thing, oldside, SPAC_MCross); + P_ActivateLine(ld, thing, oldside, SPAC_MCross); } else if (thing->flags2 & MF2_PCROSS) { - P_ActivateLine (ld, thing, oldside, SPAC_PCross); + P_ActivateLine(ld, thing, oldside, SPAC_PCross); } else if ((ld->special == Teleport || - ld->special == Teleport_NoFog || - ld->special == Teleport_Line)) + ld->special == Teleport_NoFog || + ld->special == Teleport_Line)) { // [RH] Just a little hack for BOOM compatibility - P_ActivateLine (ld, thing, oldside, SPAC_MCross); + P_ActivateLine(ld, thing, oldside, SPAC_MCross); } else { - P_ActivateLine (ld, thing, oldside, SPAC_AnyCross); + P_ActivateLine(ld, thing, oldside, SPAC_AnyCross); } } } @@ -2030,27 +2030,27 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, { const sector_t *hs = newsec->heightsec; fixed_t eyez = thing->z + viewheight; - fixed_t fakez = hs->floorplane.ZatPoint (x, y); + fixed_t fakez = hs->floorplane.ZatPoint(x, y); if (!oldAboveFakeFloor && eyez > fakez) { // View went above fake floor - newsec->SecActTarget->TriggerAction (thing, SECSPAC_EyesSurface); + newsec->SecActTarget->TriggerAction(thing, SECSPAC_EyesSurface); } else if (oldAboveFakeFloor && eyez <= fakez) { // View went below fake floor - newsec->SecActTarget->TriggerAction (thing, SECSPAC_EyesDive); + newsec->SecActTarget->TriggerAction(thing, SECSPAC_EyesDive); } if (!(hs->MoreFlags & SECF_FAKEFLOORONLY)) { - fakez = hs->ceilingplane.ZatPoint (x, y); + fakez = hs->ceilingplane.ZatPoint(x, y); if (!oldAboveFakeCeiling && eyez > fakez) { // View went above fake ceiling - newsec->SecActTarget->TriggerAction (thing, SECSPAC_EyesAboveC); + newsec->SecActTarget->TriggerAction(thing, SECSPAC_EyesAboveC); } else if (oldAboveFakeCeiling && eyez <= fakez) { // View went below fake ceiling - newsec->SecActTarget->TriggerAction (thing, SECSPAC_EyesBelowC); + newsec->SecActTarget->TriggerAction(thing, SECSPAC_EyesBelowC); } } } @@ -2070,29 +2070,29 @@ pushline: } thing->z = oldz; - if (!(thing->flags&(MF_TELEPORT|MF_NOCLIP))) + if (!(thing->flags&(MF_TELEPORT | MF_NOCLIP))) { int numSpecHitTemp; if (tm.thing->flags2 & MF2_BLASTED) { - P_DamageMobj (tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee); + P_DamageMobj(tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee); } - numSpecHitTemp = (int)spechit.Size (); + numSpecHitTemp = (int)spechit.Size(); while (numSpecHitTemp > 0) { // see which lines were pushed ld = spechit[--numSpecHitTemp]; - side = P_PointOnLineSide (thing->x, thing->y, ld); - CheckForPushSpecial (ld, side, thing, true); + side = P_PointOnLineSide(thing->x, thing->y, ld); + CheckForPushSpecial(ld, side, thing, true); } } return false; } -bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, - int dropoff, // killough 3/15/98: allow dropoff as option - const secplane_t *onfloor) // [RH] Let P_TryMove keep the thing on the floor +bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, + int dropoff, // killough 3/15/98: allow dropoff as option + const secplane_t *onfloor) // [RH] Let P_TryMove keep the thing on the floor { FCheckPosition tm; return P_TryMove(thing, x, y, dropoff, onfloor, tm); @@ -2112,7 +2112,7 @@ bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) FCheckPosition tm; fixed_t newz = thing->z; - if (!P_CheckPosition (thing, x, y, tm)) + if (!P_CheckPosition(thing, x, y, tm)) { return false; } @@ -2142,12 +2142,12 @@ bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) } if (thing->flags2 & MF2_FLY && thing->flags & MF_NOGRAVITY) { - if (thing->z+thing->height > tm.ceilingz) + if (thing->z + thing->height > tm.ceilingz) return false; } if (!(thing->flags & MF_TELEPORT) && !(thing->flags3 & MF3_FLOORHUGGER)) { - if (tm.floorz-newz > thing->MaxStepHeight) + if (tm.floorz - newz > thing->MaxStepHeight) { // too big a step up return false; } @@ -2159,7 +2159,7 @@ bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) { // [RH] Check to make sure there's nothing in the way for the step up fixed_t savedz = thing->z; thing->z = newz = tm.floorz; - bool good = P_TestMobjZ (thing); + bool good = P_TestMobjZ(thing); thing->z = savedz; if (!good) { @@ -2170,7 +2170,7 @@ bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) if (thing->flags2 & MF2_CANTLEAVEFLOORPIC && (tm.floorpic != thing->floorpic - || tm.floorz - newz != 0)) + || tm.floorz - newz != 0)) { // must stay within a sector of a certain floor type return false; } @@ -2202,12 +2202,12 @@ struct FSlide fixed_t tmymove; void HitSlideLine(line_t *ld); - void SlideTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy); - void SlideMove (AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps); + void SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy); + void SlideMove(AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps); // The bouncing code uses the same data structure - bool BounceTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy); - bool BounceWall (AActor *mo); + bool BounceTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy); + bool BounceWall(AActor *mo); }; //========================================================================== @@ -2219,17 +2219,17 @@ struct FSlide // //========================================================================== -void FSlide::HitSlideLine (line_t* ld) +void FSlide::HitSlideLine(line_t* ld) { int side; angle_t lineangle; angle_t moveangle; angle_t deltaangle; - + fixed_t movelen; bool icyfloor; // is floor icy? // phares - // | + // | // Under icy conditions, if the angle of approach to the wall // V // is more than 45 degrees, then you'll bounce and lose half // your velocity. If less than 45 degrees, you'll slide along @@ -2238,21 +2238,21 @@ void FSlide::HitSlideLine (line_t* ld) // Check for the special cases of horz or vert walls. // killough 10/98: only bounce if hit hard (prevents wobbling) - icyfloor = - (P_AproxDistance(tmxmove, tmymove) > 4*FRACUNIT) && + icyfloor = + (P_AproxDistance(tmxmove, tmymove) > 4 * FRACUNIT) && var_friction && // killough 8/28/98: calc friction on demand slidemo->z <= slidemo->floorz && - P_GetFriction (slidemo, NULL) > ORIG_FRICTION; + P_GetFriction(slidemo, NULL) > ORIG_FRICTION; if (ld->dx == 0) { // ST_VERTICAL if (icyfloor && (abs(tmxmove) > abs(tmymove))) { - tmxmove = -tmxmove/2; // absorb half the velocity + tmxmove = -tmxmove / 2; // absorb half the velocity tmymove /= 2; if (slidemo->player && slidemo->health > 0 && !(slidemo->player->cheats & CF_PREDICTING)) { - S_Sound (slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff!// ^ + S_Sound(slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff!// ^ } } // | else // phares @@ -2265,10 +2265,10 @@ void FSlide::HitSlideLine (line_t* ld) if (icyfloor && (abs(tmymove) > abs(tmxmove))) { tmxmove /= 2; // absorb half the velocity - tmymove = -tmymove/2; + tmymove = -tmymove / 2; if (slidemo->player && slidemo->health > 0 && !(slidemo->player->cheats & CF_PREDICTING)) { - S_Sound (slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff! + S_Sound(slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff! } } else @@ -2279,30 +2279,30 @@ void FSlide::HitSlideLine (line_t* ld) // The wall is angled. Bounce if the angle of approach is // phares // less than 45 degrees. // phares - side = P_PointOnLineSide (slidemo->x, slidemo->y, ld); + side = P_PointOnLineSide(slidemo->x, slidemo->y, ld); - lineangle = R_PointToAngle2 (0,0, ld->dx, ld->dy); + lineangle = R_PointToAngle2(0, 0, ld->dx, ld->dy); if (side == 1) lineangle += ANG180; - moveangle = R_PointToAngle2 (0,0, tmxmove, tmymove); + moveangle = R_PointToAngle2(0, 0, tmxmove, tmymove); moveangle += 10; // prevents sudden path reversal due to // phares - // rounding error // | - deltaangle = moveangle-lineangle; // V - movelen = P_AproxDistance (tmxmove, tmymove); - if (icyfloor && (deltaangle > ANG45) && (deltaangle < ANG90+ANG45)) + // rounding error // | + deltaangle = moveangle - lineangle; // V + movelen = P_AproxDistance(tmxmove, tmymove); + if (icyfloor && (deltaangle > ANG45) && (deltaangle < ANG90 + ANG45)) { moveangle = lineangle - deltaangle; movelen /= 2; // absorb if (slidemo->player && slidemo->health > 0 && !(slidemo->player->cheats & CF_PREDICTING)) { - S_Sound (slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff! + S_Sound(slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff! } moveangle >>= ANGLETOFINESHIFT; - tmxmove = FixedMul (movelen, finecosine[moveangle]); - tmymove = FixedMul (movelen, finesine[moveangle]); + tmxmove = FixedMul(movelen, finecosine[moveangle]); + tmymove = FixedMul(movelen, finesine[moveangle]); } // ^ else // | { // phares @@ -2311,7 +2311,7 @@ void FSlide::HitSlideLine (line_t* ld) if (i_compatflags & COMPATF_WALLRUN) { fixed_t newlen; - + if (deltaangle > ANG180) deltaangle += ANG180; // I_Error ("SlideLine: ang>ANG180"); @@ -2319,17 +2319,17 @@ void FSlide::HitSlideLine (line_t* ld) lineangle >>= ANGLETOFINESHIFT; deltaangle >>= ANGLETOFINESHIFT; - newlen = FixedMul (movelen, finecosine[deltaangle]); + newlen = FixedMul(movelen, finecosine[deltaangle]); - tmxmove = FixedMul (newlen, finecosine[lineangle]); - tmymove = FixedMul (newlen, finesine[lineangle]); + tmxmove = FixedMul(newlen, finecosine[lineangle]); + tmymove = FixedMul(newlen, finesine[lineangle]); } else { divline_t dll, dlv; fixed_t inter1, inter2, inter3; - P_MakeDivline (ld, &dll); + P_MakeDivline(ld, &dll); dlv.x = slidemo->x; dlv.y = slidemo->y; @@ -2340,13 +2340,13 @@ void FSlide::HitSlideLine (line_t* ld) dlv.dx = tmxmove; dlv.dy = tmymove; - inter2 = P_InterceptVector (&dll, &dlv); - inter3 = P_InterceptVector (&dlv, &dll); + inter2 = P_InterceptVector(&dll, &dlv); + inter3 = P_InterceptVector(&dlv, &dll); if (inter3 != 0) { - tmxmove = Scale (inter2-inter1, dll.dx, inter3); - tmymove = Scale (inter2-inter1, dll.dy, inter3); + tmxmove = Scale(inter2 - inter1, dll.dx, inter3); + tmymove = Scale(inter2 - inter1, dll.dy, inter3); } else { @@ -2363,7 +2363,7 @@ void FSlide::HitSlideLine (line_t* ld) // //========================================================================== -void FSlide::SlideTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy) +void FSlide::SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy) { FLineOpening open; FPathTraverse it(startx, starty, endx, endy, PT_ADDLINES); @@ -2372,26 +2372,26 @@ void FSlide::SlideTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_ while ((in = it.Next())) { line_t* li; - + if (!in->isaline) { // should never happen - Printf ("PTR_SlideTraverse: not a line?"); + Printf("PTR_SlideTraverse: not a line?"); continue; } - + li = in->d.line; - - if ( !(li->flags & ML_TWOSIDED) || !li->backsector ) + + if (!(li->flags & ML_TWOSIDED) || !li->backsector) { - if (P_PointOnLineSide (slidemo->x, slidemo->y, li)) + if (P_PointOnLineSide(slidemo->x, slidemo->y, li)) { // don't hit the back side - continue; + continue; } goto isblocking; } - if (li->flags & (ML_BLOCKING|ML_BLOCKEVERYTHING)) + if (li->flags & (ML_BLOCKING | ML_BLOCKEVERYTHING)) { goto isblocking; } @@ -2406,12 +2406,12 @@ void FSlide::SlideTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_ } // set openrange, opentop, openbottom - P_LineOpening (open, slidemo, li, it.Trace().x + FixedMul (it.Trace().dx, in->frac), - it.Trace().y + FixedMul (it.Trace().dy, in->frac)); - + P_LineOpening(open, slidemo, li, it.Trace().x + FixedMul(it.Trace().dx, in->frac), + it.Trace().y + FixedMul(it.Trace().dy, in->frac)); + if (open.range < slidemo->height) goto isblocking; // doesn't fit - + if (open.top - slidemo->z < slidemo->height) goto isblocking; // mobj is too high @@ -2423,7 +2423,7 @@ void FSlide::SlideTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_ { // [RH] Check to make sure there's nothing in the way for the step up fixed_t savedz = slidemo->z; slidemo->z = open.bottom; - bool good = P_TestMobjZ (slidemo); + bool good = P_TestMobjZ(slidemo); slidemo->z = savedz; if (!good) { @@ -2432,11 +2432,11 @@ void FSlide::SlideTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_ } // this line doesn't block movement - continue; - + continue; + // the line does block movement, // see if it is closer than best so far - isblocking: + isblocking: if (in->frac < bestslidefrac) { secondslidefrac = bestslidefrac; @@ -2444,7 +2444,7 @@ void FSlide::SlideTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_ bestslidefrac = in->frac; bestslideline = li; } - + return; // stop } } @@ -2463,7 +2463,7 @@ void FSlide::SlideTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_ // //========================================================================== -void FSlide::SlideMove (AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) +void FSlide::SlideMove(AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) { fixed_t leadx, leady; fixed_t trailx, traily; @@ -2477,11 +2477,11 @@ void FSlide::SlideMove (AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) if (mo->player && mo->player->mo == mo && mo->reactiontime > 0) return; // player coming right out of a teleporter. - - retry: + +retry: if (!--hitcount) goto stairstep; // don't loop forever - + // trace along the three leading corners if (tryx > 0) { @@ -2505,42 +2505,42 @@ void FSlide::SlideMove (AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) traily = mo->y + mo->radius; } - bestslidefrac = FRACUNIT+1; - - SlideTraverse (leadx, leady, leadx+tryx, leady+tryy); - SlideTraverse (trailx, leady, trailx+tryx, leady+tryy); - SlideTraverse (leadx, traily, leadx+tryx, traily+tryy); + bestslidefrac = FRACUNIT + 1; + + SlideTraverse(leadx, leady, leadx + tryx, leady + tryy); + SlideTraverse(trailx, leady, trailx + tryx, leady + tryy); + SlideTraverse(leadx, traily, leadx + tryx, traily + tryy); // move up to the wall - if (bestslidefrac == FRACUNIT+1) + if (bestslidefrac == FRACUNIT + 1) { // the move must have hit the middle, so stairstep - stairstep: + stairstep: // killough 3/15/98: Allow objects to drop off ledges xmove = 0, ymove = tryy; - walkplane = P_CheckSlopeWalk (mo, xmove, ymove); - if (!P_TryMove (mo, mo->x + xmove, mo->y + ymove, true, walkplane)) + walkplane = P_CheckSlopeWalk(mo, xmove, ymove); + if (!P_TryMove(mo, mo->x + xmove, mo->y + ymove, true, walkplane)) { xmove = tryx, ymove = 0; - walkplane = P_CheckSlopeWalk (mo, xmove, ymove); - P_TryMove (mo, mo->x + xmove, mo->y + ymove, true, walkplane); + walkplane = P_CheckSlopeWalk(mo, xmove, ymove); + P_TryMove(mo, mo->x + xmove, mo->y + ymove, true, walkplane); } return; } // fudge a bit to make sure it doesn't hit - bestslidefrac -= FRACUNIT/32; + bestslidefrac -= FRACUNIT / 32; if (bestslidefrac > 0) { - newx = FixedMul (tryx, bestslidefrac); - newy = FixedMul (tryy, bestslidefrac); + newx = FixedMul(tryx, bestslidefrac); + newy = FixedMul(tryy, bestslidefrac); // [BL] We need to abandon this function if we end up going through a teleporter const fixed_t startvelx = mo->velx; const fixed_t startvely = mo->vely; // killough 3/15/98: Allow objects to drop off ledges - if (!P_TryMove (mo, mo->x+newx, mo->y+newy, true)) + if (!P_TryMove(mo, mo->x + newx, mo->y + newy, true)) goto stairstep; if (mo->velx != startvelx || mo->vely != startvely) @@ -2548,16 +2548,16 @@ void FSlide::SlideMove (AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) } // Now continue along the wall. - bestslidefrac = FRACUNIT - (bestslidefrac + FRACUNIT/32); // remainder + bestslidefrac = FRACUNIT - (bestslidefrac + FRACUNIT / 32); // remainder if (bestslidefrac > FRACUNIT) bestslidefrac = FRACUNIT; else if (bestslidefrac <= 0) return; - tryx = tmxmove = FixedMul (tryx, bestslidefrac); - tryy = tmymove = FixedMul (tryy, bestslidefrac); + tryx = tmxmove = FixedMul(tryx, bestslidefrac); + tryy = tmymove = FixedMul(tryy, bestslidefrac); - HitSlideLine (bestslideline); // clip the moves + HitSlideLine(bestslideline); // clip the moves mo->velx = tmxmove * numsteps; mo->vely = tmymove * numsteps; @@ -2571,16 +2571,16 @@ void FSlide::SlideMove (AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) mo->player->vely = mo->vely; } - walkplane = P_CheckSlopeWalk (mo, tmxmove, tmymove); + walkplane = P_CheckSlopeWalk(mo, tmxmove, tmymove); // killough 3/15/98: Allow objects to drop off ledges - if (!P_TryMove (mo, mo->x+tmxmove, mo->y+tmymove, true, walkplane)) + if (!P_TryMove(mo, mo->x + tmxmove, mo->y + tmymove, true, walkplane)) { goto retry; } } -void P_SlideMove (AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) +void P_SlideMove(AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) { FSlide slide; slide.SlideMove(mo, tryx, tryy, numsteps); @@ -2592,7 +2592,7 @@ void P_SlideMove (AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) // //============================================================================ -const secplane_t * P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymove) +const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymove) { static secplane_t copyplane; if (actor->flags & MF_NOGRAVITY) @@ -2601,40 +2601,40 @@ const secplane_t * P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymo } const secplane_t *plane = &actor->floorsector->floorplane; - fixed_t planezhere = plane->ZatPoint (actor->x, actor->y); + fixed_t planezhere = plane->ZatPoint(actor->x, actor->y); #ifdef _3DFLOORS - for(unsigned int i=0;ifloorsector->e->XFloor.ffloors.Size();i++) + for (unsigned int i = 0; ifloorsector->e->XFloor.ffloors.Size(); i++) { - F3DFloor * rover= actor->floorsector->e->XFloor.ffloors[i]; - if(!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; + F3DFloor * rover = actor->floorsector->e->XFloor.ffloors[i]; + if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; fixed_t thisplanez = rover->top.plane->ZatPoint(actor->x, actor->y); - if (thisplanez>planezhere && thisplanez<=actor->z + actor->MaxStepHeight) + if (thisplanez>planezhere && thisplanez <= actor->z + actor->MaxStepHeight) { copyplane = *rover->top.plane; if (copyplane.c<0) copyplane.FlipVert(); plane = ©plane; - planezhere=thisplanez; + planezhere = thisplanez; } } if (actor->floorsector != actor->Sector) { - for(unsigned int i=0;iSector->e->XFloor.ffloors.Size();i++) + for (unsigned int i = 0; iSector->e->XFloor.ffloors.Size(); i++) { - F3DFloor * rover= actor->Sector->e->XFloor.ffloors[i]; - if(!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; + F3DFloor * rover = actor->Sector->e->XFloor.ffloors[i]; + if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; fixed_t thisplanez = rover->top.plane->ZatPoint(actor->x, actor->y); - if (thisplanez>planezhere && thisplanez<=actor->z + actor->MaxStepHeight) + if (thisplanez>planezhere && thisplanez <= actor->z + actor->MaxStepHeight) { copyplane = *rover->top.plane; if (copyplane.c<0) copyplane.FlipVert(); plane = ©plane; - planezhere=thisplanez; + planezhere = thisplanez; } } } @@ -2643,7 +2643,7 @@ const secplane_t * P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymo if (actor->floorsector != actor->Sector) { // this additional check prevents sliding on sloped dropoffs - if (planezhere>actor->floorz+4*FRACUNIT) + if (planezhere>actor->floorz + 4 * FRACUNIT) return NULL; } @@ -2659,10 +2659,10 @@ const secplane_t * P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymo destx = actor->x + xmove; desty = actor->y + ymove; - t = TMulScale16 (plane->a, destx, plane->b, desty, plane->c, actor->z) + plane->d; + t = TMulScale16(plane->a, destx, plane->b, desty, plane->c, actor->z) + plane->d; if (t < 0) { // Desired location is behind (below) the plane - // (i.e. Walking up the plane) + // (i.e. Walking up the plane) if (plane->c < STEEPSLOPE) { // Can't climb up slopes of ~45 degrees or more if (actor->flags & MF_NOCLIP) @@ -2674,14 +2674,14 @@ const secplane_t * P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymo const msecnode_t *node; bool dopush = true; - if (plane->c > STEEPSLOPE*2/3) + if (plane->c > STEEPSLOPE * 2 / 3) { for (node = actor->touching_sectorlist; node; node = node->m_tnext) { const sector_t *sec = node->m_sector; if (sec->floorplane.c >= STEEPSLOPE) { - if (sec->floorplane.ZatPoint (destx, desty) >= actor->z - actor->MaxStepHeight) + if (sec->floorplane.ZatPoint(destx, desty) >= actor->z - actor->MaxStepHeight) { dopush = false; break; @@ -2699,8 +2699,8 @@ const secplane_t * P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymo } // Slide the desired location along the plane's normal // so that it lies on the plane's surface - destx -= FixedMul (plane->a, t); - desty -= FixedMul (plane->b, t); + destx -= FixedMul(plane->a, t); + desty -= FixedMul(plane->b, t); xmove = destx - actor->x; ymove = desty - actor->y; return (actor->floorsector == actor->Sector) ? plane : NULL; @@ -2709,9 +2709,9 @@ const secplane_t * P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymo { // Desired location is in front of (above) the plane if (planezhere == actor->z) { // Actor's current spot is on/in the plane, so walk down it - // Same principle as walking up, except reversed - destx += FixedMul (plane->a, t); - desty += FixedMul (plane->b, t); + // Same principle as walking up, except reversed + destx += FixedMul(plane->a, t); + desty += FixedMul(plane->b, t); xmove = destx - actor->x; ymove = desty - actor->y; return (actor->floorsector == actor->Sector) ? plane : NULL; @@ -2727,7 +2727,7 @@ const secplane_t * P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymo // //============================================================================ -bool FSlide::BounceTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy) +bool FSlide::BounceTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy) { FLineOpening open; FPathTraverse it(startx, starty, endx, endy, PT_ADDLINES); @@ -2740,7 +2740,7 @@ bool FSlide::BounceTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed if (!in->isaline) { - Printf ("PTR_BounceTraverse: not a line?"); + Printf("PTR_BounceTraverse: not a line?"); continue; } @@ -2752,14 +2752,14 @@ bool FSlide::BounceTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed } if (!(li->flags&ML_TWOSIDED) || !li->backsector) { - if (P_PointOnLineSide (slidemo->x, slidemo->y, li)) + if (P_PointOnLineSide(slidemo->x, slidemo->y, li)) continue; // don't hit the back side goto bounceblocking; } - P_LineOpening (open, slidemo, li, it.Trace().x + FixedMul (it.Trace().dx, in->frac), - it.Trace().y + FixedMul (it.Trace().dy, in->frac)); // set openrange, opentop, openbottom + P_LineOpening(open, slidemo, li, it.Trace().x + FixedMul(it.Trace().dx, in->frac), + it.Trace().y + FixedMul(it.Trace().dy, in->frac)); // set openrange, opentop, openbottom if (open.range < slidemo->height) goto bounceblocking; // doesn't fit @@ -2771,7 +2771,7 @@ bool FSlide::BounceTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed continue; // this line doesn't block movement - // the line does block movement, see if it is closer than best so far + // the line does block movement, see if it is closer than best so far bounceblocking: if (in->frac < bestslidefrac) { @@ -2791,7 +2791,7 @@ bool FSlide::BounceTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed // //============================================================================ -bool FSlide::BounceWall (AActor *mo) +bool FSlide::BounceWall(AActor *mo) { fixed_t leadx, leady; int side; @@ -2805,39 +2805,39 @@ bool FSlide::BounceWall (AActor *mo) } slidemo = mo; -// -// trace along the three leading corners -// + // + // trace along the three leading corners + // if (mo->velx > 0) { - leadx = mo->x+mo->radius; + leadx = mo->x + mo->radius; } else { - leadx = mo->x-mo->radius; + leadx = mo->x - mo->radius; } if (mo->vely > 0) { - leady = mo->y+mo->radius; + leady = mo->y + mo->radius; } else { - leady = mo->y-mo->radius; + leady = mo->y - mo->radius; } - bestslidefrac = FRACUNIT+1; + bestslidefrac = FRACUNIT + 1; bestslideline = mo->BlockingLine; - if (BounceTraverse(leadx, leady, leadx+mo->velx, leady+mo->vely) && mo->BlockingLine == NULL) + if (BounceTraverse(leadx, leady, leadx + mo->velx, leady + mo->vely) && mo->BlockingLine == NULL) { // Could not find a wall, so bounce off the floor/ceiling instead. fixed_t floordist = mo->z - mo->floorz; fixed_t ceildist = mo->ceilingz - mo->z; if (floordist <= ceildist) { - mo->FloorBounceMissile (mo->Sector->floorplane); + mo->FloorBounceMissile(mo->Sector->floorplane); return true; } else { - mo->FloorBounceMissile (mo->Sector->ceilingplane); + mo->FloorBounceMissile(mo->Sector->ceilingplane); return true; } } @@ -2851,7 +2851,7 @@ bool FSlide::BounceWall (AActor *mo) } // The amount of bounces is limited - if (mo->bouncecount>0 && --mo->bouncecount==0) + if (mo->bouncecount>0 && --mo->bouncecount == 0) { if (mo->flags & MF_MISSILE) P_ExplodeMissile(mo, line, NULL); @@ -2860,14 +2860,14 @@ bool FSlide::BounceWall (AActor *mo) return true; } - side = P_PointOnLineSide (mo->x, mo->y, line); - lineangle = R_PointToAngle2 (0, 0, line->dx, line->dy); + side = P_PointOnLineSide(mo->x, mo->y, line); + lineangle = R_PointToAngle2(0, 0, line->dx, line->dy); if (side == 1) { lineangle += ANG180; } - moveangle = R_PointToAngle2 (0, 0, mo->velx, mo->vely); - deltaangle = (2*lineangle)-moveangle; + moveangle = R_PointToAngle2(0, 0, mo->velx, mo->vely); + deltaangle = (2 * lineangle) - moveangle; mo->angle = deltaangle; lineangle >>= ANGLETOFINESHIFT; @@ -2877,14 +2877,14 @@ bool FSlide::BounceWall (AActor *mo) movelen = FixedMul(movelen, mo->wallbouncefactor); FBoundingBox box(mo->x, mo->y, mo->radius); - if (box.BoxOnLineSide (line) == -1) + if (box.BoxOnLineSide(line) == -1) { - mo->SetOrigin (mo->x + FixedMul(mo->radius, + mo->SetOrigin(mo->x + FixedMul(mo->radius, finecosine[deltaangle]), mo->y + FixedMul(mo->radius, finesine[deltaangle]), mo->z); } if (movelen < FRACUNIT) { - movelen = 2*FRACUNIT; + movelen = 2 * FRACUNIT; } mo->velx = FixedMul(movelen, finecosine[deltaangle]); mo->vely = FixedMul(movelen, finesine[deltaangle]); @@ -2899,7 +2899,7 @@ bool FSlide::BounceWall (AActor *mo) return true; } -bool P_BounceWall (AActor *mo) +bool P_BounceWall(AActor *mo) { FSlide slide; return slide.BounceWall(mo); @@ -2912,7 +2912,7 @@ bool P_BounceWall (AActor *mo) //========================================================================== extern FRandom pr_bounce; -bool P_BounceActor (AActor *mo, AActor *BlockingMobj, bool ontop) +bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop) { if (mo && BlockingMobj && ((mo->BounceFlags & BOUNCE_AllActors) || ((mo->flags & MF_MISSILE) && (!(mo->flags2 & MF2_RIP) || (BlockingMobj->flags5 & MF5_DONTRIP) || ((mo->flags6 & MF6_NOBOSSRIP) && (BlockingMobj->flags2 & MF2_BOSS))) && (BlockingMobj->flags2 & MF2_REFLECTIVE)) @@ -2924,21 +2924,21 @@ bool P_BounceActor (AActor *mo, AActor *BlockingMobj, bool ontop) if (!ontop) { fixed_t speed; - angle_t angle = R_PointToAngle2 (BlockingMobj->x, - BlockingMobj->y, mo->x, mo->y) + ANGLE_1*((pr_bounce()%16)-8); - speed = P_AproxDistance (mo->velx, mo->vely); - speed = FixedMul (speed, mo->wallbouncefactor); // [GZ] was 0.75, using wallbouncefactor seems more consistent + angle_t angle = R_PointToAngle2(BlockingMobj->x, + BlockingMobj->y, mo->x, mo->y) + ANGLE_1*((pr_bounce() % 16) - 8); + speed = P_AproxDistance(mo->velx, mo->vely); + speed = FixedMul(speed, mo->wallbouncefactor); // [GZ] was 0.75, using wallbouncefactor seems more consistent mo->angle = angle; angle >>= ANGLETOFINESHIFT; - mo->velx = FixedMul (speed, finecosine[angle]); - mo->vely = FixedMul (speed, finesine[angle]); + mo->velx = FixedMul(speed, finecosine[angle]); + mo->vely = FixedMul(speed, finesine[angle]); mo->PlayBounceSound(true); if (mo->BounceFlags & BOUNCE_UseBounceState) { FName names[] = { NAME_Bounce, NAME_Actor, NAME_Creature }; FState *bouncestate; int count = 2; - + if ((BlockingMobj->flags & MF_SHOOTABLE) && !(BlockingMobj->flags & MF_NOBLOOD)) { count = 3; @@ -2956,7 +2956,7 @@ bool P_BounceActor (AActor *mo, AActor *BlockingMobj, bool ontop) if (mo->BounceFlags & (BOUNCE_HereticType | BOUNCE_MBF)) { - mo->velz -= MulScale15 (FRACUNIT, dot); + mo->velz -= MulScale15(FRACUNIT, dot); if (!(mo->BounceFlags & BOUNCE_MBF)) // Heretic projectiles die, MBF projectiles don't. { mo->flags |= MF_INBOUNCE; @@ -2981,9 +2981,9 @@ bool P_BounceActor (AActor *mo, AActor *BlockingMobj, bool ontop) if (abs(mo->velz) < (fixed_t)(mo->Mass * mo->GetGravity() / 64)) mo->velz = 0; } - else if (mo->BounceFlags & (BOUNCE_AutoOff|BOUNCE_AutoOffFloorOnly)) + else if (mo->BounceFlags & (BOUNCE_AutoOff | BOUNCE_AutoOffFloorOnly)) { - if (!(mo->flags & MF_NOGRAVITY) && (mo->velz < 3*FRACUNIT)) + if (!(mo->flags & MF_NOGRAVITY) && (mo->velz < 3 * FRACUNIT)) mo->BounceFlags &= ~BOUNCE_TypeMask; } } @@ -3008,7 +3008,7 @@ struct aim_t fixed_t toppitch, bottompitch; AActor * linetarget; - AActor * thing_friend, * thing_other; + AActor * thing_friend, *thing_other; angle_t pitch_friend, pitch_other; int flags; #ifdef _3DFLOORS @@ -3021,7 +3021,7 @@ struct aim_t bool AimTraverse3DFloors(const divline_t &trace, intercept_t * in); #endif - void AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy, AActor *target=NULL); + void AimTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy, AActor *target = NULL); }; @@ -3034,100 +3034,100 @@ struct aim_t bool aim_t::AimTraverse3DFloors(const divline_t &trace, intercept_t * in) { sector_t * nextsector; - secplane_t * nexttopplane, * nextbottomplane; - line_t * li=in->d.line; + secplane_t * nexttopplane, *nextbottomplane; + line_t * li = in->d.line; - nextsector=NULL; - nexttopplane=nextbottomplane=NULL; + nextsector = NULL; + nexttopplane = nextbottomplane = NULL; if (li->backsector == NULL) return true; // shouldn't really happen but crashed once for me... - if (li->frontsector->e->XFloor.ffloors.Size() || li->backsector->e->XFloor.ffloors.Size()) - { + if (li->frontsector->e->XFloor.ffloors.Size() || li->backsector->e->XFloor.ffloors.Size()) + { int frontflag; F3DFloor* rover; int highpitch, lowpitch; - fixed_t trX = trace.x + FixedMul (trace.dx, in->frac); - fixed_t trY = trace.y + FixedMul (trace.dy, in->frac); - fixed_t dist = FixedMul (attackrange, in->frac); + fixed_t trX = trace.x + FixedMul(trace.dx, in->frac); + fixed_t trY = trace.y + FixedMul(trace.dy, in->frac); + fixed_t dist = FixedMul(attackrange, in->frac); + - int dir = aimpitch < 0 ? 1 : aimpitch > 0 ? -1 : 0; - + frontflag = P_PointOnLineSide(shootthing->x, shootthing->y, li); - + // 3D floor check. This is not 100% accurate but normally sufficient when // combined with a final sight check - for(int i=1;i<=2;i++) + for (int i = 1; i <= 2; i++) { - sector_t * s=i==1? li->frontsector:li->backsector; + sector_t * s = i == 1 ? li->frontsector : li->backsector; - for(unsigned k=0;ke->XFloor.ffloors.Size();k++) + for (unsigned k = 0; ke->XFloor.ffloors.Size(); k++) { - crossedffloors=true; - rover=s->e->XFloor.ffloors[k]; - - if((rover->flags & FF_SHOOTTHROUGH) || !(rover->flags & FF_EXISTS)) continue; - - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(trX, trY); - fixed_t ff_top=rover->top.plane->ZatPoint(trX, trY); - + crossedffloors = true; + rover = s->e->XFloor.ffloors[k]; - highpitch = -(int)R_PointToAngle2 (0, shootz, dist, ff_top); - lowpitch = -(int)R_PointToAngle2 (0, shootz, dist, ff_bottom); + if ((rover->flags & FF_SHOOTTHROUGH) || !(rover->flags & FF_EXISTS)) continue; - if (highpitch<=toppitch) + fixed_t ff_bottom = rover->bottom.plane->ZatPoint(trX, trY); + fixed_t ff_top = rover->top.plane->ZatPoint(trX, trY); + + + highpitch = -(int)R_PointToAngle2(0, shootz, dist, ff_top); + lowpitch = -(int)R_PointToAngle2(0, shootz, dist, ff_bottom); + + if (highpitch <= toppitch) { // blocks completely - if (lowpitch>=bottompitch) return false; + if (lowpitch >= bottompitch) return false; // blocks upper edge of view - if (lowpitch>toppitch) + if (lowpitch>toppitch) { - toppitch=lowpitch; - if (frontflag!=i-1) + toppitch = lowpitch; + if (frontflag != i - 1) { - nexttopplane=rover->bottom.plane; + nexttopplane = rover->bottom.plane; } } } - else if (lowpitch>=bottompitch) + else if (lowpitch >= bottompitch) { // blocks lower edge of view - if (highpitchtop.plane; + nextbottomplane = rover->top.plane; } } } // trace is leaving a sector with a 3d-floor - if (frontflag==i-1) + if (frontflag == i - 1) { - if (s==lastsector) + if (s == lastsector) { // upper slope intersects with this 3d-floor - if (rover->bottom.plane==lastceilingplane && lowpitch > toppitch) + if (rover->bottom.plane == lastceilingplane && lowpitch > toppitch) { - toppitch=lowpitch; + toppitch = lowpitch; } // lower slope intersects with this 3d-floor - if (rover->top.plane==lastfloorplane && highpitch < bottompitch) + if (rover->top.plane == lastfloorplane && highpitch < bottompitch) { - bottompitch=highpitch; + bottompitch = highpitch; } } } if (toppitch >= bottompitch) return false; // stop } } - } + } - lastsector=nextsector; - lastceilingplane=nexttopplane; - lastfloorplane=nextbottomplane; + lastsector = nextsector; + lastceilingplane = nexttopplane; + lastfloorplane = nextbottomplane; return true; } #endif @@ -3139,9 +3139,9 @@ bool aim_t::AimTraverse3DFloors(const divline_t &trace, intercept_t * in) // //============================================================================ -void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy, AActor *target) +void aim_t::AimTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy, AActor *target) { - FPathTraverse it(startx, starty, endx, endy, PT_ADDLINES|PT_ADDTHINGS|PT_COMPATIBLE); + FPathTraverse it(startx, starty, endx, endy, PT_ADDLINES | PT_ADDTHINGS | PT_COMPATIBLE); intercept_t *in; while ((in = it.Next())) @@ -3154,35 +3154,35 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e fixed_t dist; int thingpitch; - if (in->isaline) + if (in->isaline) { li = in->d.line; - if ( !(li->flags & ML_TWOSIDED) || (li->flags & ML_BLOCKEVERYTHING) ) + if (!(li->flags & ML_TWOSIDED) || (li->flags & ML_BLOCKEVERYTHING)) return; // stop // Crosses a two sided line. // A two sided line will restrict the possible target ranges. FLineOpening open; - P_LineOpening (open, NULL, li, it.Trace().x + FixedMul (it.Trace().dx, in->frac), - it.Trace().y + FixedMul (it.Trace().dy, in->frac)); + P_LineOpening(open, NULL, li, it.Trace().x + FixedMul(it.Trace().dx, in->frac), + it.Trace().y + FixedMul(it.Trace().dy, in->frac)); if (open.bottom >= open.top) return; // stop - dist = FixedMul (attackrange, in->frac); + dist = FixedMul(attackrange, in->frac); - pitch = -(int)R_PointToAngle2 (0, shootz, dist, open.bottom); + pitch = -(int)R_PointToAngle2(0, shootz, dist, open.bottom); if (pitch < bottompitch) bottompitch = pitch; - pitch = -(int)R_PointToAngle2 (0, shootz, dist, open.top); + pitch = -(int)R_PointToAngle2(0, shootz, dist, open.top); if (pitch > toppitch) toppitch = pitch; if (toppitch >= bottompitch) return; // stop - + #ifdef _3DFLOORS if (!AimTraverse3DFloors(it.Trace(), in)) return; #endif @@ -3203,11 +3203,11 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e { if (!(flags & ALF_CHECKNONSHOOTABLE)) // For info CCMD, ignore stuff about GHOST and SHOOTABLE flags { - if (!(th->flags&MF_SHOOTABLE)) + if (!(th->flags&MF_SHOOTABLE)) continue; // corpse or something // check for physical attacks on a ghost - if ((th->flags3 & MF3_GHOST) && + if ((th->flags3 & MF3_GHOST) && shootthing->player && // [RH] Be sure shootthing is a player shootthing->player->ReadyWeapon && (shootthing->player->ReadyWeapon->flags2 & MF2_THRUGHOST)) @@ -3216,7 +3216,7 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e } } } - dist = FixedMul (attackrange, in->frac); + dist = FixedMul(attackrange, in->frac); // Don't autoaim certain special actors if (!cl_doautoaim && th->flags6 & MF6_NOTAUTOAIMED) @@ -3226,26 +3226,26 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e #ifdef _3DFLOORS // we must do one last check whether the trace has crossed a 3D floor - if (lastsector==th->Sector && th->Sector->e->XFloor.ffloors.Size()) + if (lastsector == th->Sector && th->Sector->e->XFloor.ffloors.Size()) { if (lastceilingplane) { - fixed_t ff_top=lastceilingplane->ZatPoint(th->x, th->y); - fixed_t pitch = -(int)R_PointToAngle2 (0, shootz, dist, ff_top); + fixed_t ff_top = lastceilingplane->ZatPoint(th->x, th->y); + fixed_t pitch = -(int)R_PointToAngle2(0, shootz, dist, ff_top); // upper slope intersects with this 3d-floor if (pitch > toppitch) { - toppitch=pitch; + toppitch = pitch; } } if (lastfloorplane) { - fixed_t ff_bottom=lastfloorplane->ZatPoint(th->x, th->y); - fixed_t pitch = -(int)R_PointToAngle2 (0, shootz, dist, ff_bottom); + fixed_t ff_bottom = lastfloorplane->ZatPoint(th->x, th->y); + fixed_t pitch = -(int)R_PointToAngle2(0, shootz, dist, ff_bottom); // lower slope intersects with this 3d-floor if (pitch < bottompitch) { - bottompitch=pitch; + bottompitch = pitch; } } } @@ -3253,30 +3253,30 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e // check angles to see if the thing can be aimed at - thingtoppitch = -(int)R_PointToAngle2 (0, shootz, dist, th->z + th->height); + thingtoppitch = -(int)R_PointToAngle2(0, shootz, dist, th->z + th->height); if (thingtoppitch > bottompitch) continue; // shot over the thing - thingbottompitch = -(int)R_PointToAngle2 (0, shootz, dist, th->z); + thingbottompitch = -(int)R_PointToAngle2(0, shootz, dist, th->z); if (thingbottompitch < toppitch) continue; // shot under the thing - + #ifdef _3DFLOORS if (crossedffloors) { // if 3D floors were in the way do an extra visibility check for safety - if (!P_CheckSight(shootthing, th, SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY)) + if (!P_CheckSight(shootthing, th, SF_IGNOREVISIBILITY | SF_IGNOREWATERBOUNDARY)) { // the thing can't be seen so we can safely exclude its range from our aiming field - if (thingtoppitchtoppitch) toppitch=thingbottompitch; + if (thingbottompitch>toppitch) toppitch = thingbottompitch; } else if (thingbottompitch>bottompitch) { - if (thingtoppitch bottompitch) thingbottompitch = bottompitch; - - thingpitch = thingtoppitch/2 + thingbottompitch/2; - + + thingpitch = thingtoppitch / 2 + thingbottompitch / 2; + if (flags & ALF_CHECK3D) { // We need to do a 3D distance check here because this is nearly always used in @@ -3302,7 +3302,7 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e fixed_t cosine = finecosine[thingpitch >> ANGLETOFINESHIFT]; if (cosine != 0) { - fixed_t d3 = FixedDiv( FixedMul( P_AproxDistance(it.Trace().dx, it.Trace().dy), in->frac), cosine); + fixed_t d3 = FixedDiv(FixedMul(P_AproxDistance(it.Trace().dx, it.Trace().dy), in->frac), cosine); if (d3 > attackrange) { return; @@ -3358,8 +3358,8 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e // //============================================================================ -fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **pLineTarget, fixed_t vrange, - int flags, AActor *target, AActor *friender) +fixed_t P_AimLineAttack(AActor *t1, angle_t angle, fixed_t distance, AActor **pLineTarget, fixed_t vrange, + int flags, AActor *target, AActor *friender) { fixed_t x2; fixed_t y2; @@ -3370,16 +3370,16 @@ fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **p aim.shootthing = t1; aim.friender = (friender == NULL) ? t1 : friender; - x2 = t1->x + (distance>>FRACBITS)*finecosine[angle]; - y2 = t1->y + (distance>>FRACBITS)*finesine[angle]; - aim.shootz = t1->z + (t1->height>>1) - t1->floorclip; + x2 = t1->x + (distance >> FRACBITS)*finecosine[angle]; + y2 = t1->y + (distance >> FRACBITS)*finesine[angle]; + aim.shootz = t1->z + (t1->height >> 1) - t1->floorclip; if (t1->player != NULL) { - aim.shootz += FixedMul (t1->player->mo->AttackZOffset, t1->player->crouchfactor); + aim.shootz += FixedMul(t1->player->mo->AttackZOffset, t1->player->crouchfactor); } else { - aim.shootz += 8*FRACUNIT; + aim.shootz += 8 * FRACUNIT; } // can't shoot outside view angles @@ -3387,15 +3387,15 @@ fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **p { if (t1->player == NULL || !level.IsFreelookAllowed()) { - vrange = ANGLE_1*35; + vrange = ANGLE_1 * 35; } else { // [BB] Disable autoaim on weapons with WIF_NOAUTOAIM. AWeapon *weapon = t1->player->ReadyWeapon; - if ( weapon && (weapon->WeaponFlags & WIF_NOAUTOAIM) ) + if (weapon && (weapon->WeaponFlags & WIF_NOAUTOAIM)) { - vrange = ANGLE_1/2; + vrange = ANGLE_1 / 2; } else { @@ -3403,7 +3403,7 @@ fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **p // vrange of 0 degrees, because then toppitch and bottompitch will // be equal, and PTR_AimTraverse will never find anything to shoot at // if it crosses a line. - vrange = clamp (t1->player->userinfo.GetAimDist(), ANGLE_1/2, ANGLE_1*35); + vrange = clamp(t1->player->userinfo.GetAimDist(), ANGLE_1 / 2, ANGLE_1 * 35); } } } @@ -3414,32 +3414,32 @@ fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **p aim.linetarget = NULL; // for smart aiming - aim.thing_friend=aim.thing_other=NULL; + aim.thing_friend = aim.thing_other = NULL; // Information for tracking crossed 3D floors - aim.aimpitch=t1->pitch; + aim.aimpitch = t1->pitch; #ifdef _3DFLOORS - aim.crossedffloors=t1->Sector->e->XFloor.ffloors.Size()!=0; - aim.lastsector=t1->Sector; - aim.lastfloorplane=aim.lastceilingplane=NULL; + aim.crossedffloors = t1->Sector->e->XFloor.ffloors.Size() != 0; + aim.lastsector = t1->Sector; + aim.lastfloorplane = aim.lastceilingplane = NULL; // set initial 3d-floor info - for(unsigned i=0;iSector->e->XFloor.ffloors.Size();i++) + for (unsigned i = 0; iSector->e->XFloor.ffloors.Size(); i++) { - F3DFloor * rover=t1->Sector->e->XFloor.ffloors[i]; - fixed_t bottomz=rover->bottom.plane->ZatPoint(t1->x, t1->y); + F3DFloor * rover = t1->Sector->e->XFloor.ffloors[i]; + fixed_t bottomz = rover->bottom.plane->ZatPoint(t1->x, t1->y); - if (bottomz>=t1->z+t1->height) aim.lastceilingplane=rover->bottom.plane; + if (bottomz >= t1->z + t1->height) aim.lastceilingplane = rover->bottom.plane; - bottomz=rover->top.plane->ZatPoint(t1->x, t1->y); - if (bottomz<=t1->z) aim.lastfloorplane=rover->top.plane; + bottomz = rover->top.plane->ZatPoint(t1->x, t1->y); + if (bottomz <= t1->z) aim.lastfloorplane = rover->top.plane; } #endif - aim.AimTraverse (t1->x, t1->y, x2, y2, target); + aim.AimTraverse(t1->x, t1->y, x2, y2, target); - if (!aim.linetarget) + if (!aim.linetarget) { if (aim.thing_other) { @@ -3469,9 +3469,11 @@ fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **p struct Origin { AActor *Caller; + bool hitGhosts; + bool hitSameSpecie; }; -static ETraceStatus CheckForSameSpecie(FTraceResults &res, void *userdata) +static ETraceStatus CheckForActor(FTraceResults &res, void *userdata) { if (res.HitType != TRACE_HitActor) { @@ -3480,59 +3482,21 @@ static ETraceStatus CheckForSameSpecie(FTraceResults &res, void *userdata) Origin *data = (Origin *)userdata; - // check for physical attacks on the same specie - if (res.Actor->GetSpecies() == data->Caller->GetSpecies() || res.Actor->flags4 & MF4_SPECTRAL) - { - return TRACE_Skip; - } - - return TRACE_Stop; -} -static ETraceStatus CheckForGhost(FTraceResults &res, void *userdata) -{ - if (res.HitType != TRACE_HitActor) - { - return TRACE_Stop; - } - - // check for physical attacks on a ghost - if (res.Actor->flags3 & MF3_GHOST || res.Actor->flags4 & MF4_SPECTRAL) - { - return TRACE_Skip; - } - - return TRACE_Stop; -} -static ETraceStatus CheckForSpecieAndGhost(FTraceResults &res, void *userdata) -{ - if (res.HitType != TRACE_HitActor) - { - return TRACE_Stop; - } - - Origin *data = (Origin *)userdata; - - // check for physical attacks - if (res.Actor->GetSpecies() == data->Caller->GetSpecies() || res.Actor->flags3 & MF3_GHOST || res.Actor->flags4 & MF4_SPECTRAL) - { - return TRACE_Skip; - } - - return TRACE_Stop; -} -static ETraceStatus CheckForSpectral(FTraceResults &res, void *userdata) -{ - if (res.HitType != TRACE_HitActor) - { - return TRACE_Stop; - } - // check for physical attacks on spectrals if (res.Actor->flags4 & MF4_SPECTRAL) { return TRACE_Skip; } + if (data->hitSameSpecie && res.Actor->GetSpecies() == data->Caller->GetSpecies()) + { + return TRACE_Skip; + } + if (data->hitGhosts && res.Actor->flags3 & MF3_GHOST) + { + return TRACE_Skip; + } + return TRACE_Stop; } @@ -3544,8 +3508,8 @@ static ETraceStatus CheckForSpectral(FTraceResults &res, void *userdata) // //========================================================================== -AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, - int pitch, int damage, FName damageType, const PClass *pufftype, int flags, AActor **victim, int *actualdamage) +AActor *P_LineAttack(AActor *t1, angle_t angle, fixed_t distance, + int pitch, int damage, FName damageType, const PClass *pufftype, int flags, AActor **victim, int *actualdamage) { fixed_t vx, vy, vz, shootz; FTraceResults trace; @@ -3558,7 +3522,7 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, bool killPuff = false; AActor *puff = NULL; int pflag = 0; - int puffFlags = (flags & LAF_ISMELEEATTACK)? PF_MELEERANGE : 0; + int puffFlags = (flags & LAF_ISMELEEATTACK) ? PF_MELEERANGE : 0; if (flags & LAF_NORANDOMPUFFZ) puffFlags |= PF_NORANDOMZ; @@ -3574,14 +3538,14 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, angle >>= ANGLETOFINESHIFT; pitch = (angle_t)(pitch) >> ANGLETOFINESHIFT; - vx = FixedMul (finecosine[pitch], finecosine[angle]); - vy = FixedMul (finecosine[pitch], finesine[angle]); + vx = FixedMul(finecosine[pitch], finecosine[angle]); + vy = FixedMul(finecosine[pitch], finesine[angle]); vz = -finesine[pitch]; - shootz = t1->z - t1->floorclip + (t1->height>>1); + shootz = t1->z - t1->floorclip + (t1->height >> 1); if (t1->player != NULL) { - shootz += FixedMul (t1->player->mo->AttackZOffset, t1->player->crouchfactor); + shootz += FixedMul(t1->player->mo->AttackZOffset, t1->player->crouchfactor); if (damageType == NAME_Melee || damageType == NAME_Hitscan) { // this is coming from a weapon attack function which needs to transfer information to the obituary code, @@ -3591,18 +3555,18 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, } else { - shootz += 8*FRACUNIT; + shootz += 8 * FRACUNIT; } // We need to check the defaults of the replacement here AActor *puffDefaults = GetDefaultByType(pufftype->GetReplacement()); - hitGhosts = (t1->player != NULL && + TData.hitGhosts = (t1->player != NULL && t1->player->ReadyWeapon != NULL && (t1->player->ReadyWeapon->flags2 & MF2_THRUGHOST)) || (puffDefaults && (puffDefaults->flags2 & MF2_THRUGHOST)); - hitSameSpecie = (puffDefaults && (puffDefaults->flags6 & MF6_MTHRUSPECIES)); + TData.hitSameSpecie = (puffDefaults && (puffDefaults->flags6 & MF6_MTHRUSPECIES)); // if the puff uses a non-standard damage type, this will override default, hitscan and melee damage type. // All other explicitly passed damage types (currenty only MDK) will be preserved. @@ -3614,22 +3578,22 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, int tflags; if (puffDefaults != NULL && puffDefaults->flags6 & MF6_NOTRIGGER) tflags = TRACE_NoSky; - else tflags = TRACE_NoSky|TRACE_Impact; + else tflags = TRACE_NoSky | TRACE_Impact; - if (!Trace (t1->x, t1->y, shootz, t1->Sector, vx, vy, vz, distance, - MF_SHOOTABLE, ML_BLOCKEVERYTHING|ML_BLOCKHITSCAN, t1, trace, - tflags, hitGhosts ? (hitSameSpecie ? CheckForSpecieAndGhost : CheckForGhost) : hitSameSpecie ? CheckForSameSpecie : CheckForSpectral, &TData)) + if (!Trace(t1->x, t1->y, shootz, t1->Sector, vx, vy, vz, distance, + MF_SHOOTABLE, ML_BLOCKEVERYTHING | ML_BLOCKHITSCAN, t1, trace, + tflags, CheckForActor, &TData)) { // hit nothing if (puffDefaults == NULL) { } else if (puffDefaults->ActiveSound) { // Play miss sound - S_Sound (t1, CHAN_WEAPON, puffDefaults->ActiveSound, 1, ATTN_NORM); + S_Sound(t1, CHAN_WEAPON, puffDefaults->ActiveSound, 1, ATTN_NORM); } if (puffDefaults != NULL && puffDefaults->flags3 & MF3_ALWAYSPUFF) { // Spawn the puff anyway - puff = P_SpawnPuff (t1, pufftype, trace.X, trace.Y, trace.Z, angle - ANG180, 2, puffFlags); + puff = P_SpawnPuff(t1, pufftype, trace.X, trace.Y, trace.Z, angle - ANG180, 2, puffFlags); } else { @@ -3645,32 +3609,32 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, // position a bit closer for puffs if (trace.HitType != TRACE_HitWall || trace.Line->special != Line_Horizon) { - fixed_t closer = trace.Distance - 4*FRACUNIT; - puff = P_SpawnPuff (t1, pufftype, t1->x + FixedMul (vx, closer), - t1->y + FixedMul (vy, closer), - shootz + FixedMul (vz, closer), angle - ANG90, 0, puffFlags); + fixed_t closer = trace.Distance - 4 * FRACUNIT; + puff = P_SpawnPuff(t1, pufftype, t1->x + FixedMul(vx, closer), + t1->y + FixedMul(vy, closer), + shootz + FixedMul(vz, closer), angle - ANG90, 0, puffFlags); } // [RH] Spawn a decal if (trace.HitType == TRACE_HitWall && trace.Line->special != Line_Horizon) - { + { // [TN] If the actor or weapon has a decal defined, use that one. - if(t1->DecalGenerator != NULL || + if (t1->DecalGenerator != NULL || (t1->player != NULL && t1->player->ReadyWeapon != NULL && t1->player->ReadyWeapon->DecalGenerator != NULL)) { - SpawnShootDecal (t1, trace); + SpawnShootDecal(t1, trace); } // Else, look if the bulletpuff has a decal defined. - else if(puff != NULL && puff->DecalGenerator) + else if (puff != NULL && puff->DecalGenerator) { - SpawnShootDecal (puff, trace); - } - + SpawnShootDecal(puff, trace); + } + else { - SpawnShootDecal (t1, trace); - } + SpawnShootDecal(t1, trace); + } } else if (puff != NULL && trace.CrossedWater == NULL && @@ -3679,17 +3643,17 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, { // Using the puff's position is not accurate enough. // Instead make it splash at the actual hit position - hitx = t1->x + FixedMul (vx, trace.Distance); - hity = t1->y + FixedMul (vy, trace.Distance); - hitz = shootz + FixedMul (vz, trace.Distance); - P_HitWater (puff, P_PointInSector(hitx, hity), hitx, hity, hitz); + hitx = t1->x + FixedMul(vx, trace.Distance); + hity = t1->y + FixedMul(vy, trace.Distance); + hitz = shootz + FixedMul(vz, trace.Distance); + P_HitWater(puff, P_PointInSector(hitx, hity), hitx, hity, hitz); } } else { bool bloodsplatter = (t1->flags5 & MF5_BLOODSPLATTER) || - (t1->player != NULL && t1->player->ReadyWeapon != NULL && - (t1->player->ReadyWeapon->WeaponFlags & WIF_AXEBLOOD)); + (t1->player != NULL && t1->player->ReadyWeapon != NULL && + (t1->player->ReadyWeapon->WeaponFlags & WIF_AXEBLOOD)); bool axeBlood = (t1->player != NULL && t1->player->ReadyWeapon != NULL && @@ -3698,21 +3662,21 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, // Hit a thing, so it could be either a puff or blood fixed_t dist = trace.Distance; // position a bit closer for puffs/blood if using compatibility mode. - if (i_compatflags & COMPATF_HITSCAN) dist -= 10*FRACUNIT; - hitx = t1->x + FixedMul (vx, dist); - hity = t1->y + FixedMul (vy, dist); - hitz = shootz + FixedMul (vz, dist); + if (i_compatflags & COMPATF_HITSCAN) dist -= 10 * FRACUNIT; + hitx = t1->x + FixedMul(vx, dist); + hity = t1->y + FixedMul(vy, dist); + hitz = shootz + FixedMul(vz, dist); // Spawn bullet puffs or blood spots, depending on target type. if ((puffDefaults != NULL && puffDefaults->flags3 & MF3_PUFFONACTORS) || (trace.Actor->flags & MF_NOBLOOD) || - (trace.Actor->flags2 & (MF2_INVULNERABLE|MF2_DORMANT))) + (trace.Actor->flags2 & (MF2_INVULNERABLE | MF2_DORMANT))) { if (!(trace.Actor->flags & MF_NOBLOOD)) puffFlags |= PF_HITTHINGBLEED; // We must pass the unreplaced puff type here - puff = P_SpawnPuff (t1, pufftype, hitx, hity, hitz, angle - ANG180, 2, puffFlags|PF_HITTHING); + puff = P_SpawnPuff(t1, pufftype, hitx, hity, hitz, angle - ANG180, 2, puffFlags | PF_HITTHING); } // Allow puffs to inflict poison damage, so that hitscans can poison, too. @@ -3733,15 +3697,15 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, { dmgflags |= DMG_NO_ARMOR; } - + if (puff == NULL) - { + { // Since the puff is the damage inflictor we need it here // regardless of whether it is displayed or not. - puff = P_SpawnPuff (t1, pufftype, hitx, hity, hitz, angle - ANG180, 2, puffFlags|PF_HITTHING|PF_TEMPORARY); + puff = P_SpawnPuff(t1, pufftype, hitx, hity, hitz, angle - ANG180, 2, puffFlags | PF_HITTHING | PF_TEMPORARY); killPuff = true; } - newdam = P_DamageMobj (trace.Actor, puff ? puff : t1, t1, damage, damageType, dmgflags); + newdam = P_DamageMobj(trace.Actor, puff ? puff : t1, t1, damage, damageType, dmgflags); if (actualdamage != NULL) { *actualdamage = newdam; @@ -3751,30 +3715,30 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, { if (!bloodsplatter && !axeBlood && !(trace.Actor->flags & MF_NOBLOOD) && - !(trace.Actor->flags2 & (MF2_INVULNERABLE|MF2_DORMANT))) + !(trace.Actor->flags2 & (MF2_INVULNERABLE | MF2_DORMANT))) { - P_SpawnBlood (hitx, hity, hitz, angle - ANG180, newdam > 0 ? newdam : damage, trace.Actor); + P_SpawnBlood(hitx, hity, hitz, angle - ANG180, newdam > 0 ? newdam : damage, trace.Actor); } - + if (damage) { if (bloodsplatter || axeBlood) { if (!(trace.Actor->flags&MF_NOBLOOD) && - !(trace.Actor->flags2&(MF2_INVULNERABLE|MF2_DORMANT))) + !(trace.Actor->flags2&(MF2_INVULNERABLE | MF2_DORMANT))) { if (axeBlood) { - P_BloodSplatter2 (hitx, hity, hitz, trace.Actor); + P_BloodSplatter2(hitx, hity, hitz, trace.Actor); } if (pr_lineattack() < 192) { - P_BloodSplatter (hitx, hity, hitz, trace.Actor); + P_BloodSplatter(hitx, hity, hitz, trace.Actor); } } } // [RH] Stick blood to walls - P_TraceBleed (newdam > 0 ? newdam : damage, trace.X, trace.Y, trace.Z, + P_TraceBleed(newdam > 0 ? newdam : damage, trace.X, trace.Y, trace.Z, trace.Actor, srcangle, srcpitch); } } @@ -3788,10 +3752,10 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, if (puff == NULL) { // Spawn puff just to get a mass for the splash - puff = P_SpawnPuff (t1, pufftype, hitx, hity, hitz, angle - ANG180, 2, puffFlags|PF_HITTHING|PF_TEMPORARY); + puff = P_SpawnPuff(t1, pufftype, hitx, hity, hitz, angle - ANG180, 2, puffFlags | PF_HITTHING | PF_TEMPORARY); killPuff = true; } - SpawnDeepSplash (t1, trace, puff, vx, vy, vz, shootz, trace.Crossed3DWater != NULL); + SpawnDeepSplash(t1, trace, puff, vx, vy, vz, shootz, trace.Crossed3DWater != NULL); } } if (killPuff && puff != NULL) @@ -3802,8 +3766,8 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, return puff; } -AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, - int pitch, int damage, FName damageType, FName pufftype, int flags, AActor **victim, int *actualdamage) +AActor *P_LineAttack(AActor *t1, angle_t angle, fixed_t distance, + int pitch, int damage, FName damageType, FName pufftype, int flags, AActor **victim, int *actualdamage) { const PClass * type = PClass::FindClass(pufftype); if (victim != NULL) @@ -3827,7 +3791,7 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, // //========================================================================== -void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, angle_t angle, int pitch) +void P_TraceBleed(int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, angle_t angle, int pitch) { if (!cl_bloodsplats) return; @@ -3839,7 +3803,7 @@ void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, a if ((actor->flags & MF_NOBLOOD) || (actor->flags5 & MF5_NOBLOODDECALS) || - (actor->flags2 & (MF2_INVULNERABLE|MF2_DORMANT)) || + (actor->flags2 & (MF2_INVULNERABLE | MF2_DORMANT)) || (actor->player && actor->player->cheats & CF_GODMODE)) { return; @@ -3880,28 +3844,28 @@ void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, a { FTraceResults bleedtrace; - angle_t bleedang = (angle + ((pr_tracebleed()-128) << noise)) >> ANGLETOFINESHIFT; - angle_t bleedpitch = (angle_t)(pitch + ((pr_tracebleed()-128) << noise)) >> ANGLETOFINESHIFT; - fixed_t vx = FixedMul (finecosine[bleedpitch], finecosine[bleedang]); - fixed_t vy = FixedMul (finecosine[bleedpitch], finesine[bleedang]); + angle_t bleedang = (angle + ((pr_tracebleed() - 128) << noise)) >> ANGLETOFINESHIFT; + angle_t bleedpitch = (angle_t)(pitch + ((pr_tracebleed() - 128) << noise)) >> ANGLETOFINESHIFT; + fixed_t vx = FixedMul(finecosine[bleedpitch], finecosine[bleedang]); + fixed_t vy = FixedMul(finecosine[bleedpitch], finesine[bleedang]); fixed_t vz = -finesine[bleedpitch]; - if (Trace (x, y, z, actor->Sector, - vx, vy, vz, 172*FRACUNIT, 0, ML_BLOCKEVERYTHING, actor, - bleedtrace, TRACE_NoSky)) + if (Trace(x, y, z, actor->Sector, + vx, vy, vz, 172 * FRACUNIT, 0, ML_BLOCKEVERYTHING, actor, + bleedtrace, TRACE_NoSky)) { if (bleedtrace.HitType == TRACE_HitWall) { PalEntry bloodcolor = actor->GetBloodColor(); if (bloodcolor != 0) { - bloodcolor.r>>=1; // the full color is too bright for blood decals - bloodcolor.g>>=1; - bloodcolor.b>>=1; - bloodcolor.a=1; + bloodcolor.r >>= 1; // the full color is too bright for blood decals + bloodcolor.g >>= 1; + bloodcolor.b >>= 1; + bloodcolor.a = 1; } - DImpactDecal::StaticCreate (bloodType, + DImpactDecal::StaticCreate(bloodType, bleedtrace.X, bleedtrace.Y, bleedtrace.Z, bleedtrace.Line->sidedef[bleedtrace.Side], bleedtrace.ffloor, @@ -3911,9 +3875,9 @@ void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, a } } -void P_TraceBleed (int damage, AActor *target, angle_t angle, int pitch) +void P_TraceBleed(int damage, AActor *target, angle_t angle, int pitch) { - P_TraceBleed (damage, target->x, target->y, target->z + target->height/2, + P_TraceBleed(damage, target->x, target->y, target->z + target->height / 2, target, angle, pitch); } @@ -3923,7 +3887,7 @@ void P_TraceBleed (int damage, AActor *target, angle_t angle, int pitch) // //========================================================================== -void P_TraceBleed (int damage, AActor *target, AActor *missile) +void P_TraceBleed(int damage, AActor *target, AActor *missile) { int pitch; @@ -3936,15 +3900,15 @@ void P_TraceBleed (int damage, AActor *target, AActor *missile) { double aim; - aim = atan ((double)missile->velz / (double)P_AproxDistance (missile->x - target->x, missile->y - target->y)); - pitch = -(int)(aim * ANGLE_180/PI); + aim = atan((double)missile->velz / (double)P_AproxDistance(missile->x - target->x, missile->y - target->y)); + pitch = -(int)(aim * ANGLE_180 / PI); } else { pitch = 0; } - P_TraceBleed (damage, target->x, target->y, target->z + target->height/2, - target, R_PointToAngle2 (missile->x, missile->y, target->x, target->y), + P_TraceBleed(damage, target->x, target->y, target->z + target->height / 2, + target, R_PointToAngle2(missile->x, missile->y, target->x, target->y), pitch); } @@ -3954,14 +3918,14 @@ void P_TraceBleed (int damage, AActor *target, AActor *missile) // //========================================================================== -void P_TraceBleed (int damage, AActor *target) +void P_TraceBleed(int damage, AActor *target) { if (target != NULL) { fixed_t one = pr_tracebleed() << 24; - fixed_t two = (pr_tracebleed()-128) << 16; + fixed_t two = (pr_tracebleed() - 128) << 16; - P_TraceBleed (damage, target->x, target->y, target->z + target->height/2, + P_TraceBleed(damage, target->x, target->y, target->z + target->height / 2, target, one, two); } } @@ -3984,7 +3948,7 @@ struct RailData bool StopAtInvul; }; -static ETraceStatus ProcessRailHit (FTraceResults &res, void *userdata) +static ETraceStatus ProcessRailHit(FTraceResults &res, void *userdata) { RailData *data = (RailData *)userdata; if (res.HitType != TRACE_HitActor) @@ -4001,8 +3965,8 @@ static ETraceStatus ProcessRailHit (FTraceResults &res, void *userdata) // Save this thing for damaging later, and continue the trace SRailHit newhit; newhit.HitActor = res.Actor; - newhit.Distance = res.Distance - 10*FRACUNIT; // put blood in front - data->RailHits.Push (newhit); + newhit.Distance = res.Distance - 10 * FRACUNIT; // put blood in front + data->RailHits.Push(newhit); return data->StopAtOne ? TRACE_Stop : TRACE_Continue; } @@ -4012,7 +3976,7 @@ static ETraceStatus ProcessRailHit (FTraceResults &res, void *userdata) // // //========================================================================== -void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z, int color1, int color2, float maxdiff, int railflags, const PClass *puffclass, angle_t angleoffset, angle_t pitchoffset, fixed_t distance, int duration, float sparsity, float drift, const PClass *spawnclass) +void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, int color1, int color2, float maxdiff, int railflags, const PClass *puffclass, angle_t angleoffset, angle_t pitchoffset, fixed_t distance, int duration, float sparsity, float drift, const PClass *spawnclass) { fixed_t vx, vy, vz; angle_t angle, pitch; @@ -4026,8 +3990,8 @@ void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z, pitch = ((angle_t)(-source->pitch) + pitchoffset) >> ANGLETOFINESHIFT; angle = (source->angle + angleoffset) >> ANGLETOFINESHIFT; - vx = FixedMul (finecosine[pitch], finecosine[angle]); - vy = FixedMul (finecosine[pitch], finesine[angle]); + vx = FixedMul(finecosine[pitch], finecosine[angle]); + vy = FixedMul(finecosine[pitch], finesine[angle]); vz = finesine[pitch]; x1 = source->x; @@ -4039,11 +4003,11 @@ void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z, { if (source->player != NULL) { - shootz += FixedMul (source->player->mo->AttackZOffset, source->player->crouchfactor); + shootz += FixedMul(source->player->mo->AttackZOffset, source->player->crouchfactor); } else { - shootz += 8*FRACUNIT; + shootz += 8 * FRACUNIT; } } @@ -4061,12 +4025,12 @@ void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z, int flags; assert(puffclass != NULL); // Because we set it to a default above - AActor *puffDefaults = GetDefaultByType (puffclass->GetReplacement()); + AActor *puffDefaults = GetDefaultByType(puffclass->GetReplacement()); - flags = (puffDefaults->flags6 & MF6_NOTRIGGER) ? 0 : TRACE_PCross|TRACE_Impact; + flags = (puffDefaults->flags6 & MF6_NOTRIGGER) ? 0 : TRACE_PCross | TRACE_Impact; rail_data.StopAtInvul = (puffDefaults->flags3 & MF3_FOILINVUL) ? false : true; - Trace (x1, y1, shootz, source->Sector, vx, vy, vz, + Trace(x1, y1, shootz, source->Sector, vx, vy, vz, distance, MF_SHOOTABLE, ML_BLOCKEVERYTHING, source, trace, flags, ProcessRailHit, &rail_data); @@ -4076,10 +4040,10 @@ void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z, // used as damage inflictor AActor *thepuff = NULL; - - if (puffclass != NULL) thepuff = Spawn (puffclass, source->x, source->y, source->z, ALLOW_REPLACE); - for (i = 0; i < rail_data.RailHits.Size (); i++) + if (puffclass != NULL) thepuff = Spawn(puffclass, source->x, source->y, source->z, ALLOW_REPLACE); + + for (i = 0; i < rail_data.RailHits.Size(); i++) { fixed_t x, y, z; bool spawnpuff; @@ -4094,7 +4058,7 @@ void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z, z = shootz + FixedMul(hitdist, vz); if ((hitactor->flags & MF_NOBLOOD) || - (hitactor->flags2 & (MF2_DORMANT|MF2_INVULNERABLE))) + (hitactor->flags2 & (MF2_DORMANT | MF2_INVULNERABLE))) { spawnpuff = (puffclass != NULL); } @@ -4102,7 +4066,7 @@ void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z, { spawnpuff = (puffclass != NULL && puffDefaults->flags3 & MF3_ALWAYSPUFF); puffflags |= PF_HITTHINGBLEED; // [XA] Allow for puffs to jump to XDeath state. - if (!(puffDefaults->flags3 & MF3_BLOODLESSIMPACT)) + if (!(puffDefaults->flags3 & MF3_BLOODLESSIMPACT)) { bleed = true; } @@ -4115,7 +4079,7 @@ void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z, { P_PoisonMobj(hitactor, thepuff ? thepuff : source, source, puffDefaults->PoisonDamage, puffDefaults->PoisonDuration, puffDefaults->PoisonPeriod, puffDefaults->PoisonDamageType); } - int newdam = P_DamageMobj(hitactor, thepuff? thepuff:source, source, damage, damagetype, DMG_INFLICTOR_IS_PUFF); + int newdam = P_DamageMobj(hitactor, thepuff ? thepuff : source, source, damage, damagetype, DMG_INFLICTOR_IS_PUFF); if (bleed) { P_SpawnBlood(x, y, z, (source->angle + angleoffset) - ANG180, newdam > 0 ? newdam : damage, hitactor); @@ -4126,34 +4090,34 @@ void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z, // Spawn a decal or puff at the point where the trace ended. if (trace.HitType == TRACE_HitWall) { - SpawnShootDecal (source, trace); - if (puffclass != NULL && puffDefaults->flags3 & MF3_ALWAYSPUFF) + SpawnShootDecal(source, trace); + if (puffclass != NULL && puffDefaults->flags3 & MF3_ALWAYSPUFF) { - P_SpawnPuff (source, puffclass, trace.X, trace.Y, trace.Z, (source->angle + angleoffset) - ANG90, 1, 0); + P_SpawnPuff(source, puffclass, trace.X, trace.Y, trace.Z, (source->angle + angleoffset) - ANG90, 1, 0); } } - if(thepuff != NULL) + if (thepuff != NULL) { if (trace.HitType == TRACE_HitFloor && trace.CrossedWater == NULL && trace.Sector->heightsec == NULL) { thepuff->SetOrigin(trace.X, trace.Y, trace.Z); - P_HitWater (thepuff, trace.Sector); + P_HitWater(thepuff, trace.Sector); } if (trace.Crossed3DWater || trace.CrossedWater) { - SpawnDeepSplash (source, trace, thepuff, vx, vy, vz, shootz, trace.Crossed3DWater != NULL); + SpawnDeepSplash(source, trace, thepuff, vx, vy, vz, shootz, trace.Crossed3DWater != NULL); } - thepuff->Destroy (); + thepuff->Destroy(); } // Draw the slug's trail. end.X = FIXED2FLOAT(trace.X); end.Y = FIXED2FLOAT(trace.Y); end.Z = FIXED2FLOAT(trace.Z); - P_DrawRailTrail (source, start, end, color1, color2, maxdiff, railflags, spawnclass, source->angle + angleoffset, duration, sparsity, drift); + P_DrawRailTrail(source, start, end, color1, color2, maxdiff, railflags, spawnclass, source->angle + angleoffset, duration, sparsity, drift); } //========================================================================== @@ -4162,10 +4126,10 @@ void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z, // //========================================================================== -CVAR (Float, chase_height, -8.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -CVAR (Float, chase_dist, 90.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Float, chase_height, -8.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Float, chase_dist, 90.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -void P_AimCamera (AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &CameraZ, sector_t *&CameraSector) +void P_AimCamera(AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &CameraZ, sector_t *&CameraSector) { fixed_t distance = (fixed_t)(chase_dist * FRACUNIT); angle_t angle = (t1->angle - ANG180) >> ANGLETOFINESHIFT; @@ -4173,21 +4137,21 @@ void P_AimCamera (AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &Camer FTraceResults trace; fixed_t vx, vy, vz, sz; - vx = FixedMul (finecosine[pitch], finecosine[angle]); - vy = FixedMul (finecosine[pitch], finesine[angle]); + vx = FixedMul(finecosine[pitch], finecosine[angle]); + vy = FixedMul(finecosine[pitch], finesine[angle]); vz = finesine[pitch]; sz = t1->z - t1->floorclip + t1->height + (fixed_t)(chase_height * FRACUNIT); - if (Trace (t1->x, t1->y, sz, t1->Sector, + if (Trace(t1->x, t1->y, sz, t1->Sector, vx, vy, vz, distance, 0, 0, NULL, trace) && - trace.Distance > 10*FRACUNIT) + trace.Distance > 10 * FRACUNIT) { // Position camera slightly in front of hit thing - fixed_t dist = trace.Distance - 5*FRACUNIT; - CameraX = t1->x + FixedMul (vx, dist); - CameraY = t1->y + FixedMul (vy, dist); - CameraZ = sz + FixedMul (vz, dist); + fixed_t dist = trace.Distance - 5 * FRACUNIT; + CameraX = t1->x + FixedMul(vx, dist); + CameraY = t1->y + FixedMul(vy, dist); + CameraZ = sz + FixedMul(vz, dist); } else { @@ -4212,13 +4176,13 @@ bool P_TalkFacing(AActor *player) { AActor *linetarget; - P_AimLineAttack(player, player->angle, TALKRANGE, &linetarget, ANGLE_1*35, ALF_FORCENOSMART|ALF_CHECKCONVERSATION); + P_AimLineAttack(player, player->angle, TALKRANGE, &linetarget, ANGLE_1 * 35, ALF_FORCENOSMART | ALF_CHECKCONVERSATION); if (linetarget == NULL) { - P_AimLineAttack(player, player->angle + (ANGLE_90 >> 4), TALKRANGE, &linetarget, ANGLE_1*35, ALF_FORCENOSMART|ALF_CHECKCONVERSATION); + P_AimLineAttack(player, player->angle + (ANGLE_90 >> 4), TALKRANGE, &linetarget, ANGLE_1 * 35, ALF_FORCENOSMART | ALF_CHECKCONVERSATION); if (linetarget == NULL) { - P_AimLineAttack(player, player->angle - (ANGLE_90 >> 4), TALKRANGE, &linetarget, ANGLE_1*35, ALF_FORCENOSMART|ALF_CHECKCONVERSATION); + P_AimLineAttack(player, player->angle - (ANGLE_90 >> 4), TALKRANGE, &linetarget, ANGLE_1 * 35, ALF_FORCENOSMART | ALF_CHECKCONVERSATION); if (linetarget == NULL) { return false; @@ -4238,8 +4202,8 @@ bool P_TalkFacing(AActor *player) if (linetarget->Conversation != NULL) { // Give the NPC a chance to play a brief animation - linetarget->ConversationAnimation (0); - P_StartConversation (linetarget, player, true, true); + linetarget->ConversationAnimation(0); + P_StartConversation(linetarget, player, true, true); return true; } return false; @@ -4253,7 +4217,7 @@ bool P_TalkFacing(AActor *player) bool P_UseTraverse(AActor *usething, fixed_t endx, fixed_t endy, bool &foundline) { - FPathTraverse it(usething->x, usething->y, endx, endy, PT_ADDLINES|PT_ADDTHINGS); + FPathTraverse it(usething->x, usething->y, endx, endy, PT_ADDLINES | PT_ADDTHINGS); intercept_t *in; while ((in = it.Next())) @@ -4276,17 +4240,17 @@ bool P_UseTraverse(AActor *usething, fixed_t endx, fixed_t endy, bool &foundline } FLineOpening open; - if (in->d.line->special == 0 || !(in->d.line->activation & (SPAC_Use|SPAC_UseThrough|SPAC_UseBack))) + if (in->d.line->special == 0 || !(in->d.line->activation & (SPAC_Use | SPAC_UseThrough | SPAC_UseBack))) { - blocked: - if (in->d.line->flags & (ML_BLOCKEVERYTHING|ML_BLOCKUSE)) + blocked: + if (in->d.line->flags & (ML_BLOCKEVERYTHING | ML_BLOCKUSE)) { open.range = 0; } else { - P_LineOpening (open, NULL, in->d.line, it.Trace().x + FixedMul (it.Trace().dx, in->frac), - it.Trace().y + FixedMul (it.Trace().dy, in->frac)); + P_LineOpening(open, NULL, in->d.line, it.Trace().x + FixedMul(it.Trace().dx, in->frac), + it.Trace().y + FixedMul(it.Trace().dy, in->frac)); } if (open.range <= 0 || (in->d.line->special != 0 && (i_compatflags & COMPATF_USEBLOCKING))) @@ -4297,31 +4261,31 @@ bool P_UseTraverse(AActor *usething, fixed_t endx, fixed_t endy, bool &foundline sec = usething->Sector; - if (sec->SecActTarget && sec->SecActTarget->TriggerAction (usething, SECSPAC_Use)) + if (sec->SecActTarget && sec->SecActTarget->TriggerAction(usething, SECSPAC_Use)) { return true; } - sec = P_PointOnLineSide(usething->x, usething->y, in->d.line) == 0? + sec = P_PointOnLineSide(usething->x, usething->y, in->d.line) == 0 ? in->d.line->frontsector : in->d.line->backsector; if (sec != NULL && sec->SecActTarget && - sec->SecActTarget->TriggerAction (usething, SECSPAC_UseWall)) + sec->SecActTarget->TriggerAction(usething, SECSPAC_UseWall)) { return true; } if (usething->player) { - S_Sound (usething, CHAN_VOICE, "*usefail", 1, ATTN_IDLE); + S_Sound(usething, CHAN_VOICE, "*usefail", 1, ATTN_IDLE); } return true; // can't use through a wall } foundline = true; continue; // not a special line, but keep checking } - - if (P_PointOnLineSide (usething->x, usething->y, in->d.line) == 1) + + if (P_PointOnLineSide(usething->x, usething->y, in->d.line) == 1) { if (!(in->d.line->activation & SPAC_UseBack)) { @@ -4331,18 +4295,18 @@ bool P_UseTraverse(AActor *usething, fixed_t endx, fixed_t endy, bool &foundline } else { - P_ActivateLine (in->d.line, usething, 1, SPAC_UseBack); + P_ActivateLine(in->d.line, usething, 1, SPAC_UseBack); return true; } } - else + else { - if ((in->d.line->activation & (SPAC_Use|SPAC_UseThrough|SPAC_UseBack)) == SPAC_UseBack) + if ((in->d.line->activation & (SPAC_Use | SPAC_UseThrough | SPAC_UseBack)) == SPAC_UseBack) { goto blocked; // Line cannot be used from front side so treat it as a non-trigger line } - P_ActivateLine (in->d.line, usething, 0, SPAC_Use); + P_ActivateLine(in->d.line, usething, 0, SPAC_Use); //WAS can't use more than one special line in a row //jff 3/21/98 NOW multiple use allowed with enabling line flag @@ -4379,7 +4343,7 @@ bool P_UseTraverse(AActor *usething, fixed_t endx, fixed_t endy, bool &foundline // //========================================================================== -bool P_NoWayTraverse (AActor *usething, fixed_t endx, fixed_t endy) +bool P_NoWayTraverse(AActor *usething, fixed_t endx, fixed_t endy) { FPathTraverse it(usething->x, usething->y, endx, endy, PT_ADDLINES); intercept_t *in; @@ -4392,9 +4356,9 @@ bool P_NoWayTraverse (AActor *usething, fixed_t endx, fixed_t endy) // [GrafZahl] de-obfuscated. Was I the only one who was unable to make sense out of // this convoluted mess? if (ld->special) continue; - if (ld->flags&(ML_BLOCKING|ML_BLOCKEVERYTHING|ML_BLOCK_PLAYERS)) return true; - P_LineOpening(open, NULL, ld, it.Trace().x+FixedMul(it.Trace().dx, in->frac), - it.Trace().y+FixedMul(it.Trace().dy, in->frac)); + if (ld->flags&(ML_BLOCKING | ML_BLOCKEVERYTHING | ML_BLOCK_PLAYERS)) return true; + P_LineOpening(open, NULL, ld, it.Trace().x + FixedMul(it.Trace().dx, in->frac), + it.Trace().y + FixedMul(it.Trace().dy, in->frac)); if (open.range <= 0 || open.bottom > usething->z + usething->MaxStepHeight || open.top < usething->z + usething->height) return true; @@ -4410,7 +4374,7 @@ bool P_NoWayTraverse (AActor *usething, fixed_t endx, fixed_t endy) // //========================================================================== -void P_UseLines (player_t *player) +void P_UseLines(player_t *player) { angle_t angle; fixed_t x1, y1, usedist; @@ -4431,15 +4395,15 @@ void P_UseLines (player_t *player) // // This added test makes the "oof" sound work on 2s lines -- killough: - if (!P_UseTraverse (player->mo, x1, y1, foundline)) + if (!P_UseTraverse(player->mo, x1, y1, foundline)) { // [RH] Give sector a chance to eat the use sector_t *sec = player->mo->Sector; int spac = SECSPAC_Use; if (foundline) spac |= SECSPAC_UseWall; - if ((!sec->SecActTarget || !sec->SecActTarget->TriggerAction (player->mo, spac)) && - P_NoWayTraverse (player->mo, x1, y1)) + if ((!sec->SecActTarget || !sec->SecActTarget->TriggerAction(player->mo, spac)) && + P_NoWayTraverse(player->mo, x1, y1)) { - S_Sound (player->mo, CHAN_VOICE, "*usefail", 1, ATTN_IDLE); + S_Sound(player->mo, CHAN_VOICE, "*usefail", 1, ATTN_IDLE); } } } @@ -4452,12 +4416,12 @@ void P_UseLines (player_t *player) // //========================================================================== -bool P_UsePuzzleItem (AActor *PuzzleItemUser, int PuzzleItemType) +bool P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType) { int angle; fixed_t x1, y1, x2, y2, usedist; - angle = PuzzleItemUser->angle>>ANGLETOFINESHIFT; + angle = PuzzleItemUser->angle >> ANGLETOFINESHIFT; x1 = PuzzleItemUser->x; y1 = PuzzleItemUser->y; @@ -4470,7 +4434,7 @@ bool P_UsePuzzleItem (AActor *PuzzleItemUser, int PuzzleItemType) x2 = x1 + FixedMul(usedist, finecosine[angle]); y2 = y1 + FixedMul(usedist, finesine[angle]); - FPathTraverse it(x1, y1, x2, y2, PT_ADDLINES|PT_ADDTHINGS); + FPathTraverse it(x1, y1, x2, y2, PT_ADDLINES | PT_ADDTHINGS); intercept_t *in; while ((in = it.Next())) @@ -4482,15 +4446,15 @@ bool P_UsePuzzleItem (AActor *PuzzleItemUser, int PuzzleItemType) { // Check line if (in->d.line->special != UsePuzzleItem) { - P_LineOpening (open, NULL, in->d.line, it.Trace().x + FixedMul (it.Trace().dx, in->frac), - it.Trace().y + FixedMul (it.Trace().dy, in->frac)); + P_LineOpening(open, NULL, in->d.line, it.Trace().x + FixedMul(it.Trace().dx, in->frac), + it.Trace().y + FixedMul(it.Trace().dy, in->frac)); if (open.range <= 0) { return false; // can't use through a wall } continue; } - if (P_PointOnLineSide (PuzzleItemUser->x, PuzzleItemUser->y, in->d.line) == 1) + if (P_PointOnLineSide(PuzzleItemUser->x, PuzzleItemUser->y, in->d.line) == 1) { // Don't use back sides return false; } @@ -4499,7 +4463,7 @@ bool P_UsePuzzleItem (AActor *PuzzleItemUser, int PuzzleItemType) return false; } int args[3] = { in->d.line->args[2], in->d.line->args[3], in->d.line->args[4] }; - P_StartScript (PuzzleItemUser, in->d.line, in->d.line->args[1], NULL, args, 3, ACS_ALWAYS); + P_StartScript(PuzzleItemUser, in->d.line, in->d.line->args[1], NULL, args, 3, ACS_ALWAYS); in->d.line->special = 0; return true; } @@ -4514,7 +4478,7 @@ bool P_UsePuzzleItem (AActor *PuzzleItemUser, int PuzzleItemType) continue; } int args[3] = { mobj->args[2], mobj->args[3], mobj->args[4] }; - P_StartScript (PuzzleItemUser, NULL, mobj->args[1], NULL, args, 3, ACS_ALWAYS); + P_StartScript(PuzzleItemUser, NULL, mobj->args[1], NULL, args, 3, ACS_ALWAYS); mobj->special = 0; return true; } @@ -4532,7 +4496,7 @@ bool P_UsePuzzleItem (AActor *PuzzleItemUser, int PuzzleItemType) // [RH] Damage scale to apply to thing that shot the missile. static float selfthrustscale; -CUSTOM_CVAR (Float, splashfactor, 1.f, CVAR_SERVERINFO) +CUSTOM_CVAR(Float, splashfactor, 1.f, CVAR_SERVERINFO) { if (self <= 0.f) self = 1.f; @@ -4547,19 +4511,19 @@ CUSTOM_CVAR (Float, splashfactor, 1.f, CVAR_SERVERINFO) // //========================================================================== -void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int bombdistance, FName bombmod, +void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bombdistance, FName bombmod, int flags, int fulldamagedistance) { if (bombdistance <= 0) return; - fulldamagedistance = clamp(fulldamagedistance, 0, bombdistance-1); + fulldamagedistance = clamp(fulldamagedistance, 0, bombdistance - 1); double bombdistancefloat = 1.f / (double)(bombdistance - fulldamagedistance); double bombdamagefloat = (double)bombdamage; FVector3 bombvec(FIXED2FLOAT(bombspot->x), FIXED2FLOAT(bombspot->y), FIXED2FLOAT(bombspot->z)); - FBlockThingsIterator it(FBoundingBox(bombspot->x, bombspot->y, bombdistance<x, bombspot->y, bombdistance << FRACBITS)); AActor *thing; if (flags & RADF_SOURCEISSPOT) @@ -4588,12 +4552,12 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b // be hurt by projectiles fired by a monster of the same type. // Controlled by the DONTHARMCLASS and DONTHARMSPECIES flags. if ((bombsource && !thing->player) // code common to both checks - && ( // Class check first + && ( // Class check first ((bombsource->flags4 & MF4_DONTHARMCLASS) && (thing->GetClass() == bombsource->GetClass())) || // Nigh-identical species check second ((bombsource->flags6 & MF6_DONTHARMSPECIES) && (thing->GetSpecies() == bombsource->GetSpecies())) ) - ) continue; + ) continue; // Barrels always use the original code, since this makes // them far too "active." BossBrains also use the old code @@ -4608,12 +4572,12 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b fixed_t dx, dy; double boxradius; - dx = abs (thing->x - bombspot->x); - dy = abs (thing->y - bombspot->y); - boxradius = double (thing->radius); + dx = abs(thing->x - bombspot->x); + dy = abs(thing->y - bombspot->y); + boxradius = double(thing->radius); // The damage pattern is square, not circular. - len = double (dx > dy ? dx : dy); + len = double(dx > dy ? dx : dy); if (bombspot->z < thing->z || bombspot->z >= thing->z + thing->height) { @@ -4621,11 +4585,11 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b if (bombspot->z > thing->z) { - dz = double (bombspot->z - thing->z - thing->height); + dz = double(bombspot->z - thing->z - thing->height); } else { - dz = double (thing->z - bombspot->z); + dz = double(thing->z - bombspot->z); } if (len <= boxradius) { @@ -4634,7 +4598,7 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b else { len -= boxradius; - len = sqrt (len*len + dz*dz); + len = sqrt(len*len + dz*dz); } } else @@ -4650,10 +4614,10 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b { points = points * splashfactor; } - points *= thing->GetClass()->Meta.GetMetaFixed(AMETA_RDFactor, FRACUNIT)/(double)FRACUNIT; + points *= thing->GetClass()->Meta.GetMetaFixed(AMETA_RDFactor, FRACUNIT) / (double)FRACUNIT; // points and bombdamage should be the same sign - if ((points * bombdamage) > 0 && P_CheckSight (thing, bombspot, SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY)) + if ((points * bombdamage) > 0 && P_CheckSight(thing, bombspot, SF_IGNOREVISIBILITY | SF_IGNOREWATERBOUNDARY)) { // OK to damage; target is in direct path double velz; double thrust; @@ -4661,14 +4625,14 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b int newdam = damage; if (!(flags & RADF_NODAMAGE)) - newdam = P_DamageMobj (thing, bombspot, bombsource, damage, bombmod); + newdam = P_DamageMobj(thing, bombspot, bombsource, damage, bombmod); else if (thing->player == NULL && !(flags & RADF_NOIMPACTDAMAGE)) thing->flags2 |= MF2_BLASTED; if (!(thing->flags & MF_ICECORPSE)) { if (!(flags & RADF_NODAMAGE) && !(bombspot->flags3 & MF3_BLOODLESSIMPACT)) - P_TraceBleed (newdam > 0 ? newdam : damage, thing, bombspot); + P_TraceBleed(newdam > 0 ? newdam : damage, thing, bombspot); if ((flags & RADF_NODAMAGE) || !(bombspot->flags2 & MF2_NODMGTHRUST)) { @@ -4679,7 +4643,7 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b { thrust *= selfthrustscale; } - velz = (double)(thing->z + (thing->height>>1) - bombspot->z) * thrust; + velz = (double)(thing->z + (thing->height >> 1) - bombspot->z) * thrust; if (bombsource != thing) { velz *= 0.5f; @@ -4688,9 +4652,9 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b { velz *= 0.8f; } - angle_t ang = R_PointToAngle2 (bombspot->x, bombspot->y, thing->x, thing->y) >> ANGLETOFINESHIFT; - thing->velx += fixed_t (finecosine[ang] * thrust); - thing->vely += fixed_t (finesine[ang] * thrust); + angle_t ang = R_PointToAngle2(bombspot->x, bombspot->y, thing->x, thing->y) >> ANGLETOFINESHIFT; + thing->velx += fixed_t(finecosine[ang] * thrust); + thing->vely += fixed_t(finesine[ang] * thrust); if (!(flags & RADF_NODAMAGE)) thing->velz += (fixed_t)velz; // this really doesn't work well } @@ -4703,8 +4667,8 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b // [RH] Old code just for barrels fixed_t dx, dy, dist; - dx = abs (thing->x - bombspot->x); - dy = abs (thing->y - bombspot->y); + dx = abs(thing->x - bombspot->x); + dy = abs(thing->y - bombspot->y); dist = dx>dy ? dx : dy; dist = (dist - thing->radius) >> FRACBITS; @@ -4715,17 +4679,17 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b if (dist >= bombdistance) continue; // out of range - if (P_CheckSight (thing, bombspot, SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY)) + if (P_CheckSight(thing, bombspot, SF_IGNOREVISIBILITY | SF_IGNOREWATERBOUNDARY)) { // OK to damage; target is in direct path dist = clamp(dist - fulldamagedistance, 0, dist); - int damage = Scale (bombdamage, bombdistance-dist, bombdistance); + int damage = Scale(bombdamage, bombdistance - dist, bombdistance); damage = (int)((double)damage * splashfactor); damage = Scale(damage, thing->GetClass()->Meta.GetMetaFixed(AMETA_RDFactor, FRACUNIT), FRACUNIT); if (damage > 0) { - int newdam = P_DamageMobj (thing, bombspot, bombsource, damage, bombmod); - P_TraceBleed (newdam > 0 ? newdam : damage, thing, bombspot); + int newdam = P_DamageMobj(thing, bombspot, bombsource, damage, bombmod); + P_TraceBleed(newdam > 0 ? newdam : damage, thing, bombspot); } } } @@ -4765,7 +4729,7 @@ struct FChangePosition TArray intersectors; -EXTERN_CVAR (Int, cl_bloodtype) +EXTERN_CVAR(Int, cl_bloodtype) //============================================================================= // @@ -4773,7 +4737,7 @@ EXTERN_CVAR (Int, cl_bloodtype) // //============================================================================= -bool P_AdjustFloorCeil (AActor *thing, FChangePosition *cpos) +bool P_AdjustFloorCeil(AActor *thing, FChangePosition *cpos) { int flags2 = thing->flags2 & MF2_PASSMOBJ; FCheckPosition tm; @@ -4791,7 +4755,7 @@ bool P_AdjustFloorCeil (AActor *thing, FChangePosition *cpos) thing->flags2 |= MF2_PASSMOBJ; } - bool isgood = P_CheckPosition (thing, thing->x, thing->y, tm); + bool isgood = P_CheckPosition(thing, thing->x, thing->y, tm); thing->floorz = tm.floorz; thing->ceilingz = tm.ceilingz; thing->dropoffz = tm.dropoffz; // killough 11/98: remember dropoffs @@ -4812,7 +4776,7 @@ bool P_AdjustFloorCeil (AActor *thing, FChangePosition *cpos) // //============================================================================= -void P_FindAboveIntersectors (AActor *actor) +void P_FindAboveIntersectors(AActor *actor) { if (actor->flags & MF_NOCLIP) return; @@ -4855,7 +4819,7 @@ void P_FindAboveIntersectors (AActor *actor) if (thing->z >= actor->z && thing->z <= actor->z + actor->height) { // Thing intersects above the base - intersectors.Push (thing); + intersectors.Push(thing); } } } @@ -4866,7 +4830,7 @@ void P_FindAboveIntersectors (AActor *actor) // //============================================================================= -void P_FindBelowIntersectors (AActor *actor) +void P_FindBelowIntersectors(AActor *actor) { if (actor->flags & MF_NOCLIP) return; @@ -4909,7 +4873,7 @@ void P_FindBelowIntersectors (AActor *actor) if (thing->z + thing->height <= actor->z + actor->height && thing->z + thing->height > actor->z) { // Thing intersects below the base - intersectors.Push (thing); + intersectors.Push(thing); } } } @@ -4920,34 +4884,34 @@ void P_FindBelowIntersectors (AActor *actor) // //============================================================================= -void P_DoCrunch (AActor *thing, FChangePosition *cpos) +void P_DoCrunch(AActor *thing, FChangePosition *cpos) { if (!(thing && thing->Grind(true) && cpos)) return; cpos->nofit = true; if ((cpos->crushchange > 0) && !(level.maptime & 3)) { - int newdam = P_DamageMobj (thing, NULL, NULL, cpos->crushchange, NAME_Crush); + int newdam = P_DamageMobj(thing, NULL, NULL, cpos->crushchange, NAME_Crush); // spray blood in a random direction - if (!(thing->flags2&(MF2_INVULNERABLE|MF2_DORMANT))) + if (!(thing->flags2&(MF2_INVULNERABLE | MF2_DORMANT))) { if (!(thing->flags&MF_NOBLOOD)) { PalEntry bloodcolor = thing->GetBloodColor(); const PClass *bloodcls = thing->GetBloodType(); - - P_TraceBleed (newdam > 0 ? newdam : cpos->crushchange, thing); + + P_TraceBleed(newdam > 0 ? newdam : cpos->crushchange, thing); if (bloodcls != NULL) { AActor *mo; - mo = Spawn (bloodcls, thing->x, thing->y, - thing->z + thing->height/2, ALLOW_REPLACE); + mo = Spawn(bloodcls, thing->x, thing->y, + thing->z + thing->height / 2, ALLOW_REPLACE); - mo->velx = pr_crunch.Random2 () << 12; - mo->vely = pr_crunch.Random2 () << 12; + mo->velx = pr_crunch.Random2() << 12; + mo->vely = pr_crunch.Random2() << 12; if (bloodcolor != 0 && !(mo->flags2 & MF2_DONTTRANSLATE)) { mo->Translation = TRANSLATION(TRANSLATION_Blood, bloodcolor.a); @@ -4957,7 +4921,7 @@ void P_DoCrunch (AActor *thing, FChangePosition *cpos) } angle_t an; - an = (M_Random () - 128) << 24; + an = (M_Random() - 128) << 24; if (cl_bloodtype >= 1) { P_DrawSplash2(32, thing->x, thing->y, thing->z + thing->height / 2, an, 2, bloodcolor); @@ -4982,9 +4946,9 @@ void P_DoCrunch (AActor *thing, FChangePosition *cpos) // above it didn't fit. //============================================================================= -int P_PushUp (AActor *thing, FChangePosition *cpos) +int P_PushUp(AActor *thing, FChangePosition *cpos) { - unsigned int firstintersect = intersectors.Size (); + unsigned int firstintersect = intersectors.Size(); unsigned int lastintersect; int mymass = thing->Mass; @@ -4995,8 +4959,8 @@ int P_PushUp (AActor *thing, FChangePosition *cpos) // [GZ] Skip thing intersect test for THRUACTORS things. if (thing->flags2 & MF2_THRUACTORS) return 0; - P_FindAboveIntersectors (thing); - lastintersect = intersectors.Size (); + P_FindAboveIntersectors(thing); + lastintersect = intersectors.Size(); for (; firstintersect < lastintersect; firstintersect++) { AActor *intersect = intersectors[firstintersect]; @@ -5009,17 +4973,17 @@ int P_PushUp (AActor *thing, FChangePosition *cpos) if (!(intersect->flags2 & MF2_PASSMOBJ) || (!(intersect->flags3 & MF3_ISMONSTER) && intersect->Mass > mymass) || (intersect->flags4 & MF4_ACTLIKEBRIDGE) - ) - { + ) + { // Can't push bridges or things more massive than ourself return 2; } fixed_t oldz = intersect->z; - P_AdjustFloorCeil (intersect, cpos); + P_AdjustFloorCeil(intersect, cpos); intersect->z = thing->z + thing->height + 1; - if (P_PushUp (intersect, cpos)) + if (P_PushUp(intersect, cpos)) { // Move blocked - P_DoCrunch (intersect, cpos); + P_DoCrunch(intersect, cpos); intersect->z = oldz; return 2; } @@ -5035,9 +4999,9 @@ int P_PushUp (AActor *thing, FChangePosition *cpos) // below it didn't fit. //============================================================================= -int P_PushDown (AActor *thing, FChangePosition *cpos) +int P_PushDown(AActor *thing, FChangePosition *cpos) { - unsigned int firstintersect = intersectors.Size (); + unsigned int firstintersect = intersectors.Size(); unsigned int lastintersect; int mymass = thing->Mass; @@ -5045,27 +5009,27 @@ int P_PushDown (AActor *thing, FChangePosition *cpos) { return 1; } - P_FindBelowIntersectors (thing); - lastintersect = intersectors.Size (); + P_FindBelowIntersectors(thing); + lastintersect = intersectors.Size(); for (; firstintersect < lastintersect; firstintersect++) { AActor *intersect = intersectors[firstintersect]; if (!(intersect->flags2 & MF2_PASSMOBJ) || (!(intersect->flags3 & MF3_ISMONSTER) && intersect->Mass > mymass) || (intersect->flags4 & MF4_ACTLIKEBRIDGE) - ) - { + ) + { // Can't push bridges or things more massive than ourself return 2; } fixed_t oldz = intersect->z; - P_AdjustFloorCeil (intersect, cpos); + P_AdjustFloorCeil(intersect, cpos); if (oldz > thing->z - intersect->height) { // Only push things down, not up. intersect->z = thing->z - intersect->height; - if (P_PushDown (intersect, cpos)) + if (P_PushDown(intersect, cpos)) { // Move blocked - P_DoCrunch (intersect, cpos); + P_DoCrunch(intersect, cpos); intersect->z = oldz; return 2; } @@ -5080,27 +5044,27 @@ int P_PushDown (AActor *thing, FChangePosition *cpos) // //============================================================================= -void PIT_FloorDrop (AActor *thing, FChangePosition *cpos) +void PIT_FloorDrop(AActor *thing, FChangePosition *cpos) { fixed_t oldfloorz = thing->floorz; - P_AdjustFloorCeil (thing, cpos); + P_AdjustFloorCeil(thing, cpos); if (oldfloorz == thing->floorz) return; if (thing->flags4 & MF4_ACTLIKEBRIDGE) return; // do not move bridge things if (thing->velz == 0 && (!(thing->flags & MF_NOGRAVITY) || - (thing->z == oldfloorz && !(thing->flags & MF_NOLIFTDROP)))) + (thing->z == oldfloorz && !(thing->flags & MF_NOLIFTDROP)))) { fixed_t oldz = thing->z; if ((thing->flags & MF_NOGRAVITY) || (thing->flags5 & MF5_MOVEWITHSECTOR) || - (((cpos->sector->Flags & SECF_FLOORDROP) || cpos->moveamt < 9*FRACUNIT) - && thing->z - thing->floorz <= cpos->moveamt)) + (((cpos->sector->Flags & SECF_FLOORDROP) || cpos->moveamt < 9 * FRACUNIT) + && thing->z - thing->floorz <= cpos->moveamt)) { thing->z = thing->floorz; - P_CheckFakeFloorTriggers (thing, oldz); + P_CheckFakeFloorTriggers(thing, oldz); } } else if ((thing->z != oldfloorz && !(thing->flags & MF_NOLIFTDROP))) @@ -5109,7 +5073,7 @@ void PIT_FloorDrop (AActor *thing, FChangePosition *cpos) if ((thing->flags & MF_NOGRAVITY) && (thing->flags6 & MF6_RELATIVETOFLOOR)) { thing->z = thing->z - oldfloorz + thing->floorz; - P_CheckFakeFloorTriggers (thing, oldz); + P_CheckFakeFloorTriggers(thing, oldz); } } } @@ -5120,46 +5084,46 @@ void PIT_FloorDrop (AActor *thing, FChangePosition *cpos) // //============================================================================= -void PIT_FloorRaise (AActor *thing, FChangePosition *cpos) +void PIT_FloorRaise(AActor *thing, FChangePosition *cpos) { fixed_t oldfloorz = thing->floorz; fixed_t oldz = thing->z; - P_AdjustFloorCeil (thing, cpos); + P_AdjustFloorCeil(thing, cpos); if (oldfloorz == thing->floorz) return; // Move things intersecting the floor up if (thing->z <= thing->floorz) { - if (thing->flags4 & MF4_ACTLIKEBRIDGE) + if (thing->flags4 & MF4_ACTLIKEBRIDGE) { cpos->nofit = true; return; // do not move bridge things } - intersectors.Clear (); + intersectors.Clear(); thing->z = thing->floorz; } else { - if((thing->flags & MF_NOGRAVITY) && (thing->flags6 & MF6_RELATIVETOFLOOR)) + if ((thing->flags & MF_NOGRAVITY) && (thing->flags6 & MF6_RELATIVETOFLOOR)) { - intersectors.Clear (); + intersectors.Clear(); thing->z = thing->z - oldfloorz + thing->floorz; } else return; } - switch (P_PushUp (thing, cpos)) + switch (P_PushUp(thing, cpos)) { default: - P_CheckFakeFloorTriggers (thing, oldz); + P_CheckFakeFloorTriggers(thing, oldz); break; case 1: - P_DoCrunch (thing, cpos); - P_CheckFakeFloorTriggers (thing, oldz); + P_DoCrunch(thing, cpos); + P_CheckFakeFloorTriggers(thing, oldz); break; case 2: - P_DoCrunch (thing, cpos); + P_DoCrunch(thing, cpos); thing->z = oldz; break; } @@ -5171,21 +5135,21 @@ void PIT_FloorRaise (AActor *thing, FChangePosition *cpos) // //============================================================================= -void PIT_CeilingLower (AActor *thing, FChangePosition *cpos) +void PIT_CeilingLower(AActor *thing, FChangePosition *cpos) { bool onfloor; onfloor = thing->z <= thing->floorz; - P_AdjustFloorCeil (thing, cpos); + P_AdjustFloorCeil(thing, cpos); if (thing->z + thing->height > thing->ceilingz) { - if (thing->flags4 & MF4_ACTLIKEBRIDGE) + if (thing->flags4 & MF4_ACTLIKEBRIDGE) { cpos->nofit = true; return; // do not move bridge things } - intersectors.Clear (); + intersectors.Clear(); fixed_t oldz = thing->z; if (thing->ceilingz - thing->height >= thing->floorz) { @@ -5195,18 +5159,18 @@ void PIT_CeilingLower (AActor *thing, FChangePosition *cpos) { thing->z = thing->floorz; } - switch (P_PushDown (thing, cpos)) + switch (P_PushDown(thing, cpos)) { case 2: // intentional fall-through case 1: if (onfloor) thing->z = thing->floorz; - P_DoCrunch (thing, cpos); - P_CheckFakeFloorTriggers (thing, oldz); + P_DoCrunch(thing, cpos); + P_CheckFakeFloorTriggers(thing, oldz); break; default: - P_CheckFakeFloorTriggers (thing, oldz); + P_CheckFakeFloorTriggers(thing, oldz); break; } } @@ -5218,9 +5182,9 @@ void PIT_CeilingLower (AActor *thing, FChangePosition *cpos) // //============================================================================= -void PIT_CeilingRaise (AActor *thing, FChangePosition *cpos) +void PIT_CeilingRaise(AActor *thing, FChangePosition *cpos) { - bool isgood = P_AdjustFloorCeil (thing, cpos); + bool isgood = P_AdjustFloorCeil(thing, cpos); if (thing->flags4 & MF4_ACTLIKEBRIDGE) return; // do not move bridge things @@ -5237,15 +5201,15 @@ void PIT_CeilingRaise (AActor *thing, FChangePosition *cpos) { thing->z = thing->ceilingz - thing->height; } - P_CheckFakeFloorTriggers (thing, oldz); + P_CheckFakeFloorTriggers(thing, oldz); } else if ((thing->flags2 & MF2_PASSMOBJ) && !isgood && thing->z + thing->height < thing->ceilingz) { AActor *onmobj; - if (!P_TestMobjZ (thing, true, &onmobj) && onmobj->z <= thing->z) + if (!P_TestMobjZ(thing, true, &onmobj) && onmobj->z <= thing->z) { - thing->z = MIN (thing->ceilingz - thing->height, - onmobj->z + onmobj->height); + thing->z = MIN(thing->ceilingz - thing->height, + onmobj->z + onmobj->height); } } } @@ -5260,23 +5224,23 @@ void PIT_CeilingRaise (AActor *thing, FChangePosition *cpos) // //============================================================================= -bool P_ChangeSector (sector_t *sector, int crunch, int amt, int floorOrCeil, bool isreset) +bool P_ChangeSector(sector_t *sector, int crunch, int amt, int floorOrCeil, bool isreset) { FChangePosition cpos; - void (*iterator)(AActor *, FChangePosition *); - void (*iterator2)(AActor *, FChangePosition *) = NULL; + void(*iterator)(AActor *, FChangePosition *); + void(*iterator2)(AActor *, FChangePosition *) = NULL; msecnode_t *n; cpos.nofit = false; cpos.crushchange = crunch; - cpos.moveamt = abs (amt); + cpos.moveamt = abs(amt); cpos.movemidtex = false; cpos.sector = sector; #ifdef _3DFLOORS // Also process all sectors that have 3D floors transferred from the // changed sector. - if(sector->e->XFloor.attached.Size()) + if (sector->e->XFloor.attached.Size()) { unsigned i; sector_t* sec; @@ -5285,30 +5249,30 @@ bool P_ChangeSector (sector_t *sector, int crunch, int amt, int floorOrCeil, boo // Use different functions for the four different types of sector movement. // for 3D-floors the meaning of floor and ceiling is inverted!!! if (floorOrCeil == 1) - { + { iterator = (amt >= 0) ? PIT_FloorRaise : PIT_FloorDrop; } else - { - iterator = (amt >=0) ? PIT_CeilingRaise : PIT_CeilingLower; + { + iterator = (amt >= 0) ? PIT_CeilingRaise : PIT_CeilingLower; } - for(i = 0; i < sector->e->XFloor.attached.Size(); i ++) + for (i = 0; i < sector->e->XFloor.attached.Size(); i++) { sec = sector->e->XFloor.attached[i]; P_Recalculate3DFloors(sec); // Must recalculate the 3d floor and light lists // no thing checks for attached sectors because of heightsec - if (sec->heightsec==sector) continue; + if (sec->heightsec == sector) continue; - for (n=sec->touching_thinglist; n; n=n->m_snext) n->visited = false; - do + for (n = sec->touching_thinglist; n; n = n->m_snext) n->visited = false; + do { - for (n=sec->touching_thinglist; n; n=n->m_snext) + for (n = sec->touching_thinglist; n; n = n->m_snext) { if (!n->visited) { - n->visited = true; + n->visited = true; if (!(n->m_thing->flags & MF_NOBLOCKMAP) || //jff 4/7/98 don't do these (n->m_thing->flags5 & MF5_MOVEWITHSECTOR)) { @@ -5317,8 +5281,7 @@ bool P_ChangeSector (sector_t *sector, int crunch, int amt, int floorOrCeil, boo break; } } - } - while (n); + } while (n); } } P_Recalculate3DFloors(sector); // Must recalculate the 3d floor and light lists @@ -5376,8 +5339,8 @@ bool P_ChangeSector (sector_t *sector, int crunch, int amt, int floorOrCeil, boo if (!(n->m_thing->flags & MF_NOBLOCKMAP) || //jff 4/7/98 don't do these (n->m_thing->flags5 & MF5_MOVEWITHSECTOR)) { - iterator (n->m_thing, &cpos); // process it - if (iterator2 != NULL) iterator2 (n->m_thing, &cpos); + iterator(n->m_thing, &cpos); // process it + if (iterator2 != NULL) iterator2(n->m_thing, &cpos); } break; // exit and start over } @@ -5391,7 +5354,7 @@ bool P_ChangeSector (sector_t *sector, int crunch, int amt, int floorOrCeil, boo // execute appropriate sector actions. // Only check if the sector move was successful. TArray & secs = sector->e->FakeFloor.Sectors; - for(unsigned i = 0; i < secs.Size(); i++) + for (unsigned i = 0; i < secs.Size(); i++) { sector_t * s = secs[i]; @@ -5446,7 +5409,7 @@ msecnode_t *P_GetSecnode() } else { - node = (msecnode_t *)M_Malloc (sizeof(*node)); + node = (msecnode_t *)M_Malloc(sizeof(*node)); } return node; } @@ -5459,7 +5422,7 @@ msecnode_t *P_GetSecnode() // //============================================================================= -void P_PutSecnode (msecnode_t *node) +void P_PutSecnode(msecnode_t *node) { node->m_snext = headsecnode; headsecnode = node; @@ -5477,13 +5440,13 @@ void P_PutSecnode (msecnode_t *node) // //============================================================================= -msecnode_t *P_AddSecnode (sector_t *s, AActor *thing, msecnode_t *nextnode) +msecnode_t *P_AddSecnode(sector_t *s, AActor *thing, msecnode_t *nextnode) { msecnode_t *node; if (s == 0) { - I_FatalError ("AddSecnode of 0 for %s\n", thing->_StaticType.TypeName.GetChars()); + I_FatalError("AddSecnode of 0 for %s\n", thing->_StaticType.TypeName.GetChars()); } node = nextnode; @@ -5506,16 +5469,16 @@ msecnode_t *P_AddSecnode (sector_t *s, AActor *thing, msecnode_t *nextnode) node->visited = 0; node->m_sector = s; // sector - node->m_thing = thing; // mobj - node->m_tprev = NULL; // prev node on Thing thread - node->m_tnext = nextnode; // next node on Thing thread + node->m_thing = thing; // mobj + node->m_tprev = NULL; // prev node on Thing thread + node->m_tnext = nextnode; // next node on Thing thread if (nextnode) nextnode->m_tprev = node; // set back link on Thing // Add new node at head of sector thread starting at s->touching_thinglist - node->m_sprev = NULL; // prev node on sector thread - node->m_snext = s->touching_thinglist; // next node on sector thread + node->m_sprev = NULL; // prev node on sector thread + node->m_snext = s->touching_thinglist; // next node on sector thread if (s->touching_thinglist) node->m_snext->m_sprev = node; s->touching_thinglist = node; @@ -5532,7 +5495,7 @@ msecnode_t *P_AddSecnode (sector_t *s, AActor *thing, msecnode_t *nextnode) // //============================================================================= -msecnode_t *P_DelSecnode (msecnode_t *node) +msecnode_t *P_DelSecnode(msecnode_t *node) { msecnode_t* tp; // prev node on thing thread msecnode_t* tn; // next node on thing thread @@ -5579,11 +5542,11 @@ msecnode_t *P_DelSecnode (msecnode_t *node) // //============================================================================= -void P_DelSector_List () +void P_DelSector_List() { if (sector_list != NULL) { - P_DelSeclist (sector_list); + P_DelSeclist(sector_list); sector_list = NULL; } } @@ -5596,10 +5559,10 @@ void P_DelSector_List () // //============================================================================= -void P_DelSeclist (msecnode_t *node) +void P_DelSeclist(msecnode_t *node) { while (node) - node = P_DelSecnode (node); + node = P_DelSecnode(node); } //============================================================================= @@ -5611,7 +5574,7 @@ void P_DelSeclist (msecnode_t *node) // //============================================================================= -void P_CreateSecNodeList (AActor *thing, fixed_t x, fixed_t y) +void P_CreateSecNodeList(AActor *thing, fixed_t x, fixed_t y) { msecnode_t *node; @@ -5633,13 +5596,13 @@ void P_CreateSecNodeList (AActor *thing, fixed_t x, fixed_t y) while ((ld = it.Next())) { - if (box.Right() <= ld->bbox[BOXLEFT] || - box.Left() >= ld->bbox[BOXRIGHT] || - box.Top() <= ld->bbox[BOXBOTTOM] || + if (box.Right() <= ld->bbox[BOXLEFT] || + box.Left() >= ld->bbox[BOXRIGHT] || + box.Top() <= ld->bbox[BOXBOTTOM] || box.Bottom() >= ld->bbox[BOXTOP]) continue; - if (box.BoxOnLineSide (ld) != -1) + if (box.BoxOnLineSide(ld) != -1) continue; // This line crosses through the object. @@ -5649,7 +5612,7 @@ void P_CreateSecNodeList (AActor *thing, fixed_t x, fixed_t y) // allowed to move to this position, then the sector_list // will be attached to the Thing's AActor at touching_sectorlist. - sector_list = P_AddSecnode (ld->frontsector,thing,sector_list); + sector_list = P_AddSecnode(ld->frontsector, thing, sector_list); // Don't assume all lines are 2-sided, since some Things // like MT_TFOG are allowed regardless of whether their radius takes @@ -5664,7 +5627,7 @@ void P_CreateSecNodeList (AActor *thing, fixed_t x, fixed_t y) // Add the sector of the (x,y) point to sector_list. - sector_list = P_AddSecnode (thing->Sector, thing, sector_list); + sector_list = P_AddSecnode(thing->Sector, thing, sector_list); // Now delete any nodes that won't be used. These are the ones where // m_thing is still NULL. @@ -5676,7 +5639,7 @@ void P_CreateSecNodeList (AActor *thing, fixed_t x, fixed_t y) { if (node == sector_list) sector_list = node->m_tnext; - node = P_DelSecnode (node); + node = P_DelSecnode(node); } else { @@ -5691,7 +5654,7 @@ void P_CreateSecNodeList (AActor *thing, fixed_t x, fixed_t y) // //========================================================================== -void SpawnShootDecal (AActor *t1, const FTraceResults &trace) +void SpawnShootDecal(AActor *t1, const FTraceResults &trace) { FDecalBase *decalbase = NULL; @@ -5705,7 +5668,7 @@ void SpawnShootDecal (AActor *t1, const FTraceResults &trace) } if (decalbase != NULL) { - DImpactDecal::StaticCreate (decalbase->GetDecal (), + DImpactDecal::StaticCreate(decalbase->GetDecal(), trace.X, trace.Y, trace.Z, trace.Line->sidedef[trace.Side], trace.ffloor); } } @@ -5716,10 +5679,10 @@ void SpawnShootDecal (AActor *t1, const FTraceResults &trace) // //========================================================================== -static void SpawnDeepSplash (AActor *t1, const FTraceResults &trace, AActor *puff, +static void SpawnDeepSplash(AActor *t1, const FTraceResults &trace, AActor *puff, fixed_t vx, fixed_t vy, fixed_t vz, fixed_t shootz, bool ffloor) { - const secplane_t *plane; + const secplane_t *plane; if (ffloor && trace.Crossed3DWater) plane = trace.Crossed3DWater->top.plane; else if (trace.CrossedWater && trace.CrossedWater->heightsec) @@ -5727,19 +5690,19 @@ static void SpawnDeepSplash (AActor *t1, const FTraceResults &trace, AActor *puf else return; fixed_t num, den, hitdist; - den = TMulScale16 (plane->a, vx, plane->b, vy, plane->c, vz); + den = TMulScale16(plane->a, vx, plane->b, vy, plane->c, vz); if (den != 0) { - num = TMulScale16 (plane->a, t1->x, plane->b, t1->y, plane->c, shootz) + plane->d; - hitdist = FixedDiv (-num, den); + num = TMulScale16(plane->a, t1->x, plane->b, t1->y, plane->c, shootz) + plane->d; + hitdist = FixedDiv(-num, den); if (hitdist >= 0 && hitdist <= trace.Distance) { - fixed_t hitx = t1->x+FixedMul (vx, hitdist); - fixed_t hity = t1->y+FixedMul (vy, hitdist); - fixed_t hitz = shootz+FixedMul (vz, hitdist); + fixed_t hitx = t1->x + FixedMul(vx, hitdist); + fixed_t hity = t1->y + FixedMul(vy, hitdist); + fixed_t hitz = shootz + FixedMul(vz, hitdist); - P_HitWater (puff != NULL? puff:t1, P_PointInSector(hitx, hity), hitx, hity, hitz); + P_HitWater(puff != NULL ? puff : t1, P_PointInSector(hitx, hity), hitx, hity, hitz); } } } @@ -5761,12 +5724,12 @@ bool P_ActivateThingSpecial(AActor * thing, AActor * trigger, bool death) if (thing->activationtype & THINGSPEC_TriggerTargets) trigger->target = thing; // State change mechanism. The thing needs to be not dead and to have at least one of the relevant flags - if (!death && (thing->activationtype & (THINGSPEC_Activate|THINGSPEC_Deactivate|THINGSPEC_Switch))) + if (!death && (thing->activationtype & (THINGSPEC_Activate | THINGSPEC_Deactivate | THINGSPEC_Switch))) { // If a switchable thing does not know whether it should be activated // or deactivated, the default is to activate it. - if ((thing->activationtype & THINGSPEC_Switch) - && !(thing->activationtype & (THINGSPEC_Activate|THINGSPEC_Deactivate))) + if ((thing->activationtype & THINGSPEC_Switch) + && !(thing->activationtype & (THINGSPEC_Activate | THINGSPEC_Deactivate))) { thing->activationtype |= THINGSPEC_Activate; } @@ -5793,11 +5756,11 @@ bool P_ActivateThingSpecial(AActor * thing, AActor * trigger, bool death) // Run the special, if any if (thing->special) { - res = !! P_ExecuteSpecial(thing->special, NULL, + res = !!P_ExecuteSpecial(thing->special, NULL, // TriggerActs overrides the level flag, which only concerns thing activated by death (((death && level.flags & LEVEL_ACTOWNSPECIAL && !(thing->activationtype & THINGSPEC_TriggerActs)) || (thing->activationtype & THINGSPEC_ThingActs)) // Who triggers? - ? thing : trigger), + ? thing : trigger), false, thing->args[0], thing->args[1], thing->args[2], thing->args[3], thing->args[4]); // Clears the special if it was run on thing's death or if flag is set. From e1ee80661e285f2be6d3ef58e5ec0e1fe8d554fe Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 7 Aug 2014 17:12:04 -0500 Subject: [PATCH 29/54] Make FWallCoords' members lowercase because they're kind of a pain to type when all uppercase. - Also, make its sx1 and sx2 members shorts, so it takes less space, since it's getting crammed into a vissprite now. --- src/r_bsp.cpp | 90 ++++++++++++------------ src/r_bsp.h | 12 ++-- src/r_segs.cpp | 180 +++++++++++++++++++++++------------------------ src/r_things.cpp | 12 ++-- 4 files changed, 147 insertions(+), 147 deletions(-) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 02a89f371..c56255888 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -408,7 +408,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, rw_frontcz2 <= s->floorplane.ZatPoint (curline->v2->x, curline->v2->y)) { // Check that the window is actually visible - for (int z = WallC.SX1; z < WallC.SX2; ++z) + for (int z = WallC.sx1; z < WallC.sx2; ++z) { if (floorclip[z] > ceilingclip[z]) { @@ -541,12 +541,12 @@ void R_AddLine (seg_t *line) if (WallC.Init(tx1, ty1, tx2, ty2, 32)) return; - if (WallC.SX1 > WindowRight || WallC.SX2 < WindowLeft) + if (WallC.sx1 > WindowRight || WallC.sx2 < WindowLeft) return; if (line->linedef == NULL) { - if (R_CheckClipWallSegment (WallC.SX1, WallC.SX2)) + if (R_CheckClipWallSegment (WallC.sx1, WallC.sx2)) { InSubsector->flags |= SSECF_DRAWN; } @@ -695,7 +695,7 @@ void R_AddLine (seg_t *line) // mark their subsectors as visible for automap texturing. if (hasglnodes && !(InSubsector->flags & SSECF_DRAWN)) { - if (R_CheckClipWallSegment(WallC.SX1, WallC.SX2)) + if (R_CheckClipWallSegment(WallC.sx1, WallC.sx2)) { InSubsector->flags |= SSECF_DRAWN; } @@ -709,8 +709,8 @@ void R_AddLine (seg_t *line) if (line->linedef->special == Line_Horizon) { // Be aware: Line_Horizon does not work properly with sloped planes - clearbufshort (walltop+WallC.SX1, WallC.SX2 - WallC.SX1, centery); - clearbufshort (wallbottom+WallC.SX1, WallC.SX2 - WallC.SX1, centery); + clearbufshort (walltop+WallC.sx1, WallC.sx2 - WallC.sx1, centery); + clearbufshort (wallbottom+WallC.sx1, WallC.sx2 - WallC.sx1, centery); } else { @@ -735,7 +735,7 @@ void R_AddLine (seg_t *line) #endif } - if (R_ClipWallSegment (WallC.SX1, WallC.SX2, solid)) + if (R_ClipWallSegment (WallC.sx1, WallC.sx2, solid)) { InSubsector->flags |= SSECF_DRAWN; } @@ -748,58 +748,58 @@ void R_AddLine (seg_t *line) // bool FWallCoords::Init(int x1, int y1, int x2, int y2, int too_close) { - TX1 = DMulScale20(x1, viewsin, -y1, viewcos); - TX2 = DMulScale20(x2, viewsin, -y2, viewcos); + tx1 = DMulScale20(x1, viewsin, -y1, viewcos); + tx2 = DMulScale20(x2, viewsin, -y2, viewcos); - TY1 = DMulScale20(x1, viewtancos, y1, viewtansin); - TY2 = DMulScale20(x2, viewtancos, y2, viewtansin); + ty1 = DMulScale20(x1, viewtancos, y1, viewtansin); + ty2 = DMulScale20(x2, viewtancos, y2, viewtansin); if (MirrorFlags & RF_XFLIP) { - int t = 256 - TX1; - TX1 = 256 - TX2; - TX2 = t; - swapvalues(TY1, TY2); + int t = 256 - tx1; + tx1 = 256 - tx2; + tx2 = t; + swapvalues(ty1, ty2); } - if (TX1 >= -TY1) + if (tx1 >= -ty1) { - if (TX1 > TY1) return true; // left edge is off the right side - if (TY1 == 0) return true; - SX1 = (centerxfrac + Scale(TX1, centerxfrac, TY1)) >> FRACBITS; - if (TX1 >= 0) SX1 = MIN(viewwidth, SX1+1); // fix for signed divide - SZ1 = TY1; + if (tx1 > ty1) return true; // left edge is off the right side + if (ty1 == 0) return true; + sx1 = (centerxfrac + Scale(tx1, centerxfrac, ty1)) >> FRACBITS; + if (tx1 >= 0) sx1 = MIN(viewwidth, sx1+1); // fix for signed divide + sz1 = ty1; } else { - if (TX2 < -TY2) return true; // wall is off the left side - fixed_t den = TX1 - TX2 - TY2 + TY1; + if (tx2 < -ty2) return true; // wall is off the left side + fixed_t den = tx1 - tx2 - ty2 + ty1; if (den == 0) return true; - SX1 = 0; - SZ1 = TY1 + Scale(TY2 - TY1, TX1 + TY1, den); + sx1 = 0; + sz1 = ty1 + Scale(ty2 - ty1, tx1 + ty1, den); } - if (SZ1 < too_close) + if (sz1 < too_close) return true; - if (TX2 <= TY2) + if (tx2 <= ty2) { - if (TX2 < -TY2) return true; // right edge is off the left side - if (TY2 == 0) return true; - SX2 = (centerxfrac + Scale(TX2, centerxfrac, TY2)) >> FRACBITS; - if (TX2 >= 0) SX2 = MIN(viewwidth, SX2+1); // fix for signed divide - SZ2 = TY2; + if (tx2 < -ty2) return true; // right edge is off the left side + if (ty2 == 0) return true; + sx2 = (centerxfrac + Scale(tx2, centerxfrac, ty2)) >> FRACBITS; + if (tx2 >= 0) sx2 = MIN(viewwidth, sx2+1); // fix for signed divide + sz2 = ty2; } else { - if (TX1 > TY1) return true; // wall is off the right side - fixed_t den = TY2 - TY1 - TX2 + TX1; + if (tx1 > ty1) return true; // wall is off the right side + fixed_t den = ty2 - ty1 - tx2 + tx1; if (den == 0) return true; - SX2 = viewwidth; - SZ2 = TY1 + Scale(TY2 - TY1, TX1 - TY1, den); + sx2 = viewwidth; + sz2 = ty1 + Scale(ty2 - ty1, tx1 - ty1, den); } - if (SZ2 < too_close || SX2 <= SX1) + if (sz2 < too_close || sx2 <= sx1) return true; return false; @@ -809,17 +809,17 @@ void FWallTmapVals::InitFromWallCoords(const FWallCoords *wallc) { if (MirrorFlags & RF_XFLIP) { - UoverZorg = (float)wallc->TX2 * WallTMapScale; - UoverZstep = (float)(-wallc->TY2) * 32.f; - InvZorg = (float)(wallc->TX2 - wallc->TX1) * WallTMapScale; - InvZstep = (float)(wallc->TY1 - wallc->TY2) * 32.f; + UoverZorg = (float)wallc->tx2 * WallTMapScale; + UoverZstep = (float)(-wallc->ty2) * 32.f; + InvZorg = (float)(wallc->tx2 - wallc->tx1) * WallTMapScale; + InvZstep = (float)(wallc->ty1 - wallc->ty2) * 32.f; } else { - UoverZorg = (float)wallc->TX1 * WallTMapScale; - UoverZstep = (float)(-wallc->TY1) * 32.f; - InvZorg = (float)(wallc->TX1 - wallc->TX2) * WallTMapScale; - InvZstep = (float)(wallc->TY2 - wallc->TY1) * 32.f; + UoverZorg = (float)wallc->tx1 * WallTMapScale; + UoverZstep = (float)(-wallc->ty1) * 32.f; + InvZorg = (float)(wallc->tx1 - wallc->tx2) * WallTMapScale; + InvZstep = (float)(wallc->ty2 - wallc->ty1) * 32.f; } InitDepth(); } diff --git a/src/r_bsp.h b/src/r_bsp.h index d15beca0c..79dac6c88 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -33,14 +33,14 @@ struct FWallCoords { - fixed_t TX1, TX2; // x coords at left, right of wall in view space - fixed_t TY1, TY2; // y coords at left, right of wall in view space + fixed_t tx1, tx2; // x coords at left, right of wall in view space + fixed_t ty1, ty2; // y coords at left, right of wall in view space - fixed_t CX1, CX2; // x coords at left, right of wall in camera space - fixed_t CY1, CY2; // y coords at left, right of wall in camera space + fixed_t cx1, cx2; // x coords at left, right of wall in camera space + fixed_t cy1, cy2; // y coords at left, right of wall in camera space - int SX1, SX2; // x coords at left, right of wall in screen space - fixed_t SZ1, SZ2; // depth at left, right of wall in screen space + short sx1, sx2; // x coords at left, right of wall in screen space + fixed_t sz1, sz2; // depth at left, right of wall in screen space bool Init(int x1, int y1, int x2, int y2, int too_close); }; diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 25395a596..15f736c93 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -376,10 +376,10 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) goto clearfog; } - WallC.SZ1 = ds->sz1; - WallC.SZ2 = ds->sz2; - WallC.SX1 = ds->sx1; - WallC.SX2 = ds->sx2; + WallC.sz1 = ds->sz1; + WallC.sz2 = ds->sz2; + WallC.sx1 = ds->sx1; + WallC.sx2 = ds->sx2; if (fake3D & FAKE3D_CLIPTOP) { @@ -467,10 +467,10 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) } else { // Texture does wrap vertically. - WallC.SZ1 = ds->sz1; - WallC.SZ2 = ds->sz2; - WallC.SX1 = ds->sx1; - WallC.SX2 = ds->sx2; + WallC.sz1 = ds->sz1; + WallC.sz2 = ds->sz2; + WallC.sx1 = ds->sx1; + WallC.sx2 = ds->sx2; if (CurrentSkybox) { // Midtex clipping doesn't work properly with skyboxes, since you're normally below the floor @@ -587,14 +587,14 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) else if (fixedcolormap != NULL) dc_colormap = fixedcolormap; - WallC.SZ1 = ds->sz1; - WallC.SZ2 = ds->sz2; - WallC.SX1 = ds->sx1; - WallC.SX2 = ds->sx2; - WallC.TX1 = ds->cx; - WallC.TY1 = ds->cy; - WallC.TX2 = ds->cx + ds->cdx; - WallC.TY2 = ds->cy + ds->cdy; + WallC.sz1 = ds->sz1; + WallC.sz2 = ds->sz2; + WallC.sx1 = ds->sx1; + WallC.sx2 = ds->sx2; + WallC.tx1 = ds->cx; + WallC.ty1 = ds->cy; + WallC.tx2 = ds->cx + ds->cdx; + WallC.ty2 = ds->cy + ds->cdy; WallT = ds->tmapvals; OWallMost(wallupper, sclipTop - viewz, &WallC); @@ -1209,8 +1209,8 @@ void wallscan_striped (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, up = uwal; down = most1; - assert(WallC.SX1 <= x1); - assert(WallC.SX2 > x2); + assert(WallC.sx1 <= x1); + assert(WallC.sx2 > x2); // kg3D - fake floors instead of zdoom light list for (unsigned int i = 0; i < frontsector->e->XFloor.lightlist.Size(); i++) @@ -1821,7 +1821,7 @@ void R_RenderSegLoop () yscale = FixedMul(rw_pic->yScale, rw_midtexturescaley); if (xscale != lwallscale) { - PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.SX1, WallC.SX2); + PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2); lwallscale = xscale; } if (midtexture->bWorldPanning) @@ -1864,7 +1864,7 @@ void R_RenderSegLoop () yscale = FixedMul(rw_pic->yScale, rw_toptexturescaley); if (xscale != lwallscale) { - PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.SX1, WallC.SX2); + PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2); lwallscale = xscale; } if (toptexture->bWorldPanning) @@ -1910,7 +1910,7 @@ void R_RenderSegLoop () yscale = FixedMul(rw_pic->yScale, rw_bottomtexturescaley); if (xscale != lwallscale) { - PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.SX1, WallC.SX2); + PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2); lwallscale = xscale; } if (bottomtexture->bWorldPanning) @@ -2030,7 +2030,7 @@ void R_NewWall (bool needlights) { if (rw_havehigh) { // front ceiling is above back ceiling - memcpy (&walltop[WallC.SX1], &wallupper[WallC.SX1], (WallC.SX2 - WallC.SX1)*sizeof(walltop[0])); + memcpy (&walltop[WallC.sx1], &wallupper[WallC.sx1], (WallC.sx2 - WallC.sx1)*sizeof(walltop[0])); rw_havehigh = false; } else if (rw_havelow && frontsector->ceilingplane != backsector->ceilingplane) @@ -2255,15 +2255,15 @@ void R_NewWall (bool needlights) bottomtexture ? FixedMul(bottomtexture->xScale, sidedef->GetTextureXScale(side_t::bottom)) : FRACUNIT; - PrepWall (swall, lwall, sidedef->TexelLength * lwallscale, WallC.SX1, WallC.SX2); + PrepWall (swall, lwall, sidedef->TexelLength * lwallscale, WallC.sx1, WallC.sx2); if (fixedcolormap == NULL && fixedlightlev < 0) { wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, frontsector->lightlevel) + r_actualextralight); GlobVis = r_WallVisibility; - rw_lightleft = SafeDivScale12 (GlobVis, WallC.SZ1); - rw_lightstep = (SafeDivScale12 (GlobVis, WallC.SZ2) - rw_lightleft) / (WallC.SX2 - WallC.SX1); + rw_lightleft = SafeDivScale12 (GlobVis, WallC.sz1); + rw_lightstep = (SafeDivScale12 (GlobVis, WallC.sz2) - rw_lightleft) / (WallC.sx2 - WallC.sx1); } else { @@ -2337,19 +2337,19 @@ void R_StoreWallRange (int start, int stop) } rw_offset = sidedef->GetTextureXOffset(side_t::mid); - rw_light = rw_lightleft + rw_lightstep * (start - WallC.SX1); + rw_light = rw_lightleft + rw_lightstep * (start - WallC.sx1); - ds_p->sx1 = WallC.SX1; - ds_p->sx2 = WallC.SX2; - ds_p->sz1 = WallC.SZ1; - ds_p->sz2 = WallC.SZ2; - ds_p->cx = WallC.TX1; - ds_p->cy = WallC.TY1; - ds_p->cdx = WallC.TX2 - WallC.TX1; - ds_p->cdy = WallC.TY2 - WallC.TY1; + ds_p->sx1 = WallC.sx1; + ds_p->sx2 = WallC.sx2; + ds_p->sz1 = WallC.sz1; + ds_p->sz2 = WallC.sz2; + ds_p->cx = WallC.tx1; + ds_p->cy = WallC.ty1; + ds_p->cdx = WallC.tx2 - WallC.tx1; + ds_p->cdy = WallC.ty2 - WallC.ty1; ds_p->tmapvals = WallT; - ds_p->siz1 = (DWORD)DivScale32 (1, WallC.SZ1) >> 1; - ds_p->siz2 = (DWORD)DivScale32 (1, WallC.SZ2) >> 1; + ds_p->siz1 = (DWORD)DivScale32 (1, WallC.sz1) >> 1; + ds_p->siz2 = (DWORD)DivScale32 (1, WallC.sz2) >> 1; ds_p->x1 = rw_x = start; ds_p->x2 = stop-1; ds_p->curline = curline; @@ -2442,7 +2442,7 @@ void R_StoreWallRange (int start, int stop) if ((TexMan(sidedef->GetTexture(side_t::mid), true)->UseType != FTexture::TEX_Null || ds_p->bFakeBoundary || IsFogBoundary (frontsector, backsector)) && (rw_ceilstat != 12 || !sidedef->GetTexture(side_t::top).isValid()) && (rw_floorstat != 3 || !sidedef->GetTexture(side_t::bottom).isValid()) && - (WallC.SZ1 >= TOO_CLOSE_Z && WallC.SZ2 >= TOO_CLOSE_Z)) + (WallC.sz1 >= TOO_CLOSE_Z && WallC.sz2 >= TOO_CLOSE_Z)) { fixed_t *swal; fixed_t *lwal; @@ -2590,59 +2590,59 @@ int OWallMost (short *mostbuf, fixed_t z, const FWallCoords *wallc) fixed_t s1, s2, s3, s4; z = -(z >> 4); - s1 = MulScale16 (globaluclip, wallc->SZ1); s2 = MulScale16 (globaluclip, wallc->SZ2); - s3 = MulScale16 (globaldclip, wallc->SZ1); s4 = MulScale16 (globaldclip, wallc->SZ2); + s1 = MulScale16 (globaluclip, wallc->sz1); s2 = MulScale16 (globaluclip, wallc->sz2); + s3 = MulScale16 (globaldclip, wallc->sz1); s4 = MulScale16 (globaldclip, wallc->sz2); bad = (zs3)<<2)+((z>s4)<<3); #if 1 if ((bad&3) == 3) { - memset (&mostbuf[wallc->SX1], 0, (wallc->SX2 - wallc->SX1)*sizeof(mostbuf[0])); + memset (&mostbuf[wallc->sx1], 0, (wallc->sx2 - wallc->sx1)*sizeof(mostbuf[0])); return bad; } if ((bad&12) == 12) { - clearbufshort (&mostbuf[wallc->SX1], wallc->SX2 - wallc->SX1, viewheight); + clearbufshort (&mostbuf[wallc->sx1], wallc->sx2 - wallc->sx1, viewheight); return bad; } #endif - ix1 = wallc->SX1; iy1 = wallc->SZ1; - ix2 = wallc->SX2; iy2 = wallc->SZ2; + ix1 = wallc->sx1; iy1 = wallc->sz1; + ix2 = wallc->sx2; iy2 = wallc->sz2; #if 1 if (bad & 3) { int t = DivScale30 (z-s1, s2-s1); - int inty = wallc->SZ1 + MulScale30 (wallc->SZ2 - wallc->SZ1, t); - int xcross = wallc->SX1 + Scale (MulScale30 (wallc->SZ2, t), wallc->SX2 - wallc->SX1, inty); + int inty = wallc->sz1 + MulScale30 (wallc->sz2 - wallc->sz1, t); + int xcross = wallc->sx1 + Scale (MulScale30 (wallc->sz2, t), wallc->sx2 - wallc->sx1, inty); if ((bad & 3) == 2) { - if (wallc->SX1 <= xcross) { iy2 = inty; ix2 = xcross; } - if (wallc->SX2 > xcross) memset (&mostbuf[xcross], 0, (wallc->SX2-xcross)*sizeof(mostbuf[0])); + if (wallc->sx1 <= xcross) { iy2 = inty; ix2 = xcross; } + if (wallc->sx2 > xcross) memset (&mostbuf[xcross], 0, (wallc->sx2-xcross)*sizeof(mostbuf[0])); } else { - if (xcross <= wallc->SX2) { iy1 = inty; ix1 = xcross; } - if (xcross > wallc->SX1) memset (&mostbuf[wallc->SX1], 0, (xcross-wallc->SX1)*sizeof(mostbuf[0])); + if (xcross <= wallc->sx2) { iy1 = inty; ix1 = xcross; } + if (xcross > wallc->sx1) memset (&mostbuf[wallc->sx1], 0, (xcross-wallc->sx1)*sizeof(mostbuf[0])); } } if (bad & 12) { int t = DivScale30 (z-s3, s4-s3); - int inty = wallc->SZ1 + MulScale30 (wallc->SZ2 - wallc->SZ1, t); - int xcross = wallc->SX1 + Scale (MulScale30 (wallc->SZ2, t), wallc->SX2 - wallc->SX1, inty); + int inty = wallc->sz1 + MulScale30 (wallc->sz2 - wallc->sz1, t); + int xcross = wallc->sx1 + Scale (MulScale30 (wallc->sz2, t), wallc->sx2 - wallc->sx1, inty); if ((bad & 12) == 8) { - if (wallc->SX1 <= xcross) { iy2 = inty; ix2 = xcross; } - if (wallc->SX2 > xcross) clearbufshort (&mostbuf[xcross], wallc->SX2 - xcross, viewheight); + if (wallc->sx1 <= xcross) { iy2 = inty; ix2 = xcross; } + if (wallc->sx2 > xcross) clearbufshort (&mostbuf[xcross], wallc->sx2 - xcross, viewheight); } else { - if (xcross <= wallc->SX2) { iy1 = inty; ix1 = xcross; } - if (xcross > wallc->SX1) clearbufshort (&mostbuf[wallc->SX1], xcross - wallc->SX1, viewheight); + if (xcross <= wallc->sx2) { iy1 = inty; ix1 = xcross; } + if (xcross > wallc->sx1) clearbufshort (&mostbuf[wallc->sx1], xcross - wallc->sx1, viewheight); } } @@ -2660,12 +2660,12 @@ int OWallMost (short *mostbuf, fixed_t z, const FWallCoords *wallc) double max = viewheight; double zz = z / 65536.0; #if 0 - double z1 = zz * InvZtoScale / wallc->SZ1; - double z2 = zz * InvZtoScale / wallc->SZ2 - z1; - z2 /= (wallc->SX2 - wallc->SX1); + double z1 = zz * InvZtoScale / wallc->sz1; + double z2 = zz * InvZtoScale / wallc->sz2 - z1; + z2 /= (wallc->sx2 - wallc->sx1); z1 += centeryfrac / 65536.0; - for (int x = wallc->SX1; x < wallc->SX2; ++x) + for (int x = wallc->sx1; x < wallc->sx2; ++x) { mostbuf[x] = xs_RoundToInt(clamp(z1, 0.0, max)); z1 += z2; @@ -2673,12 +2673,12 @@ int OWallMost (short *mostbuf, fixed_t z, const FWallCoords *wallc) #else double top, bot, i; - i = wallc->SX1 - centerx; + i = wallc->sx1 - centerx; top = WallT.UoverZorg + WallT.UoverZstep * i; bot = WallT.InvZorg + WallT.InvZstep * i; double cy = centeryfrac / 65536.0; - for (int x = wallc->SX1; x < wallc->SX2; x++) + for (int x = wallc->sx1; x < wallc->sx2; x++) { double frac = top / bot; double scale = frac * WallT.DepthScale + WallT.DepthOrg; @@ -2711,21 +2711,21 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) { x = curline->v2->x; y = curline->v2->y; - if (wallc->SX1 == 0 && 0 != (den = wallc->TX1 - wallc->TX2 + wallc->TY1 - wallc->TY2)) + if (wallc->sx1 == 0 && 0 != (den = wallc->tx1 - wallc->tx2 + wallc->ty1 - wallc->ty2)) { - int frac = SafeDivScale30 (wallc->TY1 + wallc->TX1, den); + int frac = SafeDivScale30 (wallc->ty1 + wallc->tx1, den); x -= MulScale30 (frac, x - curline->v1->x); y -= MulScale30 (frac, y - curline->v1->y); } z1 = viewz - plane.ZatPoint (x, y); - if (wallc->SX2 > wallc->SX1 + 1) + if (wallc->sx2 > wallc->sx1 + 1) { x = curline->v1->x; y = curline->v1->y; - if (wallc->SX2 == viewwidth && 0 != (den = wallc->TX1 - wallc->TX2 - wallc->TY1 + wallc->TY2)) + if (wallc->sx2 == viewwidth && 0 != (den = wallc->tx1 - wallc->tx2 - wallc->ty1 + wallc->ty2)) { - int frac = SafeDivScale30 (wallc->TY2 - wallc->TX2, den); + int frac = SafeDivScale30 (wallc->ty2 - wallc->tx2, den); x += MulScale30 (frac, curline->v2->x - x); y += MulScale30 (frac, curline->v2->y - y); } @@ -2740,21 +2740,21 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) { x = curline->v1->x; y = curline->v1->y; - if (wallc->SX1 == 0 && 0 != (den = wallc->TX1 - wallc->TX2 + wallc->TY1 - wallc->TY2)) + if (wallc->sx1 == 0 && 0 != (den = wallc->tx1 - wallc->tx2 + wallc->ty1 - wallc->ty2)) { - int frac = SafeDivScale30 (wallc->TY1 + wallc->TX1, den); + int frac = SafeDivScale30 (wallc->ty1 + wallc->tx1, den); x += MulScale30 (frac, curline->v2->x - x); y += MulScale30 (frac, curline->v2->y - y); } z1 = viewz - plane.ZatPoint (x, y); - if (wallc->SX2 > wallc->SX1 + 1) + if (wallc->sx2 > wallc->sx1 + 1) { x = curline->v2->x; y = curline->v2->y; - if (wallc->SX2 == viewwidth && 0 != (den = wallc->TX1 - wallc->TX2 - wallc->TY1 + wallc->TY2)) + if (wallc->sx2 == viewwidth && 0 != (den = wallc->tx1 - wallc->tx2 - wallc->ty1 + wallc->ty2)) { - int frac = SafeDivScale30 (wallc->TY2 - wallc->TX2, den); + int frac = SafeDivScale30 (wallc->ty2 - wallc->tx2, den); x -= MulScale30 (frac, x - curline->v1->x); y -= MulScale30 (frac, y - curline->v1->y); } @@ -2766,12 +2766,12 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) } } - s1 = MulScale12 (globaluclip, wallc->SZ1); s2 = MulScale12 (globaluclip, wallc->SZ2); - s3 = MulScale12 (globaldclip, wallc->SZ1); s4 = MulScale12 (globaldclip, wallc->SZ2); + s1 = MulScale12 (globaluclip, wallc->sz1); s2 = MulScale12 (globaluclip, wallc->sz2); + s3 = MulScale12 (globaldclip, wallc->sz1); s4 = MulScale12 (globaldclip, wallc->sz2); bad = (z1s3)<<2)+((z2>s4)<<3); - ix1 = wallc->SX1; ix2 = wallc->SX2; - iy1 = wallc->SZ1; iy2 = wallc->SZ2; + ix1 = wallc->sx1; ix2 = wallc->sx2; + iy1 = wallc->sz1; iy2 = wallc->sz2; oz1 = z1; oz2 = z2; if ((bad&3) == 3) @@ -2791,9 +2791,9 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) { //inty = intz / (globaluclip>>16) int t = SafeDivScale30 (oz1-s1, s2-s1+oz1-oz2); - int inty = wallc->SZ1 + MulScale30 (wallc->SZ2-wallc->SZ1,t); + int inty = wallc->sz1 + MulScale30 (wallc->sz2-wallc->sz1,t); int intz = oz1 + MulScale30 (oz2-oz1,t); - int xcross = wallc->SX1 + Scale (MulScale30 (wallc->SZ2, t), wallc->SX2-wallc->SX1, inty); + int xcross = wallc->sx1 + Scale (MulScale30 (wallc->sz2, t), wallc->sx2-wallc->sx1, inty); //t = divscale30((x1<<4)-xcross*yb1[w],xcross*(yb2[w]-yb1[w])-((x2-x1)<<4)); //inty = yb1[w] + mulscale30(yb2[w]-yb1[w],t); @@ -2801,13 +2801,13 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) if ((bad&3) == 2) { - if (wallc->SX1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; } - memset (&mostbuf[xcross], 0, (wallc->SX2-xcross)*sizeof(mostbuf[0])); + if (wallc->sx1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; } + memset (&mostbuf[xcross], 0, (wallc->sx2-xcross)*sizeof(mostbuf[0])); } else { - if (xcross <= wallc->SX2) { z1 = intz; iy1 = inty; ix1 = xcross; } - memset (&mostbuf[wallc->SX1], 0, (xcross-wallc->SX1)*sizeof(mostbuf[0])); + if (xcross <= wallc->sx2) { z1 = intz; iy1 = inty; ix1 = xcross; } + memset (&mostbuf[wallc->sx1], 0, (xcross-wallc->sx1)*sizeof(mostbuf[0])); } } @@ -2815,9 +2815,9 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) { //inty = intz / (globaldclip>>16) int t = SafeDivScale30 (oz1-s3, s4-s3+oz1-oz2); - int inty = wallc->SZ1 + MulScale30 (wallc->SZ2-wallc->SZ1,t); + int inty = wallc->sz1 + MulScale30 (wallc->sz2-wallc->sz1,t); int intz = oz1 + MulScale30 (oz2-oz1,t); - int xcross = wallc->SX1 + Scale (MulScale30 (wallc->SZ2, t), wallc->SX2-wallc->SX1,inty); + int xcross = wallc->sx1 + Scale (MulScale30 (wallc->sz2, t), wallc->sx2-wallc->sx1,inty); //t = divscale30((x1<<4)-xcross*yb1[w],xcross*(yb2[w]-yb1[w])-((x2-x1)<<4)); //inty = yb1[w] + mulscale30(yb2[w]-yb1[w],t); @@ -2825,13 +2825,13 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) if ((bad&12) == 8) { - if (wallc->SX1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; } - if (wallc->SX2 > xcross) clearbufshort (&mostbuf[xcross], wallc->SX2-xcross, viewheight); + if (wallc->sx1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; } + if (wallc->sx2 > xcross) clearbufshort (&mostbuf[xcross], wallc->sx2-xcross, viewheight); } else { - if (xcross <= wallc->SX2) { z1 = intz; iy1 = inty; ix1 = xcross; } - if (xcross > wallc->SX1) clearbufshort (&mostbuf[wallc->SX1], xcross-wallc->SX1, viewheight); + if (xcross <= wallc->sx2) { z1 = intz; iy1 = inty; ix1 = xcross; } + if (xcross > wallc->sx1) clearbufshort (&mostbuf[wallc->sx1], xcross-wallc->sx1, viewheight); } } @@ -3041,8 +3041,8 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, if (WallC.Init(lx, ly, lx2, ly2, TOO_CLOSE_Z)) goto done; - x1 = WallC.SX1; - x2 = WallC.SX2; + x1 = WallC.sx1; + x2 = WallC.sx2; if (x1 > clipper->x2 || x2 <= clipper->x1) goto done; @@ -3145,7 +3145,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, rereadcolormap = false; } - rw_light = rw_lightleft + (x1 - WallC.SX1) * rw_lightstep; + rw_light = rw_lightleft + (x1 - WallC.sx1) * rw_lightstep; if (fixedlightlev >= 0) dc_colormap = usecolormap->Maps + fixedlightlev; else if (fixedcolormap != NULL) diff --git a/src/r_things.cpp b/src/r_things.cpp index 1d2c07a2a..72ebcf8c4 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -411,8 +411,8 @@ void R_DrawWallSprite(vissprite_t *spr) fixed_t yscale; int shade = LIGHT2SHADE(140); - x1 = MAX(spr->x1, spr->wallc.SX1); - x2 = MIN(spr->x2, spr->wallc.SX2 + 1); + x1 = MAX(spr->x1, spr->wallc.sx1); + x2 = MIN(spr->x2, spr->wallc.sx2 + 1); if (x1 >= x2) return; WallT.InitFromWallCoords(&spr->wallc); @@ -440,7 +440,7 @@ void R_DrawWallSprite(vissprite_t *spr) rereadcolormap = false; } - rw_light = rw_lightleft + (x1 - spr->wallc.SX1) * rw_lightstep; + rw_light = rw_lightleft + (x1 - spr->wallc.sx1) * rw_lightstep; if (fixedlightlev >= 0) dc_colormap = usecolormap->Maps + fixedlightlev; else if (fixedcolormap != NULL) @@ -1057,7 +1057,7 @@ static void R_ProjectWallSprite(AActor *thing, fixed_t fx, fixed_t fy, fixed_t f if (wallc.Init(lx1, ly1, lx2, ly2, TOO_CLOSE_Z)) return; - if (wallc.SX1 > WindowRight || wallc.SX2 <= WindowLeft) + if (wallc.sx1 > WindowRight || wallc.sx2 <= WindowLeft) return; // Sprite sorting should probably treat these as walls, not sprites, @@ -1070,8 +1070,8 @@ static void R_ProjectWallSprite(AActor *thing, fixed_t fx, fixed_t fy, fixed_t f gzb = fz + yscale * scaled_bo; vis = R_NewVisSprite(); - vis->x1 = wallc.SX1 < WindowLeft ? WindowLeft : wallc.SX1; - vis->x2 = wallc.SX2 >= WindowRight ? WindowRight-1 : wallc.SX2-1; + vis->x1 = wallc.sx1 < WindowLeft ? WindowLeft : wallc.sx1; + vis->x2 = wallc.sx2 >= WindowRight ? WindowRight-1 : wallc.sx2-1; vis->idepth = (unsigned)DivScale32(1, tz) >> 1; vis->depth = tz; vis->sector = thing->Sector; From 0aa67c68ab44ee79dbbad27765ae41e18d41256d Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 7 Aug 2014 17:23:06 -0500 Subject: [PATCH 30/54] Redo lighting for each wall sprite - Because previously it just reused whatever the most recently drawn wall used. --- src/r_things.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 72ebcf8c4..84ce18b64 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -409,7 +409,6 @@ void R_DrawWallSprite(vissprite_t *spr) { int x1, x2; fixed_t yscale; - int shade = LIGHT2SHADE(140); x1 = MAX(spr->x1, spr->wallc.sx1); x2 = MIN(spr->x2, spr->wallc.sx2 + 1); @@ -440,6 +439,10 @@ void R_DrawWallSprite(vissprite_t *spr) rereadcolormap = false; } + int shade = LIGHT2SHADE(spr->sector->lightlevel + r_actualextralight); + GlobVis = r_WallVisibility; + rw_lightleft = SafeDivScale12(GlobVis, spr->wallc.sz1); + rw_lightstep = (SafeDivScale12(GlobVis, spr->wallc.sz2) - rw_lightleft) / (spr->wallc.sx2 - spr->wallc.sx1); rw_light = rw_lightleft + (x1 - spr->wallc.sx1) * rw_lightstep; if (fixedlightlev >= 0) dc_colormap = usecolormap->Maps + fixedlightlev; From 6303935ad61bc360dae646ac052a784b1d68e782 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 7 Aug 2014 19:57:55 -0500 Subject: [PATCH 31/54] Use wall sprite Y scale --- src/r_things.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 84ce18b64..9a6bfee6f 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -416,8 +416,8 @@ void R_DrawWallSprite(vissprite_t *spr) return; WallT.InitFromWallCoords(&spr->wallc); PrepWall(swall, lwall, spr->pic->GetWidth() << FRACBITS, x1, x2); - dc_texturemid = spr->gzt - viewz; - yscale = FRACUNIT; + yscale = spr->yscale; + dc_texturemid = FixedDiv(spr->gzt - viewz, yscale); if (spr->renderflags & RF_XFLIP) { int right = (spr->pic->GetWidth() << FRACBITS) - 1; @@ -1075,6 +1075,7 @@ static void R_ProjectWallSprite(AActor *thing, fixed_t fx, fixed_t fy, fixed_t f vis = R_NewVisSprite(); vis->x1 = wallc.sx1 < WindowLeft ? WindowLeft : wallc.sx1; vis->x2 = wallc.sx2 >= WindowRight ? WindowRight-1 : wallc.sx2-1; + vis->yscale = yscale; vis->idepth = (unsigned)DivScale32(1, tz) >> 1; vis->depth = tz; vis->sector = thing->Sector; From 7b02027ba72879a95261d353f1155c0e8d33a823 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 7 Aug 2014 20:00:49 -0500 Subject: [PATCH 32/54] Fixed: Wall sprites cut off one pixel short of the window's right border --- src/r_things.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 9a6bfee6f..801d25bfb 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -411,7 +411,7 @@ void R_DrawWallSprite(vissprite_t *spr) fixed_t yscale; x1 = MAX(spr->x1, spr->wallc.sx1); - x2 = MIN(spr->x2, spr->wallc.sx2 + 1); + x2 = MIN(spr->x2 + 1, spr->wallc.sx2 + 1); if (x1 >= x2) return; WallT.InitFromWallCoords(&spr->wallc); @@ -1074,7 +1074,7 @@ static void R_ProjectWallSprite(AActor *thing, fixed_t fx, fixed_t fy, fixed_t f vis = R_NewVisSprite(); vis->x1 = wallc.sx1 < WindowLeft ? WindowLeft : wallc.sx1; - vis->x2 = wallc.sx2 >= WindowRight ? WindowRight-1 : wallc.sx2-1; + vis->x2 = wallc.sx2 >= WindowRight ? WindowRight : wallc.sx2-1; vis->yscale = yscale; vis->idepth = (unsigned)DivScale32(1, tz) >> 1; vis->depth = tz; From 9659b894a3663aceb640d61e6950e1ac7ef256b5 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 7 Aug 2014 20:43:09 -0500 Subject: [PATCH 33/54] Skip neardepth/fardepth checking in R_DrawSprite - Wall sprites now clip much, much better than before. --- src/r_things.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 801d25bfb..092e799dc 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2076,19 +2076,9 @@ void R_DrawSprite (vissprite_t *spr) r1 = MAX (ds->x1, x1); r2 = MIN (ds->x2, x2); - fixed_t neardepth, fardepth; - if (ds->sz1 < ds->sz2) - { - neardepth = ds->sz1, fardepth = ds->sz2; - } - else - { - neardepth = ds->sz2, fardepth = ds->sz1; - } - if (neardepth > spr->depth || (fardepth > spr->depth && - // Check if sprite is in front of draw seg: - DMulScale32(spr->gy - ds->curline->v1->y, ds->curline->v2->x - ds->curline->v1->x, - ds->curline->v1->x - spr->gx, ds->curline->v2->y - ds->curline->v1->y) <= 0)) + // Check if sprite is in front of draw seg: + if (DMulScale32(spr->gy - ds->curline->v1->y, ds->curline->v2->x - ds->curline->v1->x, + ds->curline->v1->x - spr->gx, ds->curline->v2->y - ds->curline->v1->y) <= 0) { // seg is behind sprite, so draw the mid texture if it has one if (ds->maskedtexturecol != -1 || ds->bFogBoundary) From e6a1d6b516eb45206e8a688de26dd70c357799ef Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 7 Aug 2014 22:00:02 -0500 Subject: [PATCH 34/54] Parse more info from Blood's map header --- src/p_buildmap.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index 32651b5bb..7e2f0b472 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -249,7 +249,7 @@ static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **mapthings, int * BYTE infoBlock[37]; int mapver = data[5]; DWORD matt; - int numRevisions, numWalls, numsprites, skyLen; + int numRevisions, numWalls, numsprites, skyLen, visibility, parallaxType; int i; int k; @@ -269,11 +269,14 @@ static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **mapthings, int * { memcpy (infoBlock, data + 6, 37); } + skyLen = 2 << LittleShort(*(WORD *)(infoBlock + 16)); + visibility = LittleLong(*(DWORD *)(infoBlock + 18)); + parallaxType = infoBlock[26]; numRevisions = LittleLong(*(DWORD *)(infoBlock + 27)); numsectors = LittleShort(*(WORD *)(infoBlock + 31)); numWalls = LittleShort(*(WORD *)(infoBlock + 33)); numsprites = LittleShort(*(WORD *)(infoBlock + 35)); - skyLen = 2 << LittleShort(*(WORD *)(infoBlock + 16)); + Printf("Visibility: %d\n", visibility); if (mapver == 7) { From fbb5689f298348003c5fbf90956656e1f946e30f Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 7 Aug 2014 22:26:24 -0500 Subject: [PATCH 35/54] Eliminate extra vars from FWallCoords - cx1, cx2, cy1, and cy2 are not used anywhere, so get rid of them. - Also annotated the comments to indicate the corresponding arrays in the Build engine. --- src/r_bsp.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/r_bsp.h b/src/r_bsp.h index 79dac6c88..1b5af9805 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -33,14 +33,11 @@ struct FWallCoords { - fixed_t tx1, tx2; // x coords at left, right of wall in view space - fixed_t ty1, ty2; // y coords at left, right of wall in view space + fixed_t tx1, tx2; // x coords at left, right of wall in view space rx1,rx2 + fixed_t ty1, ty2; // y coords at left, right of wall in view space ry1,ry2 - fixed_t cx1, cx2; // x coords at left, right of wall in camera space - fixed_t cy1, cy2; // y coords at left, right of wall in camera space - - short sx1, sx2; // x coords at left, right of wall in screen space - fixed_t sz1, sz2; // depth at left, right of wall in screen space + short sx1, sx2; // x coords at left, right of wall in screen space xb1,xb2 + fixed_t sz1, sz2; // depth at left, right of wall in screen space yb1,yb2 bool Init(int x1, int y1, int x2, int y2, int too_close); }; From 46592f5f6d3c72938911df920a9afb4391964a33 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 7 Aug 2014 22:27:48 -0500 Subject: [PATCH 36/54] Don't clamp SHADE2LIGHT - Light levels aren't stored in bytes anymore, so there's no reason to clamp it anymore when loading Build maps. --- src/p_buildmap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index 7e2f0b472..2ee2ae83a 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -20,8 +20,8 @@ // MACROS ------------------------------------------------------------------ -//#define SHADE2LIGHT(s) (clamp (160-2*(s), 0, 255)) -#define SHADE2LIGHT(s) (clamp (255-2*s, 0, 255)) +//#define SHADE2LIGHT(s) (160-2*(s)) +#define SHADE2LIGHT(s) (255-2*s) // TYPES ------------------------------------------------------------------- From fefe6aa2c105e38056cf35668bd51f5f5b4073be Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 7 Aug 2014 22:40:12 -0500 Subject: [PATCH 37/54] Specie -> Species - specie: money in the form of coins rather than notes - species: a group of living organisms consisting of similar individuals capable of exchanging genes or interbreeding --- src/p_map.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index 68c2c1530..4ea8762ec 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -3470,7 +3470,7 @@ struct Origin { AActor *Caller; bool hitGhosts; - bool hitSameSpecie; + bool hitSameSpecies; }; static ETraceStatus CheckForActor(FTraceResults &res, void *userdata) @@ -3488,7 +3488,7 @@ static ETraceStatus CheckForActor(FTraceResults &res, void *userdata) return TRACE_Skip; } - if (data->hitSameSpecie && res.Actor->GetSpecies() == data->Caller->GetSpecies()) + if (data->hitSameSpecies && res.Actor->GetSpecies() == data->Caller->GetSpecies()) { return TRACE_Skip; } @@ -3517,8 +3517,6 @@ AActor *P_LineAttack(AActor *t1, angle_t angle, fixed_t distance, TData.Caller = t1; angle_t srcangle = angle; int srcpitch = pitch; - bool hitGhosts; - bool hitSameSpecie; bool killPuff = false; AActor *puff = NULL; int pflag = 0; @@ -3566,7 +3564,7 @@ AActor *P_LineAttack(AActor *t1, angle_t angle, fixed_t distance, (t1->player->ReadyWeapon->flags2 & MF2_THRUGHOST)) || (puffDefaults && (puffDefaults->flags2 & MF2_THRUGHOST)); - TData.hitSameSpecie = (puffDefaults && (puffDefaults->flags6 & MF6_MTHRUSPECIES)); + TData.hitSameSpecies = (puffDefaults && (puffDefaults->flags6 & MF6_MTHRUSPECIES)); // if the puff uses a non-standard damage type, this will override default, hitscan and melee damage type. // All other explicitly passed damage types (currenty only MDK) will be preserved. From 1fcde912984c9a5628ca01737b24c9787153c1de Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 8 Aug 2014 09:25:35 +0200 Subject: [PATCH 38/54] - BlueShadow's GetArmorInfo submission. --- src/p_acs.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 2ca6fe909..1646ab7b7 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -120,6 +120,16 @@ FRandom pr_acs ("ACS"); #define SDF_ABSANGLE 1 #define SDF_PERMANENT 2 +// GetArmorInfo +enum +{ + ARMORINFO_CLASSNAME, + ARMORINFO_SAVEAMOUNT, + ARMORINFO_SAVEPERCENT, + ARMORINFO_MAXABSORB, + ARMORINFO_MAXFULLABSORB, +}; + struct CallReturn { CallReturn(int pc, ScriptFunction *func, FBehavior *module, SDWORD *locals, ACSLocalArrays *arrays, bool discard, unsigned int runaway) @@ -4349,6 +4359,7 @@ enum EACSFunctions ACSF_GetActorPowerupTics, ACSF_ChangeActorAngle, ACSF_ChangeActorPitch, // 80 + ACSF_GetArmorInfo, /* Zandronum's - these must be skipped when we reach 99! -100:ResetMap(0), @@ -4822,6 +4833,38 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args, const return 0; } + case ACSF_GetArmorInfo: + { + if (activator == NULL || activator->player == NULL) return 0; + + ABasicArmor * equippedarmor = (ABasicArmor *) activator->FindInventory(NAME_BasicArmor); + + if (equippedarmor && equippedarmor->Amount != 0) + { + switch(args[0]) + { + case ARMORINFO_CLASSNAME: + return GlobalACSStrings.AddString(equippedarmor->ArmorType.GetChars(), stack, stackdepth); + + case ARMORINFO_SAVEAMOUNT: + return equippedarmor->MaxAmount; + + case ARMORINFO_SAVEPERCENT: + return equippedarmor->SavePercent; + + case ARMORINFO_MAXABSORB: + return equippedarmor->MaxAbsorb; + + case ARMORINFO_MAXFULLABSORB: + return equippedarmor->MaxFullAbsorb; + + default: + return 0; + } + } + return args[0] == ARMORINFO_CLASSNAME ? GlobalACSStrings.AddString("None", stack, stackdepth) : 0; + } + case ACSF_SpawnSpotForced: return DoSpawnSpot(args[0], args[1], args[2], args[3], true); From 259466c3d462f55a7f8b07abfe850c619d0076ab Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 11 Aug 2014 09:39:38 +0200 Subject: [PATCH 39/54] fixed time printing. - In ZDoom the timer runs a bit too fast because roundoff errors make 35 tics only last 0.98 seconds. None of the internal timing has been changed, only the places where a time value is printed it will get adjusted for this discrepancy. --- src/cmdlib.h | 21 +++++++++++++++++++++ src/g_shared/sbarinfo_commands.cpp | 5 ++++- src/g_shared/shared_hud.cpp | 8 ++++---- src/g_shared/shared_sbar.cpp | 4 ++-- src/g_strife/strife_sbar.cpp | 20 ++++++++++++-------- src/statistics.cpp | 4 ++-- src/wi_stuff.cpp | 20 +++++++++++--------- 7 files changed, 56 insertions(+), 26 deletions(-) diff --git a/src/cmdlib.h b/src/cmdlib.h index e3a9d3d08..66747415a 100644 --- a/src/cmdlib.h +++ b/src/cmdlib.h @@ -62,4 +62,25 @@ struct FFileList void ScanDirectory(TArray &list, const char *dirpath); + +//========================================================================== +// +// Functions to compensate for a tic being a bit short. +// Since ZDoom uses a milliseconds timer for game timing +// 35 tics are actually only 0.98 seconds. +// For real time display this needs to be adjusted +// +//========================================================================== + +inline int AdjustTics(int tics) +{ + return (tics * 98) / 100; +} + +inline int Tics2Seconds(int tics) +{ + return (tics * 98) / (100 * TICRATE); +} + + #endif diff --git a/src/g_shared/sbarinfo_commands.cpp b/src/g_shared/sbarinfo_commands.cpp index 629c31cb4..c9011e851 100644 --- a/src/g_shared/sbarinfo_commands.cpp +++ b/src/g_shared/sbarinfo_commands.cpp @@ -886,8 +886,11 @@ class CommandDrawString : public SBarInfoCommand } break; case TIME: - str.Format("%02d:%02d:%02d", (level.time/TICRATE)/3600, ((level.time/TICRATE)%3600)/60, (level.time/TICRATE)%60); + { + int sec = Tics2Seconds(level.time); + str.Format("%02d:%02d:%02d", sec / 3600, (sec % 3600) / 60, sec % 60); break; + } case LOGTEXT: str = statusBar->CPlayer->LogText; break; diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index 3806e5f9d..2daeff7a8 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -867,7 +867,7 @@ static void DrawTime() : (hud_showtime < 6 ? level.time : level.totaltime); - const int timeSeconds = timeTicks / TICRATE; + const int timeSeconds = Tics2Seconds(timeTicks); hours = timeSeconds / 3600; minutes = (timeSeconds % 3600) / 60; @@ -994,7 +994,7 @@ void DrawHUD() if (am_showtotaltime) { - seconds = level.totaltime / TICRATE; + seconds = Tics2Seconds(level.totaltime); mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60); DrawHudText(SmallFont, hudcolor_ttim, printstr, hudwidth-length, bottom, FRACUNIT); bottom -= fonth; @@ -1004,14 +1004,14 @@ void DrawHUD() { if (level.clusterflags&CLUSTER_HUB) { - seconds = level.time /TICRATE; + seconds = Tics2Seconds(level.time); mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60); DrawHudText(SmallFont, hudcolor_time, printstr, hudwidth-length, bottom, FRACUNIT); bottom -= fonth; } // Single level time for hubs - seconds= level.maptime /TICRATE; + seconds= Tics2Seconds(level.maptime); mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60); DrawHudText(SmallFont, hudcolor_ltim, printstr, hudwidth-length, bottom, FRACUNIT); } diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index 6b2f609b7..89921e3a2 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -1306,8 +1306,8 @@ void DBaseStatusBar::Draw (EHudState state) } else if (automapactive) { - int y, time = level.time / TICRATE, height; - int totaltime = level.totaltime / TICRATE; + int y, time = Tics2Seconds(level.time), height; + int totaltime = Tics2Seconds(level.totaltime); EColorRange highlight = (gameinfo.gametype & GAME_DoomChex) ? CR_UNTRANSLATED : CR_YELLOW; diff --git a/src/g_strife/strife_sbar.cpp b/src/g_strife/strife_sbar.cpp index 1a355b90a..89659e61d 100644 --- a/src/g_strife/strife_sbar.cpp +++ b/src/g_strife/strife_sbar.cpp @@ -586,29 +586,33 @@ private: screen->DrawTexture (Images[back], left, top, DTA_CleanNoMove, true, DTA_Alpha, FRACUNIT*3/4, TAG_DONE); screen->DrawTexture (Images[bars], left, top, DTA_CleanNoMove, true, TAG_DONE); + switch (CurrentPop) { case POP_Log: + { + int seconds = Tics2Seconds(level.time); // Draw the latest log message. - mysnprintf (buff, countof(buff), "%02d:%02d:%02d", - (level.time/TICRATE)/3600, - ((level.time/TICRATE)%3600)/60, - (level.time/TICRATE)%60); + mysnprintf(buff, countof(buff), "%02d:%02d:%02d", + seconds / 3600, + (seconds % 3600) / 60, + (seconds) % 60); - screen->DrawText (SmallFont2, CR_UNTRANSLATED, left+210*xscale, top+8*yscale, buff, + screen->DrawText(SmallFont2, CR_UNTRANSLATED, left + 210 * xscale, top + 8 * yscale, buff, DTA_CleanNoMove, true, TAG_DONE); if (CPlayer->LogText != NULL) { - FBrokenLines *lines = V_BreakLines (SmallFont2, 272, CPlayer->LogText); + FBrokenLines *lines = V_BreakLines(SmallFont2, 272, CPlayer->LogText); for (i = 0; lines[i].Width >= 0; ++i) { - screen->DrawText (SmallFont2, CR_UNTRANSLATED, left+24*xscale, top+(18+i*12)*yscale, + screen->DrawText(SmallFont2, CR_UNTRANSLATED, left + 24 * xscale, top + (18 + i * 12)*yscale, lines[i].Text, DTA_CleanNoMove, true, TAG_DONE); } - V_FreeBrokenLines (lines); + V_FreeBrokenLines(lines); } break; + } case POP_Keys: // List the keys the player has. diff --git a/src/statistics.cpp b/src/statistics.cpp index acd8440e8..7ed6e7f8e 100644 --- a/src/statistics.cpp +++ b/src/statistics.cpp @@ -420,7 +420,7 @@ static void StoreLevelStats() LevelData[i].killcount = level.killed_monsters; LevelData[i].totalsecrets = level.total_secrets; LevelData[i].secretcount = level.found_secrets; - LevelData[i].leveltime = level.maptime; + LevelData[i].leveltime = AdjustTics(level.maptime); // Check for living monsters. On some maps it can happen // that the counter misses some. @@ -490,7 +490,7 @@ void STAT_ChangeLevel(const char *newl) } infostring.Format("%4d/%4d, %3d/%3d, %2d", statvals[0], statvals[1], statvals[2], statvals[3], validlevels); - FSessionStatistics *es = StatisticsEntry(sl, infostring, level.totaltime); + FSessionStatistics *es = StatisticsEntry(sl, infostring, AdjustTics(level.totaltime)); for(unsigned i = 0; i < LevelData.Size(); i++) { diff --git a/src/wi_stuff.cpp b/src/wi_stuff.cpp index e60fee303..2ab93f090 100644 --- a/src/wi_stuff.cpp +++ b/src/wi_stuff.cpp @@ -1460,7 +1460,7 @@ void WI_drawDeathmatchStats () // Draw game time y += height + CleanYfac; - int seconds = plrs[me].stime / TICRATE; + int seconds = Tics2Seconds(plrs[me].stime); int hours = seconds / 3600; int minutes = (seconds % 3600) / 60; seconds = seconds % 60; @@ -1817,9 +1817,9 @@ void WI_updateStats () cnt_kills[0] = plrs[me].skills; cnt_items[0] = plrs[me].sitems; cnt_secret[0] = plrs[me].ssecret; - cnt_time = plrs[me].stime / TICRATE; + cnt_time = Tics2Seconds(plrs[me].stime); cnt_par = wbs->partime / TICRATE; - cnt_total_time = wbs->totaltime / TICRATE; + cnt_total_time = Tics2Seconds(wbs->totaltime); } if (sp_state == 2) @@ -1882,19 +1882,21 @@ void WI_updateStats () cnt_total_time += 3; } - if (!gameinfo.intermissioncounter || cnt_time >= plrs[me].stime / TICRATE) - cnt_time = plrs[me].stime / TICRATE; + int sec = Tics2Seconds(plrs[me].stime); + if (!gameinfo.intermissioncounter || cnt_time >= sec) + cnt_time = sec; - if (!gameinfo.intermissioncounter || cnt_total_time >= wbs->totaltime / TICRATE) - cnt_total_time = wbs->totaltime / TICRATE; + int tsec = Tics2Seconds(wbs->totaltime); + if (!gameinfo.intermissioncounter || cnt_total_time >= tsec) + cnt_total_time = tsec; if (!gameinfo.intermissioncounter || cnt_par >= wbs->partime / TICRATE) { cnt_par = wbs->partime / TICRATE; - if (cnt_time >= plrs[me].stime / TICRATE) + if (cnt_time >= sec) { - cnt_total_time = wbs->totaltime / TICRATE; + cnt_total_time = tsec; S_Sound (CHAN_VOICE | CHAN_UI, "intermission/nextstage", 1, ATTN_NONE); sp_state++; } From f0eccb9d1541ea1fefcc82cdd02a0b7b2dc73fbe Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 11 Aug 2014 10:08:49 +0200 Subject: [PATCH 40/54] - BlueShadow's submission for keeping the max save amount of BasicArmorPickups around when picking up armor bonuses. --- src/g_shared/a_armor.cpp | 8 ++++++++ src/g_shared/a_pickups.h | 1 + src/p_acs.cpp | 4 ++++ src/version.h | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/g_shared/a_armor.cpp b/src/g_shared/a_armor.cpp index 6b90a6a78..a745197c2 100644 --- a/src/g_shared/a_armor.cpp +++ b/src/g_shared/a_armor.cpp @@ -25,6 +25,11 @@ void ABasicArmor::Serialize (FArchive &arc) { Super::Serialize (arc); arc << SavePercent << BonusCount << MaxAbsorb << MaxFullAbsorb << AbsorbCount << ArmorType; + + if (SaveVersion >= 4511) + { + arc << ActualSaveAmount; + } } //=========================================================================== @@ -69,6 +74,7 @@ AInventory *ABasicArmor::CreateCopy (AActor *other) copy->Icon = Icon; copy->BonusCount = BonusCount; copy->ArmorType = ArmorType; + copy->ActualSaveAmount = ActualSaveAmount; GoAwayAndDie (); return copy; } @@ -268,6 +274,7 @@ bool ABasicArmorPickup::Use (bool pickup) armor->MaxAbsorb = MaxAbsorb; armor->MaxFullAbsorb = MaxFullAbsorb; armor->ArmorType = this->GetClass()->TypeName; + armor->ActualSaveAmount = SaveAmount; return true; } @@ -360,6 +367,7 @@ bool ABasicArmorBonus::Use (bool pickup) armor->MaxAbsorb = MaxAbsorb; armor->ArmorType = this->GetClass()->TypeName; armor->MaxFullAbsorb = MaxFullAbsorb; + armor->ActualSaveAmount = MaxSaveAmount; } armor->Amount = MIN(armor->Amount + saveAmount, MaxSaveAmount + armor->BonusCount); diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index 22d1e009f..72548776a 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -423,6 +423,7 @@ public: int MaxFullAbsorb; int BonusCount; FNameNoInit ArmorType; + int ActualSaveAmount; }; // BasicArmorPickup replaces the armor you have. diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 1646ab7b7..e0967d400 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -128,6 +128,7 @@ enum ARMORINFO_SAVEPERCENT, ARMORINFO_MAXABSORB, ARMORINFO_MAXFULLABSORB, + ARMORINFO_ACTUALSAVEAMOUNT, }; struct CallReturn @@ -4858,6 +4859,9 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args, const case ARMORINFO_MAXFULLABSORB: return equippedarmor->MaxFullAbsorb; + case ARMORINFO_ACTUALSAVEAMOUNT: + return equippedarmor->ActualSaveAmount; + default: return 0; } diff --git a/src/version.h b/src/version.h index 6d24c3fe8..af376938c 100644 --- a/src/version.h +++ b/src/version.h @@ -76,7 +76,7 @@ const char *GetVersionString(); // Use 4500 as the base git save version, since it's higher than the // SVN revision ever got. -#define SAVEVER 4510 +#define SAVEVER 4511 #define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) From 48163de8e2485116e3007cdb0245bc975e8eed80 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 11 Aug 2014 11:47:14 +0200 Subject: [PATCH 41/54] must include doomdef.h in cmdlib.h to get TICRATE. --- src/cmdlib.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cmdlib.h b/src/cmdlib.h index 66747415a..f6f0e6ad8 100644 --- a/src/cmdlib.h +++ b/src/cmdlib.h @@ -5,6 +5,7 @@ #include "doomtype.h" +#include "doomdef.h" #include #include From f482dc094df50a6bf4ae5608dbb564a18bc864fd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 11 Aug 2014 12:27:04 +0200 Subject: [PATCH 42/54] fixed: R_PointOnSideSlow had precision issues with very short lines. When this function was originally written there was no possibility of fractional vertex coordinates so it threw away the fractional parts of the node's directional vector (which in the original nodes was always 0.) Now, with UDMF and high precision vertices this no longer works and the loss of significant parts of their value caused this code to produce erroneous results if the linedefs were only a few map units long and using fractional positions. --- src/p_maputl.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 17fc97d2f..3a4a4c6a0 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -434,8 +434,8 @@ static int R_PointOnSideSlow (fixed_t x, fixed_t y, node_t *node) // add on a 386/486, but it certainly isn't on anything newer than that. fixed_t dx; fixed_t dy; - fixed_t left; - fixed_t right; + double left; + double right; if (!node->dx) { @@ -466,8 +466,9 @@ static int R_PointOnSideSlow (fixed_t x, fixed_t y, node_t *node) return 0; } - left = FixedMul ( node->dy>>FRACBITS , dx ); - right = FixedMul ( dy , node->dx>>FRACBITS ); + // we must use doubles here because the fixed point code will produce errors due to loss of precision for extremely short linedefs. + left = (double)node->dy * (double)dx; + right = (double)dy * (double)node->dx; if (right < left) { From b461000795f3c52beed13f90498c2cf80d1a839e Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 13 Aug 2014 22:46:08 +0300 Subject: [PATCH 43/54] Fixed crash on opening 7z/LZMA archives, x64 only With Position Independent Code (PIC) enabled on x64, non-MSVC compilers use wrong inline assembly for cpuid --- lzma/C/CpuArch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lzma/C/CpuArch.c b/lzma/C/CpuArch.c index 425d18923..d6ab3f7f8 100644 --- a/lzma/C/CpuArch.c +++ b/lzma/C/CpuArch.c @@ -70,9 +70,9 @@ static void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d) *c = c2; *d = d2; - #elif __PIC__ + #elif defined __PIC__ && defined __i386__ - /* GCC or Clang WITH position-independent code generation */ + /* GCC or Clang WITH position-independent code generation, i386 only */ __asm__ __volatile__ ( "xchgl %%ebx, %1\n" @@ -86,7 +86,7 @@ static void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d) #else - /* GCC or Clang WITHOUT position-independent code generation */ + /* GCC or Clang WITHOUT position-independent code generation, or x86_64 */ __asm__ __volatile__ ( "cpuid" From 07d7f690e8bb83f87e48d30f2842ec7b28d795db Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Thu, 21 Aug 2014 20:01:05 +1200 Subject: [PATCH 44/54] Non-wall sprites need their original depth checks --- src/r_things.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 092e799dc..c0475ee75 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2076,9 +2076,22 @@ void R_DrawSprite (vissprite_t *spr) r1 = MAX (ds->x1, x1); r2 = MIN (ds->x2, x2); + fixed_t neardepth, fardepth; + if (!spr->bWallSprite) + { + if (ds->sz1 < ds->sz2) + { + neardepth = ds->sz1, fardepth = ds->sz2; + } + else + { + neardepth = ds->sz2, fardepth = ds->sz1; + } + } // Check if sprite is in front of draw seg: - if (DMulScale32(spr->gy - ds->curline->v1->y, ds->curline->v2->x - ds->curline->v1->x, - ds->curline->v1->x - spr->gx, ds->curline->v2->y - ds->curline->v1->y) <= 0) + if ((!spr->bWallSprite && neardepth > spr->depth) || ((spr->bWallSprite || fardepth > spr->depth) && + DMulScale32(spr->gy - ds->curline->v1->y, ds->curline->v2->x - ds->curline->v1->x, + ds->curline->v1->x - spr->gx, ds->curline->v2->y - ds->curline->v1->y) <= 0)) { // seg is behind sprite, so draw the mid texture if it has one if (ds->maskedtexturecol != -1 || ds->bFogBoundary) From df0d3543a85076168fa73b26486ac9a105e69a7d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 21 Aug 2014 13:01:12 +0200 Subject: [PATCH 45/54] - fixed: *ALL* original ceiling crushers, not just type 49, require a distance of 8 to the floor for the destination height. For the silent types this required a new action special, Ceiling_CrushAndRaiseSilentDist. This change only affects the XLAT mapping, the Hexen format types behave as before. - removed the redundant internal ceilCrushAndRaiseDist ceiling movement type. It was precisely the same as ceilCrushAndRaise in all details. --- src/actionspecials.h | 1 + src/cmdlib.h | 5 +++-- src/p_ceiling.cpp | 8 ++------ src/p_lnspec.cpp | 10 ++++++++-- src/p_spec.h | 1 - wadsrc/static/xlat/base.txt | 22 +++++++++++----------- wadsrc/static/xlat/strife.txt | 10 +++++----- 7 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/actionspecials.h b/src/actionspecials.h index 1377def82..752ef77eb 100644 --- a/src/actionspecials.h +++ b/src/actionspecials.h @@ -102,6 +102,7 @@ DEFINE_SPECIAL(Scroll_Texture_Left, 100, -1, -1, 2) DEFINE_SPECIAL(Scroll_Texture_Right, 101, -1, -1, 2) DEFINE_SPECIAL(Scroll_Texture_Up, 102, -1, -1, 2) DEFINE_SPECIAL(Scroll_Texture_Down, 103, -1, -1, 2) +DEFINE_SPECIAL(Ceiling_CrushAndRaiseSilentDist, 104, 3, 5, 5) DEFINE_SPECIAL(Light_ForceLightning, 109, 1, 1, 1) DEFINE_SPECIAL(Light_RaiseByValue, 110, 2, 2, 2) diff --git a/src/cmdlib.h b/src/cmdlib.h index f6f0e6ad8..6df893580 100644 --- a/src/cmdlib.h +++ b/src/cmdlib.h @@ -6,6 +6,7 @@ #include "doomtype.h" #include "doomdef.h" +#include "m_fixed.h" #include #include @@ -75,12 +76,12 @@ void ScanDirectory(TArray &list, const char *dirpath); inline int AdjustTics(int tics) { - return (tics * 98) / 100; + return Scale(tics, 98, 100); } inline int Tics2Seconds(int tics) { - return (tics * 98) / (100 * TICRATE); + return Scale(tics, 98, (100 * TICRATE)); } diff --git a/src/p_ceiling.cpp b/src/p_ceiling.cpp index 426bdf507..d0c54761a 100644 --- a/src/p_ceiling.cpp +++ b/src/p_ceiling.cpp @@ -133,7 +133,6 @@ void DCeiling::Tick () switch (m_Type) { case ceilCrushAndRaise: - case ceilCrushAndRaiseDist: m_Direction = -1; m_Speed = m_Speed1; if (!SN_IsMakingLoopingSound (m_Sector)) @@ -165,7 +164,6 @@ void DCeiling::Tick () switch (m_Type) { case ceilCrushAndRaise: - case ceilCrushAndRaiseDist: case ceilCrushRaiseAndStay: m_Speed = m_Speed2; m_Direction = 1; @@ -195,7 +193,6 @@ void DCeiling::Tick () switch (m_Type) { case ceilCrushAndRaise: - case ceilCrushAndRaiseDist: case ceilLowerAndCrush: case ceilLowerAndCrushDist: if (m_Speed1 == FRACUNIT && m_Speed2 == FRACUNIT) @@ -257,7 +254,6 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line, switch (type) { case ceilCrushAndRaise: - case ceilCrushAndRaiseDist: case ceilCrushRaiseAndStay: ceiling->m_TopHeight = sec->ceilingplane.d; case ceilLowerAndCrush: @@ -267,7 +263,7 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line, { targheight += 8*FRACUNIT; } - else if (type == ceilLowerAndCrushDist || type == ceilCrushAndRaiseDist) + else if (type == ceilCrushAndRaise) { targheight += height; } @@ -509,7 +505,7 @@ bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line, // Reactivate in-stasis ceilings...for certain types. // This restarts a crusher after it has been stopped - if (type == DCeiling::ceilCrushAndRaise || type == DCeiling::ceilCrushAndRaiseDist) + if (type == DCeiling::ceilCrushAndRaise) { P_ActivateInStasisCeiling (tag); } diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 7cb5ca7e6..14bcd430c 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -641,7 +641,7 @@ FUNC(LS_Ceiling_CrushAndRaiseA) FUNC(LS_Ceiling_CrushAndRaiseDist) // Ceiling_CrushAndRaiseDist (tag, dist, speed, damage, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushAndRaiseDist, ln, arg0, SPEED(arg2), SPEED(arg2), arg1*FRACUNIT, arg3, 0, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg2), SPEED(arg2), arg1*FRACUNIT, arg3, 0, 0, CRUSHTYPE(arg4)); } FUNC(LS_Ceiling_CrushAndRaiseSilentA) @@ -650,6 +650,12 @@ FUNC(LS_Ceiling_CrushAndRaiseSilentA) return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 1, 0, CRUSHTYPE(arg4)); } +FUNC(LS_Ceiling_CrushAndRaiseSilentDist) +// Ceiling_CrushAndRaiseSilentDist (tag, dist, upspeed, damage, crushtype) +{ + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg2), SPEED(arg2), arg1*FRACUNIT, arg3, 1, 0, CRUSHTYPE(arg4)); +} + FUNC(LS_Ceiling_RaiseToNearest) // Ceiling_RaiseToNearest (tag, speed) { @@ -3261,7 +3267,7 @@ lnSpecFunc LineSpecials[256] = /* 101 */ LS_NOP, // Scroll_Texture_Right /* 102 */ LS_NOP, // Scroll_Texture_Up /* 103 */ LS_NOP, // Scroll_Texture_Down - /* 104 */ LS_NOP, + /* 104 */ LS_Ceiling_CrushAndRaiseSilentDist, /* 105 */ LS_NOP, /* 106 */ LS_NOP, /* 107 */ LS_NOP, diff --git a/src/p_spec.h b/src/p_spec.h index dc0eb3646..c9bb6eded 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -628,7 +628,6 @@ public: ceilLowerInstant, ceilRaiseInstant, ceilCrushAndRaise, - ceilCrushAndRaiseDist, ceilLowerAndCrush, ceilLowerAndCrushDist, ceilCrushRaiseAndStay, diff --git a/wadsrc/static/xlat/base.txt b/wadsrc/static/xlat/base.txt index 11b9fd315..856e7a505 100644 --- a/wadsrc/static/xlat/base.txt +++ b/wadsrc/static/xlat/base.txt @@ -5,7 +5,7 @@ include "xlat/defines.i" 3 = WALK, Door_Close (tag, D_SLOW) 4 = WALK|MONST, Door_Raise (tag, D_SLOW, VDOORWAIT) 5 = WALK, Floor_RaiseToLowestCeiling (tag, F_SLOW) - 6 = WALK, Ceiling_CrushAndRaiseA (tag, C_NORMAL, C_NORMAL, 10) + 6 = WALK, Ceiling_CrushAndRaiseDist (tag, 8, C_NORMAL, 10) 7 = USE, Stairs_BuildUpDoom (tag, ST_SLOW, 8) 8 = WALK, Stairs_BuildUpDoom (tag, ST_SLOW, 8) 9 = USE, Floor_Donut (tag, DORATE, DORATE) @@ -24,7 +24,7 @@ include "xlat/defines.i" 22 = WALK, Plat_RaiseAndStayTx0 (tag, P_SLOW/2) 23 = USE, Floor_LowerToLowest (tag, F_SLOW) 24 = SHOOT, Floor_RaiseToLowestCeiling (tag, F_SLOW) - 25 = WALK, Ceiling_CrushAndRaiseA (tag, C_SLOW, C_SLOW, 10) + 25 = WALK, Ceiling_CrushAndRaiseDist (tag, C_SLOW, C_SLOW, 10) 26 = USE|REP, Door_LockedRaise (0, D_SLOW, VDOORWAIT, BCard | CardIsSkull, tag) 27 = USE|REP, Door_LockedRaise (0, D_SLOW, VDOORWAIT, YCard | CardIsSkull, tag) 28 = USE|REP, Door_LockedRaise (0, D_SLOW, VDOORWAIT, RCard | CardIsSkull, tag) @@ -72,11 +72,11 @@ include "xlat/defines.i" 70 = USE|REP, Floor_LowerToHighest (tag, F_FAST, 136) 71 = USE, Floor_LowerToHighest (tag, F_FAST, 136) 72 = WALK|REP, Ceiling_LowerAndCrush (tag, C_SLOW, 0, 2) - 73 = WALK|REP, Ceiling_CrushAndRaiseA (tag, C_SLOW, C_SLOW, 10) + 73 = WALK|REP, Ceiling_CrushAndRaiseDist (tag, 8, C_SLOW, 10) 74 = WALK|REP, Ceiling_CrushStop (tag) 75 = WALK|REP, Door_Close (tag, D_SLOW) 76 = WALK|REP, Door_CloseWaitOpen (tag, D_SLOW, 240) - 77 = WALK|REP, Ceiling_CrushAndRaiseA (tag, C_NORMAL, C_NORMAL, 10) + 77 = WALK|REP, Ceiling_CrushAndRaiseDist (tag, 8, C_NORMAL, 10) 78 = USE|REP, Floor_TransferNumeric (tag) // <- BOOM special 79 = WALK|REP, Light_ChangeToValue (tag, 35) 80 = WALK|REP, Light_MaxNeighbor (tag) @@ -140,7 +140,7 @@ include "xlat/defines.i" 138 = USE|REP, Light_ChangeToValue (tag, 255) 139 = USE|REP, Light_ChangeToValue (tag, 35) 140 = USE, Floor_RaiseByValueTimes8 (tag, F_SLOW, 64) -141 = WALK, Ceiling_CrushAndRaiseSilentA (tag, C_SLOW, C_SLOW, 10) +141 = WALK, Ceiling_CrushAndRaiseSilentDist (tag, 8, C_SLOW, 10) /****** The following are all new to BOOM ******/ @@ -152,7 +152,7 @@ include "xlat/defines.i" 147 = WALK|REP, Floor_RaiseByValueTimes8 (tag, F_SLOW, 64) 148 = WALK|REP, Plat_UpByValueStayTx (tag, P_SLOW/2, 3) 149 = WALK|REP, Plat_UpByValueStayTx (tag, P_SLOW/2, 4) -150 = WALK|REP, Ceiling_CrushAndRaiseSilentA (tag, C_SLOW, C_SLOW, 10) +150 = WALK|REP, Ceiling_CrushAndRaiseSilentDist (tag, 8, C_SLOW, 10) 151 = WALK|REP, FloorAndCeiling_LowerRaise (tag, F_SLOW, C_SLOW) 152 = WALK|REP, Ceiling_LowerToFloor (tag, C_SLOW) 153 = WALK, Floor_TransferTrigger (tag) @@ -166,8 +166,8 @@ include "xlat/defines.i" 161 = USE, Floor_RaiseByValue (tag, F_SLOW, 24) 162 = USE, Plat_PerpetualRaiseLip (tag, P_SLOW, PLATWAIT, 0) 163 = USE, Plat_Stop (tag) -164 = USE, Ceiling_CrushAndRaiseA (tag, C_NORMAL, C_NORMAL, 10) -165 = USE, Ceiling_CrushAndRaiseSilentA (tag, C_SLOW, C_SLOW, 10) +164 = USE, Ceiling_CrushAndRaiseDist (tag, 8, C_NORMAL, 10) +165 = USE, Ceiling_CrushAndRaiseSilentDist (tag, 8, C_SLOW, 10) 166 = USE, FloorAndCeiling_LowerRaise (tag, F_SLOW, C_SLOW, 1998) 167 = USE, Ceiling_LowerAndCrush (tag, C_SLOW, 0, 2) 168 = USE, Ceiling_CrushStop (tag) @@ -185,9 +185,9 @@ include "xlat/defines.i" 180 = USE|REP, Floor_RaiseByValue (tag, F_SLOW, 24) 181 = USE|REP, Plat_PerpetualRaiseLip (tag, P_SLOW, PLATWAIT, 0) 182 = USE|REP, Plat_Stop (tag) -183 = USE|REP, Ceiling_CrushAndRaiseA (tag, C_NORMAL, C_NORMAL, 10) -184 = USE|REP, Ceiling_CrushAndRaiseA (tag, C_SLOW, C_SLOW, 10) -185 = USE|REP, Ceiling_CrushAndRaiseSilentA (tag, C_SLOW, C_SLOW, 10) +183 = USE|REP, Ceiling_CrushAndRaiseDist (tag, 8, C_NORMAL, 10) +184 = USE|REP, Ceiling_CrushAndRaiseDist (tag, 8, C_SLOW, 10) +185 = USE|REP, Ceiling_CrushAndRaiseSilentDist (tag, 8, C_SLOW, 10) 186 = USE|REP, FloorAndCeiling_LowerRaise (tag, F_SLOW, C_SLOW, 1998) 187 = USE|REP, Ceiling_LowerAndCrush (tag, C_SLOW, 0, 2) 188 = USE|REP, Ceiling_CrushStop (tag) diff --git a/wadsrc/static/xlat/strife.txt b/wadsrc/static/xlat/strife.txt index 159933c80..755ace5ad 100644 --- a/wadsrc/static/xlat/strife.txt +++ b/wadsrc/static/xlat/strife.txt @@ -90,7 +90,7 @@ RetailOnly = 121 3 = WALK, Door_Close (tag, D_SLOW) 4 = WALK|MONST, Door_Raise (tag, D_SLOW, VDOORWAIT) 5 = WALK, Floor_RaiseToLowestCeiling (tag, F_SLOW) - 6 = WALK, Ceiling_CrushAndRaiseA (tag, C_FAST, C_FAST, 10) + 6 = WALK, Ceiling_CrushAndRaiseDist (tag, 8, C_FAST, 10) 8 = WALK, Stairs_BuildUpDoom (tag, ST_SLOW, 8) 10 = WALK|MONST, Plat_DownWaitUpStayLip (tag, P_FAST, PLATWAIT, 0) 12 = WALK, Light_MaxNeighbor (tag) @@ -99,7 +99,7 @@ RetailOnly = 121 17 = WALK, Light_StrobeDoom (tag, 5, 35) 19 = WALK, Floor_LowerToHighest (tag, F_SLOW, 128) 22 = WALK, Plat_RaiseAndStayTx0 (tag, P_SLOW/2) - 25 = WALK, Ceiling_CrushAndRaiseA (tag, C_SLOW, C_SLOW, 0) + 25 = WALK, Ceiling_CrushAndRaiseDist (tag, 8, C_SLOW, 0) 30 = WALK, Floor_RaiseByTexture (tag, F_SLOW) 35 = WALK, Light_ChangeToValue (tag, 35) 36 = WALK, Floor_LowerToHighest (tag, F_FAST, 128) @@ -128,7 +128,7 @@ RetailOnly = 121 124 = WALK, Teleport_EndGame () 125 = MONWALK, Teleport (0, tag) 130 = WALK, Floor_RaiseToNearest (tag, F_FAST) -141 = WALK, Ceiling_CrushAndRaiseSilentA (tag, C_SLOW, C_SLOW, 0) +141 = WALK, Ceiling_CrushAndRaiseSilentDist (tag, 8, C_SLOW, 10) 174 = WALK, ACS_ExecuteAlways (0, 0, 174, tag) 183 = WALK, ACS_ExecuteAlways (0, 0, 183, tag) 178 = WALK, Generic_Stairs (tag, ST_FAST, 16, 0, 0) @@ -146,11 +146,11 @@ RetailOnly = 121 216 = WALK|REP, ACS_ExecuteAlways (0, 0, 216, tag) 90 = WALK|REP, Door_Raise (tag, D_SLOW, VDOORWAIT) 72 = WALK|REP, Ceiling_LowerAndCrushDist (tag, C_SLOW, 10) - 73 = WALK|REP, Ceiling_CrushAndRaiseA (tag, C_SLOW, C_SLOW, 0) + 73 = WALK|REP, Ceiling_CrushAndRaiseDist (tag, 8, C_SLOW, 0) 74 = WALK|REP, Ceiling_CrushStop (tag) 75 = WALK|REP, Door_Close (tag, D_SLOW) 76 = WALK|REP, Door_CloseWaitOpen (tag, D_SLOW, 240) - 77 = WALK|REP, Ceiling_CrushAndRaiseA (tag, C_FAST, C_FAST, 10) + 77 = WALK|REP, Ceiling_CrushAndRaiseDist (tag, 8, C_FAST, 10) 79 = WALK|REP, Light_ChangeToValue (tag, 35) 80 = WALK|REP, Light_MaxNeighbor (tag) 81 = WALK|REP, Light_ChangeToValue (tag, 255) From eebd5c9d4da705d6fed48cafd21b38a90c54ac7b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 21 Aug 2014 13:38:47 +0200 Subject: [PATCH 46/54] - fixed bad edit in linedef translation. --- wadsrc/static/xlat/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/xlat/base.txt b/wadsrc/static/xlat/base.txt index 856e7a505..9607841d5 100644 --- a/wadsrc/static/xlat/base.txt +++ b/wadsrc/static/xlat/base.txt @@ -24,7 +24,7 @@ include "xlat/defines.i" 22 = WALK, Plat_RaiseAndStayTx0 (tag, P_SLOW/2) 23 = USE, Floor_LowerToLowest (tag, F_SLOW) 24 = SHOOT, Floor_RaiseToLowestCeiling (tag, F_SLOW) - 25 = WALK, Ceiling_CrushAndRaiseDist (tag, C_SLOW, C_SLOW, 10) + 25 = WALK, Ceiling_CrushAndRaiseDist (tag, 8, C_SLOW, 10) 26 = USE|REP, Door_LockedRaise (0, D_SLOW, VDOORWAIT, BCard | CardIsSkull, tag) 27 = USE|REP, Door_LockedRaise (0, D_SLOW, VDOORWAIT, YCard | CardIsSkull, tag) 28 = USE|REP, Door_LockedRaise (0, D_SLOW, VDOORWAIT, RCard | CardIsSkull, tag) From 5364116354303317922427a8f12764b0846c49ca Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 23 Aug 2014 13:24:15 +0200 Subject: [PATCH 47/54] - fixed: APROP_Friendly did not manage monster counting correctly. --- src/p_acs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index e0967d400..235a47933 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -3747,16 +3747,16 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value) break; case APROP_Friendly: + if (actor->CountsAsKill()) level.total_monsters--; if (value) { - if (actor->CountsAsKill()) level.total_monsters--; actor->flags |= MF_FRIENDLY; } else { actor->flags &= ~MF_FRIENDLY; - if (actor->CountsAsKill()) level.total_monsters++; } + if (actor->CountsAsKill()) level.total_monsters++; break; From 51d7340288e477d8f44af7992ec2fee439105f6e Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 23 Aug 2014 16:35:05 +0300 Subject: [PATCH 48/54] Fixed crash on music volume change when no track is played using FluidSynth device --- src/sound/music_midistream.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sound/music_midistream.cpp b/src/sound/music_midistream.cpp index ba0077903..15f4caec8 100644 --- a/src/sound/music_midistream.cpp +++ b/src/sound/music_midistream.cpp @@ -540,7 +540,7 @@ bool MIDIStreamer::IsPlaying() void MIDIStreamer::MusicVolumeChanged() { - if (MIDI->FakeVolume()) + if (MIDI != NULL && MIDI->FakeVolume()) { float realvolume = clamp(snd_musicvolume * relative_volume, 0.f, 1.f); Volume = clamp((DWORD)(realvolume * 65535.f), 0, 65535); @@ -622,7 +622,7 @@ void MIDIStreamer::FluidSettingStr(const char *setting, const char *value) void MIDIStreamer::OutputVolume (DWORD volume) { - if (MIDI->FakeVolume()) + if (MIDI != NULL && MIDI->FakeVolume()) { NewVolume = volume; VolumeChanged = true; From 1d2aa3df0c6881c74e1ef350b8c9c19c5fc561c4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 25 Aug 2014 10:51:50 +0200 Subject: [PATCH 49/54] fixed: The wait console command waited one tic too many because it got 1 added to it twice instead of only once. --- src/c_dispatch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/c_dispatch.cpp b/src/c_dispatch.cpp index 105d8c0d3..65e017bdc 100644 --- a/src/c_dispatch.cpp +++ b/src/c_dispatch.cpp @@ -723,7 +723,7 @@ void AddCommandString (char *cmd, int keynum) // Note that deferred commands lose track of which key // (if any) they were pressed from. *brkpt = ';'; - new DWaitingCommand (brkpt, tics+1); + new DWaitingCommand (brkpt, tics); } return; } From 8f238f8d3269b579a2d46efbffd4f03095643dd2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 27 Aug 2014 11:06:12 +0200 Subject: [PATCH 50/54] - fixed: the Revenant's frame duration in its missile state were wrong. --- wadsrc/static/actors/doom/revenant.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wadsrc/static/actors/doom/revenant.txt b/wadsrc/static/actors/doom/revenant.txt index 5f0a78691..5ef97789b 100644 --- a/wadsrc/static/actors/doom/revenant.txt +++ b/wadsrc/static/actors/doom/revenant.txt @@ -39,8 +39,8 @@ ACTOR Revenant 66 SKEL I 6 A_SkelFist Goto See Missile: - SKEL J 1 BRIGHT A_FaceTarget - SKEL J 9 BRIGHT A_FaceTarget + SKEL J 0 BRIGHT A_FaceTarget + SKEL J 10 BRIGHT A_FaceTarget SKEL K 10 A_SkelMissile SKEL K 10 A_FaceTarget Goto See From 49382a2a146544e95f4278fb824b3531aae1202c Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Thu, 4 Sep 2014 19:34:41 -0400 Subject: [PATCH 51/54] - Added detection for The Adventures of Sqaure (based off MTrop's submission). - IWADINFO no longer requires a mapinfo to be specified. --- src/g_level.h | 2 +- src/g_mapinfo.cpp | 6 +++--- wadsrc/static/iwadinfo.txt | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/g_level.h b/src/g_level.h index 0cd366798..05290f48b 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -525,7 +525,7 @@ level_info_t *CheckLevelRedirect (level_info_t *info); FString CalcMapName (int episode, int level); -void G_ParseMapInfo (const char *basemapinfo); +void G_ParseMapInfo (FString basemapinfo); void G_ClearSnapshots (void); void P_RemoveDefereds (); diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index b7aa77e1c..5a451dfaa 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -1886,7 +1886,7 @@ static void ClearMapinfo() // //========================================================================== -void G_ParseMapInfo (const char *basemapinfo) +void G_ParseMapInfo (FString basemapinfo) { int lump, lastlump = 0; level_info_t gamedefaults; @@ -1895,7 +1895,7 @@ void G_ParseMapInfo (const char *basemapinfo) atterm(ClearMapinfo); // Parse the default MAPINFO for the current game. This lump *MUST* come from zdoom.pk3. - if (basemapinfo != NULL) + if (basemapinfo.IsNotEmpty()) { FMapInfoParser parse; level_info_t defaultinfo; @@ -1903,7 +1903,7 @@ void G_ParseMapInfo (const char *basemapinfo) if (Wads.GetLumpFile(baselump) > 0) { I_FatalError("File %s is overriding core lump %s.", - Wads.GetWadFullName(Wads.GetLumpFile(baselump)), basemapinfo); + Wads.GetWadFullName(Wads.GetLumpFile(baselump)), basemapinfo.GetChars()); } parse.ParseMapInfo(baselump, gamedefaults, defaultinfo); } diff --git a/wadsrc/static/iwadinfo.txt b/wadsrc/static/iwadinfo.txt index a2f8ef6c0..088e74466 100644 --- a/wadsrc/static/iwadinfo.txt +++ b/wadsrc/static/iwadinfo.txt @@ -1,5 +1,23 @@ // Must be sorted in identification order (easiest to recognize first!) +IWad +{ + Name = "The Adventures of Square" + Game = "Doom" + Config = "Square" + MustContain = "SQU-IWAD", "E1A1" + BannerColors = "ff ff ff", "80 00 80" +} + +IWad +{ + Name = "The Adventures of Square (Square-ware)" + Game = "Doom" + Config = "Square" + MustContain = "SQU-SWE1", "E1A1" + BannerColors = "ff ff ff", "80 00 80" +} + IWad { Name = "Harmony" @@ -361,4 +379,5 @@ Names "harm1.wad" "hacx.wad" "hacx2.wad" + "square1.pk3" } From cfd24f438f0d1f1bc84882d3e2bf9b072bb0881e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 8 Sep 2014 13:02:05 +0200 Subject: [PATCH 52/54] - jpalomo's A_Saw flags submission. --- src/g_doom/a_doomweaps.cpp | 34 ++++++++++++++++++------------ wadsrc/static/actors/constants.txt | 2 ++ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index 368d7ce8b..424e691e7 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -107,6 +107,8 @@ enum SAW_Flags SF_RANDOMLIGHTHIT = 4, SF_NOUSEAMMOMISS = 8, SF_NOUSEAMMO = 16, + SF_NOPULLIN = 32, + SF_NOTURN = 64, }; DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw) @@ -187,23 +189,27 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw) S_Sound (self, CHAN_WEAPON, hitsound, 1, ATTN_NORM); // turn to face target - angle = R_PointToAngle2 (self->x, self->y, - linetarget->x, linetarget->y); - if (angle - self->angle > ANG180) + if (!(Flags & SF_NOTURN)) { - if (angle - self->angle < (angle_t)(-ANG90/20)) - self->angle = angle + ANG90/21; + angle = R_PointToAngle2(self->x, self->y, + linetarget->x, linetarget->y); + if (angle - self->angle > ANG180) + { + if (angle - self->angle < (angle_t)(-ANG90 / 20)) + self->angle = angle + ANG90 / 21; + else + self->angle -= ANG90 / 20; + } else - self->angle -= ANG90/20; + { + if (angle - self->angle > ANG90 / 20) + self->angle = angle - ANG90 / 21; + else + self->angle += ANG90 / 20; + } } - else - { - if (angle - self->angle > ANG90/20) - self->angle = angle - ANG90/21; - else - self->angle += ANG90/20; - } - self->flags |= MF_JUSTATTACKED; + if (!(Flags & SF_NOPULLIN)) + self->flags |= MF_JUSTATTACKED; } // diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 0332d09a3..d5358e5af 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -14,6 +14,8 @@ const int SF_RANDOMLIGHTHIT = 4; const int SF_RANDOMLIGHTBOTH = 6; const int SF_NOUSEAMMOMISS = 8; const int SF_NOUSEAMMO = 16; +const int SF_NOPULLIN = 32; +const int SF_NOTURN = 64; // Flags for A_CustomMissile const int CMF_AIMOFFSET = 1; From 580e580c429885a34d2770fd8a10426510e0eef1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 8 Sep 2014 22:54:56 +0200 Subject: [PATCH 53/54] - added option to set a sector's tag via compatibility.txt (needed by GZDoom) --- src/compatibility.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/compatibility.cpp b/src/compatibility.cpp index 7339a0f19..c2153fbd7 100644 --- a/src/compatibility.cpp +++ b/src/compatibility.cpp @@ -81,6 +81,7 @@ enum CP_SECTORFLOOROFFSET, CP_SETWALLYSCALE, CP_SETTHINGZ, + CP_SETTAG, }; // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- @@ -307,6 +308,15 @@ void ParseCompatibility() sc.MustGetFloat(); CompatParams.Push(FLOAT2FIXED(sc.Float)); } + else if (sc.Compare("setsectortag")) + { + if (flags.ExtCommandIndex == ~0u) flags.ExtCommandIndex = CompatParams.Size(); + CompatParams.Push(CP_SETTAG); + sc.MustGetNumber(); + CompatParams.Push(sc.Number); + sc.MustGetNumber(); + CompatParams.Push(sc.Number); + } else { sc.UnGet(); @@ -520,6 +530,14 @@ void SetCompatibilityParams() i += 3; break; } + case CP_SETTAG: + { + if ((unsigned)CompatParams[i + 1] < (unsigned)numsectors) + { + sectors[CompatParams[i + 1]].tag = CompatParams[i + 2]; + } + break; + } } } } From 5e34b78451869558b38e8f08fba8102da40d2a0a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 8 Sep 2014 23:25:27 +0200 Subject: [PATCH 54/54] - missed a line. --- src/compatibility.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compatibility.cpp b/src/compatibility.cpp index c2153fbd7..351c2672a 100644 --- a/src/compatibility.cpp +++ b/src/compatibility.cpp @@ -536,6 +536,7 @@ void SetCompatibilityParams() { sectors[CompatParams[i + 1]].tag = CompatParams[i + 2]; } + i += 3; break; } }