diff --git a/source/games/blood/src/barf.cpp b/source/games/blood/src/barf.cpp index 057044ee7..634cf80e3 100644 --- a/source/games/blood/src/barf.cpp +++ b/source/games/blood/src/barf.cpp @@ -31,12 +31,12 @@ BEGIN_BLD_NS // I don't think we still need these. enum { - DICT_LOAD = 0, - DICT_LOCK = 0, - - kMaxCmdLineDefines = 5, - kMaxDefines = 1000, - kMaxParseLevels = 5 + DICT_LOAD = 0, + DICT_LOCK = 0, + + kMaxCmdLineDefines = 5, + kMaxDefines = 1000, + kMaxParseLevels = 5 }; static int nCmdDefines = 0; static int nDefines = 0; @@ -53,86 +53,86 @@ char scriptBuffer[256]; struct define_t { - FString _text; - int _value; + FString _text; + int _value; }; define_t gCmdDefines[kMaxCmdLineDefines]; -void addMemoryResource(char *fileName, char flags, int ID); +void addMemoryResource(char* fileName, char flags, int ID); struct tag_t { - const char *_value; - uint8_t _index; + const char* _value; + uint8_t _index; }; enum eTags { - kTag0, - kTagEnd, - kTagString, - kTagConstant, - kTag4, // string constant? - kTagComma, - kTagSemiColon, - kTagColon, - kTagEquals, - kTagHash, - kTagComment, - kTagInclude, - kTagResource, - kTagAs, - kTagPreload, - kTagPrelock, - kTagData, - kTagLoad, - kTagEmit, - kTagIfDef, - kTagEndif, - kTagElse + kTag0, + kTagEnd, + kTagString, + kTagConstant, + kTag4, // string constant? + kTagComma, + kTagSemiColon, + kTagColon, + kTagEquals, + kTagHash, + kTagComment, + kTagInclude, + kTagResource, + kTagAs, + kTagPreload, + kTagPrelock, + kTagData, + kTagLoad, + kTagEmit, + kTagIfDef, + kTagEndif, + kTagElse }; tag_t tags[] = { - { ",", kTagComma }, - { ";", kTagSemiColon }, - { ":", kTagColon }, - { "=", kTagEquals }, - { "#", kTagHash }, - { "//", kTagComment }, - { "INCLUDE", kTagInclude }, - { "RESOURCE", kTagResource }, - { "AS", kTagAs }, - { "PRELOAD", kTagPreload }, - { "PRELOCK", kTagPrelock }, - { "DATA", kTagData }, - { "LOAD", kTagLoad }, - { "EMIT", kTagEmit }, - { "%ifdef", kTagIfDef }, - { "%endif", kTagEndif }, - { "%else", kTagElse } + { ",", kTagComma }, + { ";", kTagSemiColon }, + { ":", kTagColon }, + { "=", kTagEquals }, + { "#", kTagHash }, + { "//", kTagComment }, + { "INCLUDE", kTagInclude }, + { "RESOURCE", kTagResource }, + { "AS", kTagAs }, + { "PRELOAD", kTagPreload }, + { "PRELOCK", kTagPrelock }, + { "DATA", kTagData }, + { "LOAD", kTagLoad }, + { "EMIT", kTagEmit }, + { "%ifdef", kTagIfDef }, + { "%endif", kTagEndif }, + { "%else", kTagElse } }; const int kTagCount = sizeof(tags) / sizeof(tag_t); -int qsort_compar(const void *a, const void *b) +int qsort_compar(const void* a, const void* b) { - return stricmp((const char*)a, (const char*)b); + return stricmp((const char*)a, (const char*)b); } void SortTags() { - qsort(tags, kTagCount, sizeof(tag_t), qsort_compar); + qsort(tags, kTagCount, sizeof(tag_t), qsort_compar); } -void AddCmdDefine(char *text, int value) +void AddCmdDefine(char* text, int value) { - assert(nCmdDefines < kMaxCmdLineDefines); + assert(nCmdDefines < kMaxCmdLineDefines); gCmdDefines[nCmdDefines]._text = text; - gCmdDefines[nCmdDefines]._value = value; + gCmdDefines[nCmdDefines]._value = value; - nCmdDefines++; + nCmdDefines++; } //--------------------------------------------------------------------------- @@ -141,47 +141,47 @@ void AddCmdDefine(char *text, int value) // //--------------------------------------------------------------------------- -static void SplitPath(const char *pzPath, char *pzDirectory, char *pzFile, char *pzType) +static void SplitPath(const char* pzPath, char* pzDirectory, char* pzFile, char* pzType) { - int const nLength = (int)strlen(pzPath); - const char *pDot = NULL; - for (int i = nLength-1; i >= 0; i--) - { - if (pzPath[i] == '/' || pzPath[i] == '\\') - { - strncpy(pzDirectory, pzPath, i); - pzDirectory[i] = 0; - if (!pDot) - { - strcpy(pzFile, pzPath+i+1); - strcpy(pzType, ""); - } - else - { - strncpy(pzFile, pzPath+i+1, pDot-(pzPath+i+1)); - pzFile[pDot-(pzPath+i+1)] = 0; - strcpy(pzType, pDot+1); - } - - return; - } - else if (pzPath[i] == '.') - { - pDot = pzPath+i; - } - } - strcpy(pzDirectory, "/"); - if (!pDot) - { - strcpy(pzFile, pzPath); - strcpy(pzType, ""); - } - else - { - strncpy(pzFile, pzPath, pDot-pzPath); - pzFile[pDot-pzPath] = 0; - strcpy(pzType, pDot+1); - } + int const nLength = (int)strlen(pzPath); + const char* pDot = NULL; + for (int i = nLength - 1; i >= 0; i--) + { + if (pzPath[i] == '/' || pzPath[i] == '\\') + { + strncpy(pzDirectory, pzPath, i); + pzDirectory[i] = 0; + if (!pDot) + { + strcpy(pzFile, pzPath + i + 1); + strcpy(pzType, ""); + } + else + { + strncpy(pzFile, pzPath + i + 1, pDot - (pzPath + i + 1)); + pzFile[pDot - (pzPath + i + 1)] = 0; + strcpy(pzType, pDot + 1); + } + + return; + } + else if (pzPath[i] == '.') + { + pDot = pzPath + i; + } + } + strcpy(pzDirectory, "/"); + if (!pDot) + { + strcpy(pzFile, pzPath); + strcpy(pzType, ""); + } + else + { + strncpy(pzFile, pzPath, pDot - pzPath); + pzFile[pDot - pzPath] = 0; + strcpy(pzType, pDot + 1); + } } @@ -197,26 +197,26 @@ struct RFS { private: TArray buffer; - char *_ptr; // [0] - char _curChar; // [4] - char *_pUnknown2; // [5] - some sort of pointer into _ptr? - char *_pStartLine; // [9] - char *_pEnd; // [13] - char *_pMark; // [17] - char _unknown6; // [21] - int _unknown7; // [22] - int _curLine; // [26] - char _fileName[BMAX_PATH]; // [30] + char* _ptr; // [0] + char _curChar; // [4] + char* _pUnknown2; // [5] - some sort of pointer into _ptr? + char* _pStartLine; // [9] + char* _pEnd; // [13] + char* _pMark; // [17] + char _unknown6; // [21] + int _unknown7; // [22] + int _curLine; // [26] + char _fileName[BMAX_PATH]; // [30] public: - int Open(int lumpnum); - void Close(); - void Increment(); - void SkipBeyondValue(char value); - uint8_t GetNextTag(); - void ScriptError(const char *message); - void SetMark(); - void UnsetMark(); + int Open(int lumpnum); + void Close(); + void Increment(); + void SkipBeyondValue(char value); + uint8_t GetNextTag(); + void ScriptError(const char* message); + void SetMark(); + void UnsetMark(); }; //--------------------------------------------------------------------------- @@ -227,29 +227,29 @@ public: int RFS::Open(int lumpnum) { - auto hFile = fileSystem.OpenFileReader(lumpnum); - if (!hFile.isOpen()) { - Printf("BARF: Error opening file %d", lumpnum); - return 1; - } + auto hFile = fileSystem.OpenFileReader(lumpnum); + if (!hFile.isOpen()) { + Printf("BARF: Error opening file %d", lumpnum); + return 1; + } int fileSize = (int)hFile.GetLength(); - buffer.Resize(fileSize+1); - _ptr = buffer.Data(); - if (_ptr == NULL) { - Printf("BARF: Not enough memory to read %d", lumpnum); - return 1; - } + buffer.Resize(fileSize + 1); + _ptr = buffer.Data(); + if (_ptr == NULL) { + Printf("BARF: Not enough memory to read %d", lumpnum); + return 1; + } - hFile.Read(_ptr, fileSize); - buffer[fileSize] = '\n'; + hFile.Read(_ptr, fileSize); + buffer[fileSize] = '\n'; - _curLine = 0; - _pUnknown2 = _ptr; - _curChar = '\n'; - _pEnd = &_ptr[fileSize]; + _curLine = 0; + _pUnknown2 = _ptr; + _curChar = '\n'; + _pEnd = &_ptr[fileSize]; - return 0; + return 0; } void RFS::Close() @@ -264,18 +264,18 @@ void RFS::Close() void RFS::Increment() { - if (_curChar == '\n') { - _curLine++; - _pStartLine = _pUnknown2; - } + if (_curChar == '\n') { + _curLine++; + _pStartLine = _pUnknown2; + } - if (_pUnknown2 >= _pEnd) { - _curChar = 0; - } - else { - _curChar = *_pUnknown2; // grabs the next char - _pUnknown2++; // increment pointer into char data - } + if (_pUnknown2 >= _pEnd) { + _curChar = 0; + } + else { + _curChar = *_pUnknown2; // grabs the next char + _pUnknown2++; // increment pointer into char data + } } //--------------------------------------------------------------------------- @@ -286,24 +286,24 @@ void RFS::Increment() void RFS::SkipBeyondValue(char nVal) { - while (_curChar && _curChar != nVal) { - Increment(); - } + while (_curChar && _curChar != nVal) { + Increment(); + } } void RFS::SetMark() { - _pMark = _pUnknown2; - _unknown6 = _curChar; - _unknown7 = _curLine; + _pMark = _pUnknown2; + _unknown6 = _curChar; + _unknown7 = _curLine; } // inverse of the above function void RFS::UnsetMark() { - _pUnknown2 = _pMark; - _curChar = _unknown6; - _curLine = _unknown7; + _pUnknown2 = _pMark; + _curChar = _unknown6; + _curLine = _unknown7; } //--------------------------------------------------------------------------- @@ -312,35 +312,35 @@ void RFS::UnsetMark() // //--------------------------------------------------------------------------- -void RFS::ScriptError(const char *message) +void RFS::ScriptError(const char* message) { - // TODO - TArray msg; + // TODO + TArray msg; - char *p = _pStartLine; - while (*p != '\n') - { - if (isprint(*p)) - msg.Push(*p); - else - msg.Push(' '); - p++; - } + char* p = _pStartLine; + while (*p != '\n') + { + if (isprint(*p)) + msg.Push(*p); + else + msg.Push(' '); + p++; + } - msg.Push('\n'); + msg.Push('\n'); - p = _pStartLine; + p = _pStartLine; - while (p < _pMark) - { - msg.Push(' '); - p++; - } + while (p < _pMark) + { + msg.Push(' '); + p++; + } - msg.Push('^'); - msg.Push(0); + msg.Push('^'); + msg.Push(0); - Printf("Error in %s line %d: %s\n\n%s", _fileName, _curLine, message, msg.Data()); + Printf("Error in %s line %d: %s\n\n%s", _fileName, _curLine, message, msg.Data()); } //--------------------------------------------------------------------------- @@ -351,188 +351,188 @@ void RFS::ScriptError(const char *message) uint8_t RFS::GetNextTag() { - // skip any space characters - do { - Increment(); - } while (isspace(_curChar)); + // skip any space characters + do { + Increment(); + } while (isspace(_curChar)); - if (_curChar == '\0') { - return kTagEnd; - } + if (_curChar == '\0') { + return kTagEnd; + } - SetMark(); + SetMark(); - // Path A - if (_curChar == '"') - { - Increment(); + // Path A + if (_curChar == '"') + { + Increment(); - int i = 0; + int i = 0; - // section 1 - while (1) { + // section 1 + while (1) { - if (_curChar == '\0' || _curChar == '"') { - scriptBuffer[i] = '\0'; - return kTagString; - } + if (_curChar == '\0' || _curChar == '"') { + scriptBuffer[i] = '\0'; + return kTagString; + } - if (i == 256) { - ScriptError("String exceeds maximum string length"); - break; - } + if (i == 256) { + ScriptError("String exceeds maximum string length"); + break; + } - scriptBuffer[i] = _curChar; - i++; - Increment(); - } + scriptBuffer[i] = _curChar; + i++; + Increment(); + } - // section 2 - while (1) - { - if (_curChar == '\0' || _curChar == '"') { - return kTag0; - } + // section 2 + while (1) + { + if (_curChar == '\0' || _curChar == '"') { + return kTag0; + } - Increment(); - } - } - else - { - scriptValue = 0; - bool isNegative = false; // or 'isSigned' ? + Increment(); + } + } + else + { + scriptValue = 0; + bool isNegative = false; // or 'isSigned' ? - // is it a negative number? - if (_curChar == '-') - { - Increment(); + // is it a negative number? + if (_curChar == '-') + { + Increment(); - isNegative = true; + isNegative = true; - if (!isdigit(_curChar)) { - UnsetMark(); - } - } + if (!isdigit(_curChar)) { + UnsetMark(); + } + } - if (isdigit(_curChar)) - { - // left path - if (_curChar == '0') - { - Increment(); + if (isdigit(_curChar)) + { + // left path + if (_curChar == '0') + { + Increment(); - // handle a hex value - if (toupper(_curChar) == 'X') - { - // orange loop - while (1) - { - Increment(); - if (!isxdigit(_curChar)) { // isxdigit() checks for a hex value - break; - } + // handle a hex value + if (toupper(_curChar) == 'X') + { + // orange loop + while (1) + { + Increment(); + if (!isxdigit(_curChar)) { // isxdigit() checks for a hex value + break; + } - // hex version of atoi? - scriptValue *= 16; - if (!isdigit(_curChar)) { - scriptValue += toupper(_curChar) - 55; - } - else { - scriptValue += _curChar - '0'; - } + // hex version of atoi? + scriptValue *= 16; + if (!isdigit(_curChar)) { + scriptValue += toupper(_curChar) - 55; + } + else { + scriptValue += _curChar - '0'; + } - SetMark(); - } + SetMark(); + } - UnsetMark(); - if (isNegative) { - scriptValue = -scriptValue; - } + UnsetMark(); + if (isNegative) { + scriptValue = -scriptValue; + } - return kTagConstant; - } + return kTagConstant; + } - UnsetMark(); - } + UnsetMark(); + } - // the loop - while (isdigit(_curChar)) - { - // atoi implementation - scriptValue = scriptValue * 10 + _curChar - '0'; - SetMark(); - Increment(); - } + // the loop + while (isdigit(_curChar)) + { + // atoi implementation + scriptValue = scriptValue * 10 + _curChar - '0'; + SetMark(); + Increment(); + } - UnsetMark(); - if (isNegative) { - scriptValue = -scriptValue; - } + UnsetMark(); + if (isNegative) { + scriptValue = -scriptValue; + } - return kTagConstant; - } - else - { - // BLUEISH PATH - int ebp = 0; // v11 - int i = 0; + return kTagConstant; + } + else + { + // BLUEISH PATH + int ebp = 0; // v11 + int i = 0; - // blue loop #1 - while (1) - { - scriptBuffer[ebp] = _curChar; - ebp++; - int eax = -1; + // blue loop #1 + while (1) + { + scriptBuffer[ebp] = _curChar; + ebp++; + int eax = -1; - // blue loop #2 - for (i = 0; i < kTagCount; i++) - { - //if (eax >= 0) { - if (eax == 0) { - break; - } + // blue loop #2 + for (i = 0; i < kTagCount; i++) + { + //if (eax >= 0) { + if (eax == 0) { + break; + } - // eax = strnicmp(tags[i]._value, scriptBuffer, ebp); - eax = strnicmp(scriptBuffer, tags[i]._value, ebp); + // eax = strnicmp(tags[i]._value, scriptBuffer, ebp); + eax = strnicmp(scriptBuffer, tags[i]._value, ebp); - //if (eax >= 0) { - if (eax == 0) { - break; - } - } + //if (eax >= 0) { + if (eax == 0) { + break; + } + } - if (eax > 0 || i == kTagCount) { - break; - } + if (eax > 0 || i == kTagCount) { + break; + } - if (eax == 0 && (int)strlen(tags[i]._value) == ebp) - { - scriptBuffer[ebp] = 0; - return tags[i]._index; - } + if (eax == 0 && (int)strlen(tags[i]._value) == ebp) + { + scriptBuffer[ebp] = 0; + return tags[i]._index; + } - Increment(); - } + Increment(); + } - UnsetMark(); + UnsetMark(); - i = 0; + i = 0; - while (isalnum(_curChar)) - { - scriptBuffer[i] = _curChar; - SetMark(); - i++; - Increment(); - } + while (isalnum(_curChar)) + { + scriptBuffer[i] = _curChar; + SetMark(); + i++; + Increment(); + } - UnsetMark(); - scriptBuffer[i] = 0; - return kTag4; - } - } + UnsetMark(); + scriptBuffer[i] = 0; + return kTag4; + } + } - // qAssert(1==0); // TODO - what to return here + // qAssert(1==0); // TODO - what to return here } //--------------------------------------------------------------------------- @@ -543,442 +543,442 @@ uint8_t RFS::GetNextTag() void ParseScript(int lumpnum) { - char text[256]; - char char256_1[256]; - char char256_2[256]; - char fileName[BMAX_PATH]; - char inp[BMAX_PATH]; - //char zScriptDirectory[BMAX_PATH], zTemp1[BMAX_PATH], zTemp2[BMAX_PATH]; + char text[256]; + char char256_1[256]; + char char256_2[256]; + char fileName[BMAX_PATH]; + char inp[BMAX_PATH]; + //char zScriptDirectory[BMAX_PATH], zTemp1[BMAX_PATH], zTemp2[BMAX_PATH]; - //SplitPath(scriptFileName, zScriptDirectory, zTemp1, zTemp2); + //SplitPath(scriptFileName, zScriptDirectory, zTemp1, zTemp2); - RFS rfs; + RFS rfs; - // AddExtension(name, ".RFS"); - if (rfs.Open(lumpnum)) - { - return; - } + // AddExtension(name, ".RFS"); + if (rfs.Open(lumpnum)) + { + return; + } - gParseLevel = 0; - dword_44CE0[0] = 0; + gParseLevel = 0; + dword_44CE0[0] = 0; - bool parsing = true; + bool parsing = true; - while (parsing) - { - // START LOOP. to be fixed later - START: + while (parsing) + { + // START LOOP. to be fixed later + START: - uint8_t tag = rfs.GetNextTag(); + uint8_t tag = rfs.GetNextTag(); - switch (tag) - { - default: - { - break; - } - case kTagEnd: - { - parsing = false; - break; - } - case kTagComment: - { - // skip to next line - rfs.SkipBeyondValue('\n'); - break; - } - case kTagEmit: // minty/light green colour - { - tag = rfs.GetNextTag(); - if (tag != kTag4) - { - rfs.ScriptError("Symbol name expected"); - rfs.SkipBeyondValue(';'); - break; - } - else - { - strcpy(char256_2, scriptBuffer); - tag = rfs.GetNextTag(); - if (tag != kTagEquals) - { - rfs.ScriptError("Missing '='"); - rfs.SkipBeyondValue(';'); - break; - } - - tag = rfs.GetNextTag(); - if (tag != kTagConstant) - { - rfs.ScriptError("Constant expected"); - rfs.SkipBeyondValue(';'); - break; - } - else - { - //AddDefine(char256_2, scriptValue); - rfs.SkipBeyondValue('\n'); - } - } - [[fallthrough]]; - } - case kTagResource: // really light blue.. - { - if (kTagString != rfs.GetNextTag()) { - rfs.ScriptError("String constant exected"); - rfs.SkipBeyondValue('\n'); - break; - } - - strcpy(inp, scriptBuffer); - uint8_t nFlags = 0; - int ID = 0; - bool isDefine = false; - - tag = rfs.GetNextTag(); - if (tag == kTagAs) - { - tag = rfs.GetNextTag(); - if (tag == kTag4) - { - strcpy(text, scriptBuffer); - - if (rfs.GetNextTag() != kTagEquals) - { - rfs.ScriptError("Missing '='"); - rfs.SkipBeyondValue(';'); - break; - } - - isDefine = true; - tag = rfs.GetNextTag(); - } - - if (tag != kTagConstant) - { - rfs.ScriptError("Constant expected"); - rfs.SkipBeyondValue(';'); - break; - } - - if (isDefine) { - //AddDefine(text, scriptValue); - } - - ID = scriptValue; - tag = rfs.GetNextTag(); - } - - //if (!bNoEncrypt) { - // nFlags |= kResFlagIsEncrypted; - //} - - while (tag == kTagComma) - { - tag = rfs.GetNextTag(); - - if (tag == kTagPreload) { - nFlags |= DICT_LOAD; - } - else if (tag == kTagPrelock) { - nFlags |= DICT_LOCK; - } - else { - rfs.ScriptError("Unrecognized flag"); - rfs.SkipBeyondValue(';'); - goto START; // FIXME - } - - tag = rfs.GetNextTag(); - } - - if (tag != kTagSemiColon) - { - rfs.ScriptError("';' expected"); - rfs.SkipBeyondValue(';'); - break; - } - - if (dword_44CE0[gParseLevel] == 0) + switch (tag) + { + default: + { + break; + } + case kTagEnd: + { + parsing = false; + break; + } + case kTagComment: + { + // skip to next line + rfs.SkipBeyondValue('\n'); + break; + } + case kTagEmit: // minty/light green colour + { + tag = rfs.GetNextTag(); + if (tag != kTag4) + { + rfs.ScriptError("Symbol name expected"); + rfs.SkipBeyondValue(';'); + break; + } + else + { + strcpy(char256_2, scriptBuffer); + tag = rfs.GetNextTag(); + if (tag != kTagEquals) { - // In the RFS files I have seen the outermost directory is not part of what goes into the file system. - auto inp1 = strpbrk(inp, "/\\"); - if (!inp1 || !fileSystem.CreatePathlessCopy(inp1 + 1, ID, nFlags)) + rfs.ScriptError("Missing '='"); + rfs.SkipBeyondValue(';'); + break; + } + + tag = rfs.GetNextTag(); + if (tag != kTagConstant) + { + rfs.ScriptError("Constant expected"); + rfs.SkipBeyondValue(';'); + break; + } + else + { + //AddDefine(char256_2, scriptValue); + rfs.SkipBeyondValue('\n'); + } + } + [[fallthrough]]; + } + case kTagResource: // really light blue.. + { + if (kTagString != rfs.GetNextTag()) { + rfs.ScriptError("String constant exected"); + rfs.SkipBeyondValue('\n'); + break; + } + + strcpy(inp, scriptBuffer); + uint8_t nFlags = 0; + int ID = 0; + bool isDefine = false; + + tag = rfs.GetNextTag(); + if (tag == kTagAs) + { + tag = rfs.GetNextTag(); + if (tag == kTag4) + { + strcpy(text, scriptBuffer); + + if (rfs.GetNextTag() != kTagEquals) { - // GDX spports this so we should, too. - fileSystem.CreatePathlessCopy(inp, ID, nFlags); + rfs.ScriptError("Missing '='"); + rfs.SkipBeyondValue(';'); + break; } - } - break; - } - case kTagIfDef: // purplish colour - { - tag = rfs.GetNextTag(); - if (tag != kTag4) - { - rfs.ScriptError("Parameter error in ifdef"); - rfs.SkipBeyondValue('\n'); - break; - } - else - { - rfs.SetMark(); - strcpy(char256_1, scriptBuffer); + isDefine = true; + tag = rfs.GetNextTag(); + } - bool bGotDefine = false; + if (tag != kTagConstant) + { + rfs.ScriptError("Constant expected"); + rfs.SkipBeyondValue(';'); + break; + } - // check if this was defined via command prompt arguments - for (int i = 0; i < nCmdDefines; i++) - { - if (stricmp(gCmdDefines[i]._text, char256_1) == 0) { // string is equivalent - bGotDefine = true; - break; - } - } + if (isDefine) { + //AddDefine(text, scriptValue); + } - // loc_11FC3: - gParseLevel++; - assert(gParseLevel < kMaxParseLevels); + ID = scriptValue; + tag = rfs.GetNextTag(); + } - if (bGotDefine) { - dword_44CE0[gParseLevel] = dword_44CE0[gParseLevel - 1]; - } - else { - dword_44CE0[gParseLevel] = 1; - } - } - break; - } - case kTagElse: // pinky colour - { - if (gParseLevel) - { - // loc_12066: - if (dword_44CE0[gParseLevel - 1] == 0) { - if (dword_44CE0[gParseLevel] == 0) { - dword_44CE0[gParseLevel] = 1; - } + //if (!bNoEncrypt) { + // nFlags |= kResFlagIsEncrypted; + //} - rfs.SkipBeyondValue('\n'); - break; - } - } - else { - rfs.ScriptError("Unexpected else"); - rfs.SkipBeyondValue('\n'); - break; - } - break; - } - case kTagEndif: // poo coloured - { - if (gParseLevel) { - gParseLevel--; - rfs.SkipBeyondValue('\n'); - break; - } - else - { - rfs.ScriptError("Unexpected Endif"); - rfs.SkipBeyondValue('\n'); - break; - } - } - case kTagHash: // gold colour - { - tag = rfs.GetNextTag(); - if (tag == kTagInclude) - { - tag = rfs.GetNextTag(); - if (tag != kTagString) - { - rfs.ScriptError("String constant exected"); - // why no SkipBeyondValue? - break; - } - else - { - // too dangerous if we want to cumulatively collect all RFS files - //fileSystem.Rehash(); - //ParseScript(scriptBuffer); - } - } - break; - } - case kTagData: // eg: data "AMB1.SFX" as 1: 80, 0x10000, 0x0, 1, -1, "amb1"; - { - // green coloured section - if (rfs.GetNextTag() != kTagString) { - rfs.ScriptError("String constant expected"); - rfs.SkipBeyondValue(';'); - break; - } + while (tag == kTagComma) + { + tag = rfs.GetNextTag(); - // eg strcpy(fileName, "AMB1.SFX"); - strcpy(fileName, scriptBuffer); + if (tag == kTagPreload) { + nFlags |= DICT_LOAD; + } + else if (tag == kTagPrelock) { + nFlags |= DICT_LOCK; + } + else { + rfs.ScriptError("Unrecognized flag"); + rfs.SkipBeyondValue(';'); + goto START; // FIXME + } - uint8_t nFlags = 0; - int ID = 0; + tag = rfs.GetNextTag(); + } - bool isDefine = false; + if (tag != kTagSemiColon) + { + rfs.ScriptError("';' expected"); + rfs.SkipBeyondValue(';'); + break; + } - tag = rfs.GetNextTag(); + if (dword_44CE0[gParseLevel] == 0) + { + // In the RFS files I have seen the outermost directory is not part of what goes into the file system. + auto inp1 = strpbrk(inp, "/\\"); + if (!inp1 || !fileSystem.CreatePathlessCopy(inp1 + 1, ID, nFlags)) + { + // GDX spports this so we should, too. + fileSystem.CreatePathlessCopy(inp, ID, nFlags); + } + } - // process an ID section - if (tag == kTagAs) - { - tag = rfs.GetNextTag(); - if (tag == kTag4) - { - strcpy(fileName, scriptBuffer); + break; + } + case kTagIfDef: // purplish colour + { + tag = rfs.GetNextTag(); + if (tag != kTag4) + { + rfs.ScriptError("Parameter error in ifdef"); + rfs.SkipBeyondValue('\n'); + break; + } + else + { + rfs.SetMark(); + strcpy(char256_1, scriptBuffer); - tag = rfs.GetNextTag(); - if (tag != kTagEquals) { - rfs.ScriptError("Missing '='"); - rfs.SkipBeyondValue(';'); - break; - } + bool bGotDefine = false; - isDefine = true; - tag = rfs.GetNextTag(); - } + // check if this was defined via command prompt arguments + for (int i = 0; i < nCmdDefines; i++) + { + if (stricmp(gCmdDefines[i]._text, char256_1) == 0) { // string is equivalent + bGotDefine = true; + break; + } + } - if (tag != kTagConstant) - { - rfs.ScriptError("Constant Expected"); - rfs.SkipBeyondValue(';'); - break; - } - else { - //if (isDefine) { - // AddDefine(fileName, scriptValue); - //} + // loc_11FC3: + gParseLevel++; + assert(gParseLevel < kMaxParseLevels); - ID = scriptValue; - tag = rfs.GetNextTag(); - } - } + if (bGotDefine) { + dword_44CE0[gParseLevel] = dword_44CE0[gParseLevel - 1]; + } + else { + dword_44CE0[gParseLevel] = 1; + } + } + break; + } + case kTagElse: // pinky colour + { + if (gParseLevel) + { + // loc_12066: + if (dword_44CE0[gParseLevel - 1] == 0) { + if (dword_44CE0[gParseLevel] == 0) { + dword_44CE0[gParseLevel] = 1; + } - if (tag == kTagComma) - { - // process all sections on this line that are comma separated - while (1) - { - tag = rfs.GetNextTag(); - if (tag == kTagPreload) - { - nFlags |= DICT_LOAD; - tag = rfs.GetNextTag(); + rfs.SkipBeyondValue('\n'); + break; + } + } + else { + rfs.ScriptError("Unexpected else"); + rfs.SkipBeyondValue('\n'); + break; + } + break; + } + case kTagEndif: // poo coloured + { + if (gParseLevel) { + gParseLevel--; + rfs.SkipBeyondValue('\n'); + break; + } + else + { + rfs.ScriptError("Unexpected Endif"); + rfs.SkipBeyondValue('\n'); + break; + } + } + case kTagHash: // gold colour + { + tag = rfs.GetNextTag(); + if (tag == kTagInclude) + { + tag = rfs.GetNextTag(); + if (tag != kTagString) + { + rfs.ScriptError("String constant exected"); + // why no SkipBeyondValue? + break; + } + else + { + // too dangerous if we want to cumulatively collect all RFS files + //fileSystem.Rehash(); + //ParseScript(scriptBuffer); + } + } + break; + } + case kTagData: // eg: data "AMB1.SFX" as 1: 80, 0x10000, 0x0, 1, -1, "amb1"; + { + // green coloured section + if (rfs.GetNextTag() != kTagString) { + rfs.ScriptError("String constant expected"); + rfs.SkipBeyondValue(';'); + break; + } - if (tag == kTagComma) { - continue; - } - } - else if (tag == kTagPrelock) - { - nFlags |= DICT_LOCK; - tag = rfs.GetNextTag(); + // eg strcpy(fileName, "AMB1.SFX"); + strcpy(fileName, scriptBuffer); - if (tag == kTagComma) { - continue; - } - } - else - { - rfs.ScriptError("Unrecognized flag"); - rfs.SkipBeyondValue(';'); - goto START; // FIXME - } - } - } + uint8_t nFlags = 0; + int ID = 0; - // loc_12471: - if (tag != kTagColon) // marked orange in IDA - { - while (1) - { - if (tag == kTagPreload) - { - nFlags |= DICT_LOAD; - tag = rfs.GetNextTag(); + bool isDefine = false; - if (tag == kTagColon) { - break; - } - } - else if (tag == kTagPrelock) - { - nFlags |= DICT_LOCK; - tag = rfs.GetNextTag(); + tag = rfs.GetNextTag(); - if (tag == kTagColon) { - break; - } - } - else { - rfs.ScriptError("':' expected"); - rfs.SkipBeyondValue(';'); - goto START; // FIXME - } - } - } + // process an ID section + if (tag == kTagAs) + { + tag = rfs.GetNextTag(); + if (tag == kTag4) + { + strcpy(fileName, scriptBuffer); - nBytes = 0; + tag = rfs.GetNextTag(); + if (tag != kTagEquals) { + rfs.ScriptError("Missing '='"); + rfs.SkipBeyondValue(';'); + break; + } - // yellow loop - while (1) - { - tag = rfs.GetNextTag(); + isDefine = true; + tag = rfs.GetNextTag(); + } - switch (tag) - { - case kTagString: - { - memcpy(&buffer[nBytes], scriptBuffer, strlen(scriptBuffer) + 1); - nBytes += (int)strlen(scriptBuffer) + 1; - break; - } - case kTagConstant: - { - memcpy(&buffer[nBytes], &scriptValue, sizeof(scriptValue)); - nBytes += sizeof(scriptValue); - break; - } - default: - { - rfs.ScriptError("Constant expected"); - rfs.SkipBeyondValue(';'); - goto START; // FIXME - } - } + if (tag != kTagConstant) + { + rfs.ScriptError("Constant Expected"); + rfs.SkipBeyondValue(';'); + break; + } + else { + //if (isDefine) { + // AddDefine(fileName, scriptValue); + //} - tag = rfs.GetNextTag(); - if (tag != kTagComma) { - break; - } - } + ID = scriptValue; + tag = rfs.GetNextTag(); + } + } - if (tag != kTagSemiColon) { - rfs.ScriptError("Semicolon expected"); - rfs.SkipBeyondValue(';'); - break; - } - else - { - if (dword_44CE0[gParseLevel] == 0) { - addMemoryResource(fileName, nFlags, ID); - } - } - break; - } - } - } + if (tag == kTagComma) + { + // process all sections on this line that are comma separated + while (1) + { + tag = rfs.GetNextTag(); + if (tag == kTagPreload) + { + nFlags |= DICT_LOAD; + tag = rfs.GetNextTag(); - //CreateHeader(); - rfs.Close(); + if (tag == kTagComma) { + continue; + } + } + else if (tag == kTagPrelock) + { + nFlags |= DICT_LOCK; + tag = rfs.GetNextTag(); + + if (tag == kTagComma) { + continue; + } + } + else + { + rfs.ScriptError("Unrecognized flag"); + rfs.SkipBeyondValue(';'); + goto START; // FIXME + } + } + } + + // loc_12471: + if (tag != kTagColon) // marked orange in IDA + { + while (1) + { + if (tag == kTagPreload) + { + nFlags |= DICT_LOAD; + tag = rfs.GetNextTag(); + + if (tag == kTagColon) { + break; + } + } + else if (tag == kTagPrelock) + { + nFlags |= DICT_LOCK; + tag = rfs.GetNextTag(); + + if (tag == kTagColon) { + break; + } + } + else { + rfs.ScriptError("':' expected"); + rfs.SkipBeyondValue(';'); + goto START; // FIXME + } + } + } + + nBytes = 0; + + // yellow loop + while (1) + { + tag = rfs.GetNextTag(); + + switch (tag) + { + case kTagString: + { + memcpy(&buffer[nBytes], scriptBuffer, strlen(scriptBuffer) + 1); + nBytes += (int)strlen(scriptBuffer) + 1; + break; + } + case kTagConstant: + { + memcpy(&buffer[nBytes], &scriptValue, sizeof(scriptValue)); + nBytes += sizeof(scriptValue); + break; + } + default: + { + rfs.ScriptError("Constant expected"); + rfs.SkipBeyondValue(';'); + goto START; // FIXME + } + } + + tag = rfs.GetNextTag(); + if (tag != kTagComma) { + break; + } + } + + if (tag != kTagSemiColon) { + rfs.ScriptError("Semicolon expected"); + rfs.SkipBeyondValue(';'); + break; + } + else + { + if (dword_44CE0[gParseLevel] == 0) { + addMemoryResource(fileName, nFlags, ID); + } + } + break; + } + } + } + + //CreateHeader(); + rfs.Close(); } //--------------------------------------------------------------------------- @@ -989,13 +989,13 @@ void ParseScript(int lumpnum) void addMemoryResource(char* filePath, char flags, int ID) { - char zDirectory[BMAX_PATH]; - char zFilename[BMAX_PATH]; - char zType[BMAX_PATH]; + char zDirectory[BMAX_PATH]; + char zFilename[BMAX_PATH]; + char zType[BMAX_PATH]; - SplitPath(filePath, zDirectory, zFilename, zType); + SplitPath(filePath, zDirectory, zFilename, zType); - fileSystem.AddFromBuffer(zFilename, zType, buffer, nBytes, ID, flags); + fileSystem.AddFromBuffer(zFilename, zType, buffer, nBytes, ID, flags); } @@ -1007,17 +1007,17 @@ void addMemoryResource(char* filePath, char flags, int ID) void ReadAllRFS() { - bool found = false; - auto numf = fileSystem.GetNumEntries(); - for (int i = 0; i < numf; i++) - { - auto rl = fileSystem.GetResourceType(i); - if (!stricmp(rl, "RFS")) - { - ParseScript(i); - found = true; - } - } - if (found) fileSystem.InitHashChains(); + bool found = false; + auto numf = fileSystem.GetNumEntries(); + for (int i = 0; i < numf; i++) + { + auto rl = fileSystem.GetResourceType(i); + if (!stricmp(rl, "RFS")) + { + ParseScript(i); + found = true; + } + } + if (found) fileSystem.InitHashChains(); } END_BLD_NS diff --git a/source/games/blood/src/db.cpp b/source/games/blood/src/db.cpp index c734cb56e..3c62b7dcb 100644 --- a/source/games/blood/src/db.cpp +++ b/source/games/blood/src/db.cpp @@ -47,21 +47,21 @@ int gSkyCount; DBloodActor* InsertSprite(sectortype* pSector, int nStat) { - auto act = static_cast(::InsertActor(RUNTIME_CLASS(DBloodActor), pSector, nStat)); - act->spr.cstat = CSTAT_SPRITE_YCENTER; - act->spr.clipdist = 32; - act->spr.xrepeat = act->spr.yrepeat = 64; - return act; + auto act = static_cast(::InsertActor(RUNTIME_CLASS(DBloodActor), pSector, nStat)); + act->spr.cstat = CSTAT_SPRITE_YCENTER; + act->spr.clipdist = 32; + act->spr.xrepeat = act->spr.yrepeat = 64; + return act; } int DeleteSprite(DBloodActor* actor) { #ifdef NOONE_EXTENSIONS - for (auto& ctrl : gPlayerCtrl) if (ctrl.qavScene.initiator == actor) ctrl.qavScene.initiator = nullptr; + for (auto& ctrl : gPlayerCtrl) if (ctrl.qavScene.initiator == actor) ctrl.qavScene.initiator = nullptr; #endif - actor->Destroy(); - return 0; + actor->Destroy(); + return 0; } @@ -74,13 +74,13 @@ int gVisibility; // //--------------------------------------------------------------------------- -void dbCrypt(char *pPtr, int nLength, int nKey) +void dbCrypt(char* pPtr, int nLength, int nKey) { - for (int i = 0; i < nLength; i++) - { - pPtr[i] = pPtr[i] ^ nKey; - nKey++; - } + for (int i = 0; i < nLength; i++) + { + pPtr[i] = pPtr[i] ^ nKey; + nKey++; + } } @@ -90,37 +90,37 @@ void dbCrypt(char *pPtr, int nLength, int nKey) // //--------------------------------------------------------------------------- -unsigned int dbReadMapCRC(const char *pPath) +unsigned int dbReadMapCRC(const char* pPath) { - FString mapname = pPath; - DefaultExtension(mapname, ".map"); - auto fr = fileSystem.OpenFileReader(mapname); + FString mapname = pPath; + DefaultExtension(mapname, ".map"); + auto fr = fileSystem.OpenFileReader(mapname); - if (!fr.isOpen()) - { - Printf("Error opening map file %s", pPath); - return -1; - } + if (!fr.isOpen()) + { + Printf("Error opening map file %s", pPath); + return -1; + } - MAPSIGNATURE header; - fr.Read(&header, 6); - if (memcmp(header.signature, "BLM\x1a", 4)) - { - I_Error("%s: Map file corrupted.", mapname.GetChars()); - } - int ver = LittleShort(header.version); - if ((ver & 0xff00) == 0x600) - { - } - else if ((ver & 0xff00) == 0x700) - { - } - else - { - I_Error("%s: Map file is wrong version.", mapname.GetChars()); - } - fr.Seek(-4, FileReader::SeekEnd); - return fr.ReadInt32(); + MAPSIGNATURE header; + fr.Read(&header, 6); + if (memcmp(header.signature, "BLM\x1a", 4)) + { + I_Error("%s: Map file corrupted.", mapname.GetChars()); + } + int ver = LittleShort(header.version); + if ((ver & 0xff00) == 0x600) + { + } + else if ((ver & 0xff00) == 0x700) + { + } + else + { + I_Error("%s: Map file is wrong version.", mapname.GetChars()); + } + fr.Seek(-4, FileReader::SeekEnd); + return fr.ReadInt32(); } //--------------------------------------------------------------------------- @@ -131,548 +131,548 @@ unsigned int dbReadMapCRC(const char *pPath) void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, sectortype** ppSector, unsigned int* pCRC, BloodSpawnSpriteDef& sprites) { - const int nXSectorSize = 60; - const int nXSpriteSize = 56; - const int nXWallSize = 24; + const int nXSectorSize = 60; + const int nXSpriteSize = 56; + const int nXWallSize = 24; - MAPHEADER2 xheader; - int gMapRev, gMattId; + MAPHEADER2 xheader; + int gMapRev, gMattId; - int16_t tpskyoff[256]; - ClearAutomap(); + int16_t tpskyoff[256]; + ClearAutomap(); #ifdef NOONE_EXTENSIONS - gModernMap = false; + gModernMap = false; #endif #ifdef NOONE_EXTENSIONS - for (auto& ctrl : gPlayerCtrl) ctrl.qavScene.initiator = nullptr; + for (auto& ctrl : gPlayerCtrl) ctrl.qavScene.initiator = nullptr; #endif - FString mapname = pPath; - DefaultExtension(mapname, ".map"); - auto fr = fileSystem.OpenFileReader(mapname); + FString mapname = pPath; + DefaultExtension(mapname, ".map"); + auto fr = fileSystem.OpenFileReader(mapname); - if (!fr.isOpen()) - { - I_Error("Error opening map file %s", mapname.GetChars()); - } - MAPSIGNATURE header; - fr.Read(&header, 6); - if (memcmp(header.signature, "BLM\x1a", 4)) - { - I_Error("%s: Map file corrupted", mapname.GetChars()); - } - bool encrypted = 0; - if ((LittleShort(header.version) & 0xff00) == 0x700) { - encrypted = 1; + if (!fr.isOpen()) + { + I_Error("Error opening map file %s", mapname.GetChars()); + } + MAPSIGNATURE header; + fr.Read(&header, 6); + if (memcmp(header.signature, "BLM\x1a", 4)) + { + I_Error("%s: Map file corrupted", mapname.GetChars()); + } + bool encrypted = 0; + if ((LittleShort(header.version) & 0xff00) == 0x700) { + encrypted = 1; #ifdef NOONE_EXTENSIONS - // indicate if the map requires modern features to work properly - // for maps wich created in PMAPEDIT BETA13 or higher versions. Since only minor version changed, - // the map is still can be loaded with vanilla BLOOD / MAPEDIT and should work in other ports too. - if ((header.version & 0x00ff) == 0x001) gModernMap = true; + // indicate if the map requires modern features to work properly + // for maps wich created in PMAPEDIT BETA13 or higher versions. Since only minor version changed, + // the map is still can be loaded with vanilla BLOOD / MAPEDIT and should work in other ports too. + if ((header.version & 0x00ff) == 0x001) gModernMap = true; #endif - } - else { - I_Error("%s: Map file is wrong version", mapname.GetChars()); - } + } + else { + I_Error("%s: Map file is wrong version", mapname.GetChars()); + } - MAPHEADER mapHeader; - fr.Read(&mapHeader, 37/* sizeof(mapHeader)*/); - if (mapHeader.mattid != 0 && mapHeader.mattid != 0x7474614d && mapHeader.mattid != 0x4d617474) { - dbCrypt((char*)&mapHeader, sizeof(mapHeader), 0x7474614d); - } + MAPHEADER mapHeader; + fr.Read(&mapHeader, 37/* sizeof(mapHeader)*/); + if (mapHeader.mattid != 0 && mapHeader.mattid != 0x7474614d && mapHeader.mattid != 0x4d617474) { + dbCrypt((char*)&mapHeader, sizeof(mapHeader), 0x7474614d); + } - mapHeader.x = LittleLong(mapHeader.x); - mapHeader.y = LittleLong(mapHeader.y); - mapHeader.z = LittleLong(mapHeader.z); - mapHeader.ang = LittleShort(mapHeader.ang); - mapHeader.sect = LittleShort(mapHeader.sect); - mapHeader.pskybits = LittleShort(mapHeader.pskybits); - mapHeader.visibility = LittleLong(mapHeader.visibility); - mapHeader.mattid = LittleLong(mapHeader.mattid); - mapHeader.revision = LittleLong(mapHeader.revision); - mapHeader.numsectors = LittleShort(mapHeader.numsectors); - mapHeader.numwalls = LittleShort(mapHeader.numwalls); - mapHeader.numsprites = LittleShort(mapHeader.numsprites); + mapHeader.x = LittleLong(mapHeader.x); + mapHeader.y = LittleLong(mapHeader.y); + mapHeader.z = LittleLong(mapHeader.z); + mapHeader.ang = LittleShort(mapHeader.ang); + mapHeader.sect = LittleShort(mapHeader.sect); + mapHeader.pskybits = LittleShort(mapHeader.pskybits); + mapHeader.visibility = LittleLong(mapHeader.visibility); + mapHeader.mattid = LittleLong(mapHeader.mattid); + mapHeader.revision = LittleLong(mapHeader.revision); + mapHeader.numsectors = LittleShort(mapHeader.numsectors); + mapHeader.numwalls = LittleShort(mapHeader.numwalls); + mapHeader.numsprites = LittleShort(mapHeader.numsprites); - *pX = mapHeader.x; - *pY = mapHeader.y; - *pZ = mapHeader.z; - *pAngle = mapHeader.ang; - gVisibility = g_visibility = mapHeader.visibility; - gMattId = mapHeader.mattid; - if (encrypted) - { - if (!(mapHeader.mattid == 0x7474614d || mapHeader.mattid == 0x4d617474 || !mapHeader.mattid)) - { - I_Error("%s: Corrupted Map file", mapname.GetChars()); - } - } - else if (mapHeader.mattid) - { - I_Error("%s: Corrupted Map file", mapname.GetChars()); - } - parallaxtype = mapHeader.parallax; - gMapRev = mapHeader.revision; - allocateMapArrays(mapHeader.numwalls, mapHeader.numsectors, mapHeader.numsprites); + *pX = mapHeader.x; + *pY = mapHeader.y; + *pZ = mapHeader.z; + *pAngle = mapHeader.ang; + gVisibility = g_visibility = mapHeader.visibility; + gMattId = mapHeader.mattid; + if (encrypted) + { + if (!(mapHeader.mattid == 0x7474614d || mapHeader.mattid == 0x4d617474 || !mapHeader.mattid)) + { + I_Error("%s: Corrupted Map file", mapname.GetChars()); + } + } + else if (mapHeader.mattid) + { + I_Error("%s: Corrupted Map file", mapname.GetChars()); + } + parallaxtype = mapHeader.parallax; + gMapRev = mapHeader.revision; + allocateMapArrays(mapHeader.numwalls, mapHeader.numsectors, mapHeader.numsprites); #if 1 // bad, bad hack, just for making Polymost happy... PolymostAllocFakeSector(); #endif - * ppSector = mapHeader.sect >= 0? §or[mapHeader.sect] : nullptr; + * ppSector = mapHeader.sect >= 0 ? §or[mapHeader.sect] : nullptr; - if (encrypted) - { - fr.Read(&xheader, 128); - dbCrypt((char*)&xheader, 128, wall.Size()); + if (encrypted) + { + fr.Read(&xheader, 128); + dbCrypt((char*)&xheader, 128, wall.Size()); - xheader.numxsprites = LittleLong(xheader.numxsprites); - xheader.numxwalls = LittleLong(xheader.numxwalls); - xheader.numxsectors = LittleLong(xheader.numxsectors); - } - else - { - memset(&xheader, 0, 128); - } - gSkyCount = 1 << mapHeader.pskybits; - fr.Read(tpskyoff, gSkyCount * sizeof(tpskyoff[0])); - if (encrypted) - { - dbCrypt((char*)tpskyoff, gSkyCount * sizeof(tpskyoff[0]), gSkyCount * 2); - } + xheader.numxsprites = LittleLong(xheader.numxsprites); + xheader.numxwalls = LittleLong(xheader.numxwalls); + xheader.numxsectors = LittleLong(xheader.numxsectors); + } + else + { + memset(&xheader, 0, 128); + } + gSkyCount = 1 << mapHeader.pskybits; + fr.Read(tpskyoff, gSkyCount * sizeof(tpskyoff[0])); + if (encrypted) + { + dbCrypt((char*)tpskyoff, gSkyCount * sizeof(tpskyoff[0]), gSkyCount * 2); + } - psky_t* pSky = tileSetupSky(DEFAULTPSKY); - pSky->horizfrac = 65536; - pSky->lognumtiles = mapHeader.pskybits; - for (int i = 0; i < ClipHigh(gSkyCount, MAXPSKYTILES); i++) - { - pSky->tileofs[i] = LittleShort(tpskyoff[i]); - } + psky_t* pSky = tileSetupSky(DEFAULTPSKY); + pSky->horizfrac = 65536; + pSky->lognumtiles = mapHeader.pskybits; + for (int i = 0; i < ClipHigh(gSkyCount, MAXPSKYTILES); i++) + { + pSky->tileofs[i] = LittleShort(tpskyoff[i]); + } - for (unsigned i = 0; i < sector.Size(); i++) - { - sectortype* pSector = §or[i]; - sectortypedisk load; - fr.Read(&load, sizeof(sectortypedisk)); - if (encrypted) - { - dbCrypt((char*)&load, sizeof(sectortypedisk), gMapRev * sizeof(sectortypedisk)); - } - pSector->wallptr = LittleShort(load.wallptr); - pSector->wallnum = LittleShort(load.wallnum); - pSector->setceilingz(LittleLong(load.ceilingz), true); - pSector->setfloorz(LittleLong(load.floorz), true); - pSector->ceilingstat = ESectorFlags::FromInt(LittleShort(load.ceilingstat)); - pSector->floorstat = ESectorFlags::FromInt(LittleShort(load.floorstat)); - pSector->ceilingpicnum = LittleShort(load.ceilingpicnum); - pSector->ceilingheinum = LittleShort(load.ceilingheinum); - pSector->floorpicnum = LittleShort(load.floorpicnum); - pSector->floorheinum = LittleShort(load.floorheinum); - pSector->type = LittleShort(load.type); - pSector->hitag = LittleShort(load.hitag); - pSector->extra = LittleShort(load.extra); - pSector->ceilingshade = load.ceilingshade; - pSector->ceilingpal = load.ceilingpal; - pSector->ceilingxpan_ = load.ceilingxpanning; - pSector->ceilingypan_ = load.ceilingypanning; - pSector->floorshade = load.floorshade; - pSector->floorpal = load.floorpal; - pSector->floorxpan_ = load.floorxpanning; - pSector->floorypan_ = load.floorypanning; - pSector->visibility = load.visibility; - pSector->slopewallofs = load.fogpal; - pSector->dirty = EDirty::AllDirty; - pSector->exflags = 0; - pSector->fogpal = 0; + for (unsigned i = 0; i < sector.Size(); i++) + { + sectortype* pSector = §or[i]; + sectortypedisk load; + fr.Read(&load, sizeof(sectortypedisk)); + if (encrypted) + { + dbCrypt((char*)&load, sizeof(sectortypedisk), gMapRev * sizeof(sectortypedisk)); + } + pSector->wallptr = LittleShort(load.wallptr); + pSector->wallnum = LittleShort(load.wallnum); + pSector->setceilingz(LittleLong(load.ceilingz), true); + pSector->setfloorz(LittleLong(load.floorz), true); + pSector->ceilingstat = ESectorFlags::FromInt(LittleShort(load.ceilingstat)); + pSector->floorstat = ESectorFlags::FromInt(LittleShort(load.floorstat)); + pSector->ceilingpicnum = LittleShort(load.ceilingpicnum); + pSector->ceilingheinum = LittleShort(load.ceilingheinum); + pSector->floorpicnum = LittleShort(load.floorpicnum); + pSector->floorheinum = LittleShort(load.floorheinum); + pSector->type = LittleShort(load.type); + pSector->hitag = LittleShort(load.hitag); + pSector->extra = LittleShort(load.extra); + pSector->ceilingshade = load.ceilingshade; + pSector->ceilingpal = load.ceilingpal; + pSector->ceilingxpan_ = load.ceilingxpanning; + pSector->ceilingypan_ = load.ceilingypanning; + pSector->floorshade = load.floorshade; + pSector->floorpal = load.floorpal; + pSector->floorxpan_ = load.floorxpanning; + pSector->floorypan_ = load.floorypanning; + pSector->visibility = load.visibility; + pSector->slopewallofs = load.fogpal; + pSector->dirty = EDirty::AllDirty; + pSector->exflags = 0; + pSector->fogpal = 0; - if (pSector->extra > 0) - { - char pBuffer[nXSectorSize]; - pSector->allocX(); - XSECTOR* pXSector = &pSector->xs(); - int nCount; - if (!encrypted) - { - nCount = nXSectorSize; - } - else - { - nCount = xheader.numxsectors; - } - assert(nCount <= nXSectorSize); - fr.Read(pBuffer, nCount); - BitReader bitReader(pBuffer, nCount); - /*pXSector->reference =*/ bitReader.readSigned(14); - pXSector->state = bitReader.readUnsigned(1); - pXSector->busy = bitReader.readUnsigned(17); - pXSector->data = bitReader.readUnsigned(16); - pXSector->txID = bitReader.readUnsigned(10); - pXSector->busyWaveA = bitReader.readUnsigned(3); - pXSector->busyWaveB = bitReader.readUnsigned(3); - pXSector->rxID = bitReader.readUnsigned(10); - pXSector->command = bitReader.readUnsigned(8); - pXSector->triggerOn = bitReader.readUnsigned(1); - pXSector->triggerOff = bitReader.readUnsigned(1); - pXSector->busyTimeA = bitReader.readUnsigned(12); - pXSector->waitTimeA = bitReader.readUnsigned(12); - pXSector->restState = bitReader.readUnsigned(1); - pXSector->interruptable = bitReader.readUnsigned(1); - pXSector->amplitude = bitReader.readSigned(8); - pXSector->freq = bitReader.readUnsigned(8); - pXSector->reTriggerA = bitReader.readUnsigned(1); - pXSector->reTriggerB = bitReader.readUnsigned(1); - pXSector->phase = bitReader.readUnsigned(8); - pXSector->wave = bitReader.readUnsigned(4); - pXSector->shadeAlways = bitReader.readUnsigned(1); - pXSector->shadeFloor = bitReader.readUnsigned(1); - pXSector->shadeCeiling = bitReader.readUnsigned(1); - pXSector->shadeWalls = bitReader.readUnsigned(1); - pXSector->shade = bitReader.readSigned(8); - pXSector->panAlways = bitReader.readUnsigned(1); - pXSector->panFloor = bitReader.readUnsigned(1); - pXSector->panCeiling = bitReader.readUnsigned(1); - pXSector->Drag = bitReader.readUnsigned(1); - pXSector->Underwater = bitReader.readUnsigned(1); - pXSector->Depth = bitReader.readUnsigned(3); - pXSector->panVel = bitReader.readUnsigned(8); - pXSector->panAngle = bitReader.readUnsigned(11); - pXSector->unused1 = bitReader.readUnsigned(1); - pXSector->decoupled = bitReader.readUnsigned(1); - pXSector->triggerOnce = bitReader.readUnsigned(1); - pXSector->isTriggered = bitReader.readUnsigned(1); - pXSector->Key = bitReader.readUnsigned(3); - pXSector->Push = bitReader.readUnsigned(1); - pXSector->Vector = bitReader.readUnsigned(1); - pXSector->Reserved = bitReader.readUnsigned(1); - pXSector->Enter = bitReader.readUnsigned(1); - pXSector->Exit = bitReader.readUnsigned(1); - pXSector->Wallpush = bitReader.readUnsigned(1); - pXSector->color = bitReader.readUnsigned(1); - /*pXSector->unused2 =*/ bitReader.readUnsigned(1); - pXSector->busyTimeB = bitReader.readUnsigned(12); - pXSector->waitTimeB = bitReader.readUnsigned(12); - pXSector->stopOn = bitReader.readUnsigned(1); - pXSector->stopOff = bitReader.readUnsigned(1); - pXSector->ceilpal = bitReader.readUnsigned(4); - pXSector->offCeilZ = bitReader.readSigned(32); - pXSector->onCeilZ = bitReader.readSigned(32); - pXSector->offFloorZ = bitReader.readSigned(32); - pXSector->onFloorZ = bitReader.readSigned(32); - /*pXSector->marker0 =*/ bitReader.readUnsigned(16); - /*pXSector->marker1 =*/ bitReader.readUnsigned(16); - pXSector->Crush = bitReader.readUnsigned(1); - pSector->ceilingxpan_ += bitReader.readUnsigned(8) / 256.f; - pSector->ceilingypan_ += bitReader.readUnsigned(8) / 256.f; - pSector->floorxpan_ += bitReader.readUnsigned(8) / 256.f; - pXSector->damageType = bitReader.readUnsigned(3); - pXSector->floorpal = bitReader.readUnsigned(4); - pSector->floorypan_ += bitReader.readUnsigned(8) / 256.f; - pXSector->locked = bitReader.readUnsigned(1); - pXSector->windVel = bitReader.readUnsigned(10); - pXSector->windAng = bitReader.readUnsigned(11); - pXSector->windAlways = bitReader.readUnsigned(1); - pXSector->dudeLockout = bitReader.readUnsigned(1); - pXSector->bobTheta = bitReader.readUnsigned(11); - pXSector->bobZRange = bitReader.readUnsigned(5); - pXSector->bobSpeed = bitReader.readSigned(12); - pXSector->bobAlways = bitReader.readUnsigned(1); - pXSector->bobFloor = bitReader.readUnsigned(1); - pXSector->bobCeiling = bitReader.readUnsigned(1); - pXSector->bobRotate = bitReader.readUnsigned(1); - pXSector->busy = IntToFixed(pXSector->state); + if (pSector->extra > 0) + { + char pBuffer[nXSectorSize]; + pSector->allocX(); + XSECTOR* pXSector = &pSector->xs(); + int nCount; + if (!encrypted) + { + nCount = nXSectorSize; + } + else + { + nCount = xheader.numxsectors; + } + assert(nCount <= nXSectorSize); + fr.Read(pBuffer, nCount); + BitReader bitReader(pBuffer, nCount); + /*pXSector->reference =*/ bitReader.readSigned(14); + pXSector->state = bitReader.readUnsigned(1); + pXSector->busy = bitReader.readUnsigned(17); + pXSector->data = bitReader.readUnsigned(16); + pXSector->txID = bitReader.readUnsigned(10); + pXSector->busyWaveA = bitReader.readUnsigned(3); + pXSector->busyWaveB = bitReader.readUnsigned(3); + pXSector->rxID = bitReader.readUnsigned(10); + pXSector->command = bitReader.readUnsigned(8); + pXSector->triggerOn = bitReader.readUnsigned(1); + pXSector->triggerOff = bitReader.readUnsigned(1); + pXSector->busyTimeA = bitReader.readUnsigned(12); + pXSector->waitTimeA = bitReader.readUnsigned(12); + pXSector->restState = bitReader.readUnsigned(1); + pXSector->interruptable = bitReader.readUnsigned(1); + pXSector->amplitude = bitReader.readSigned(8); + pXSector->freq = bitReader.readUnsigned(8); + pXSector->reTriggerA = bitReader.readUnsigned(1); + pXSector->reTriggerB = bitReader.readUnsigned(1); + pXSector->phase = bitReader.readUnsigned(8); + pXSector->wave = bitReader.readUnsigned(4); + pXSector->shadeAlways = bitReader.readUnsigned(1); + pXSector->shadeFloor = bitReader.readUnsigned(1); + pXSector->shadeCeiling = bitReader.readUnsigned(1); + pXSector->shadeWalls = bitReader.readUnsigned(1); + pXSector->shade = bitReader.readSigned(8); + pXSector->panAlways = bitReader.readUnsigned(1); + pXSector->panFloor = bitReader.readUnsigned(1); + pXSector->panCeiling = bitReader.readUnsigned(1); + pXSector->Drag = bitReader.readUnsigned(1); + pXSector->Underwater = bitReader.readUnsigned(1); + pXSector->Depth = bitReader.readUnsigned(3); + pXSector->panVel = bitReader.readUnsigned(8); + pXSector->panAngle = bitReader.readUnsigned(11); + pXSector->unused1 = bitReader.readUnsigned(1); + pXSector->decoupled = bitReader.readUnsigned(1); + pXSector->triggerOnce = bitReader.readUnsigned(1); + pXSector->isTriggered = bitReader.readUnsigned(1); + pXSector->Key = bitReader.readUnsigned(3); + pXSector->Push = bitReader.readUnsigned(1); + pXSector->Vector = bitReader.readUnsigned(1); + pXSector->Reserved = bitReader.readUnsigned(1); + pXSector->Enter = bitReader.readUnsigned(1); + pXSector->Exit = bitReader.readUnsigned(1); + pXSector->Wallpush = bitReader.readUnsigned(1); + pXSector->color = bitReader.readUnsigned(1); + /*pXSector->unused2 =*/ bitReader.readUnsigned(1); + pXSector->busyTimeB = bitReader.readUnsigned(12); + pXSector->waitTimeB = bitReader.readUnsigned(12); + pXSector->stopOn = bitReader.readUnsigned(1); + pXSector->stopOff = bitReader.readUnsigned(1); + pXSector->ceilpal = bitReader.readUnsigned(4); + pXSector->offCeilZ = bitReader.readSigned(32); + pXSector->onCeilZ = bitReader.readSigned(32); + pXSector->offFloorZ = bitReader.readSigned(32); + pXSector->onFloorZ = bitReader.readSigned(32); + /*pXSector->marker0 =*/ bitReader.readUnsigned(16); + /*pXSector->marker1 =*/ bitReader.readUnsigned(16); + pXSector->Crush = bitReader.readUnsigned(1); + pSector->ceilingxpan_ += bitReader.readUnsigned(8) / 256.f; + pSector->ceilingypan_ += bitReader.readUnsigned(8) / 256.f; + pSector->floorxpan_ += bitReader.readUnsigned(8) / 256.f; + pXSector->damageType = bitReader.readUnsigned(3); + pXSector->floorpal = bitReader.readUnsigned(4); + pSector->floorypan_ += bitReader.readUnsigned(8) / 256.f; + pXSector->locked = bitReader.readUnsigned(1); + pXSector->windVel = bitReader.readUnsigned(10); + pXSector->windAng = bitReader.readUnsigned(11); + pXSector->windAlways = bitReader.readUnsigned(1); + pXSector->dudeLockout = bitReader.readUnsigned(1); + pXSector->bobTheta = bitReader.readUnsigned(11); + pXSector->bobZRange = bitReader.readUnsigned(5); + pXSector->bobSpeed = bitReader.readSigned(12); + pXSector->bobAlways = bitReader.readUnsigned(1); + pXSector->bobFloor = bitReader.readUnsigned(1); + pXSector->bobCeiling = bitReader.readUnsigned(1); + pXSector->bobRotate = bitReader.readUnsigned(1); + pXSector->busy = IntToFixed(pXSector->state); - } - } - for (unsigned i = 0; i < wall.Size(); i++) - { - walltype* pWall = &wall[i]; - walltypedisk load; - fr.Read(&load, sizeof(walltypedisk)); - if (encrypted) - { - dbCrypt((char*)&load, sizeof(walltypedisk), (gMapRev * sizeof(sectortypedisk)) | 0x7474614d); - } - pWall->pos.X = LittleLong(load.x); - pWall->pos.Y = LittleLong(load.y); - pWall->point2 = LittleShort(load.point2); - pWall->nextwall = LittleShort(load.nextwall); - pWall->nextsector = LittleShort(load.nextsector); - pWall->cstat = EWallFlags::FromInt(LittleShort(load.cstat)); - pWall->picnum = EWallFlags::FromInt(LittleShort(load.picnum)); - pWall->overpicnum = LittleShort(load.overpicnum); - pWall->type = LittleShort(load.type); - pWall->hitag = LittleShort(load.hitag); - pWall->extra = LittleShort(load.extra); - pWall->shade = load.shade; - pWall->pal = load.pal; - pWall->xrepeat = load.xrepeat; - pWall->xpan_ = load.xpanning; - pWall->yrepeat = load.yrepeat; - pWall->ypan_ = load.ypanning; + } + } + for (unsigned i = 0; i < wall.Size(); i++) + { + walltype* pWall = &wall[i]; + walltypedisk load; + fr.Read(&load, sizeof(walltypedisk)); + if (encrypted) + { + dbCrypt((char*)&load, sizeof(walltypedisk), (gMapRev * sizeof(sectortypedisk)) | 0x7474614d); + } + pWall->pos.X = LittleLong(load.x); + pWall->pos.Y = LittleLong(load.y); + pWall->point2 = LittleShort(load.point2); + pWall->nextwall = LittleShort(load.nextwall); + pWall->nextsector = LittleShort(load.nextsector); + pWall->cstat = EWallFlags::FromInt(LittleShort(load.cstat)); + pWall->picnum = EWallFlags::FromInt(LittleShort(load.picnum)); + pWall->overpicnum = LittleShort(load.overpicnum); + pWall->type = LittleShort(load.type); + pWall->hitag = LittleShort(load.hitag); + pWall->extra = LittleShort(load.extra); + pWall->shade = load.shade; + pWall->pal = load.pal; + pWall->xrepeat = load.xrepeat; + pWall->xpan_ = load.xpanning; + pWall->yrepeat = load.yrepeat; + pWall->ypan_ = load.ypanning; - if (pWall->extra > 0) - { - char pBuffer[nXWallSize]; - pWall->allocX(); - XWALL* pXWall = &pWall->xw(); - int nCount; - if (!encrypted) - { - nCount = nXWallSize; - } - else - { - nCount = xheader.numxwalls; - } - assert(nCount <= nXWallSize); - fr.Read(pBuffer, nCount); - BitReader bitReader(pBuffer, nCount); - /*pXWall->reference =*/ bitReader.readSigned(14); - pXWall->state = bitReader.readUnsigned(1); - pXWall->busy = bitReader.readUnsigned(17); - pXWall->data = bitReader.readSigned(16); - pXWall->txID = bitReader.readUnsigned(10); - bitReader.readUnsigned(6); - pXWall->rxID = bitReader.readUnsigned(10); - pXWall->command = bitReader.readUnsigned(8); - pXWall->triggerOn = bitReader.readUnsigned(1); - pXWall->triggerOff = bitReader.readUnsigned(1); - pXWall->busyTime = bitReader.readUnsigned(12); - pXWall->waitTime = bitReader.readUnsigned(12); - pXWall->restState = bitReader.readUnsigned(1); - pXWall->interruptable = bitReader.readUnsigned(1); - pXWall->panAlways = bitReader.readUnsigned(1); - pXWall->panXVel = bitReader.readSigned(8); - pXWall->panYVel = bitReader.readSigned(8); - pXWall->decoupled = bitReader.readUnsigned(1); - pXWall->triggerOnce = bitReader.readUnsigned(1); - pXWall->isTriggered = bitReader.readUnsigned(1); - pXWall->key = bitReader.readUnsigned(3); - pXWall->triggerPush = bitReader.readUnsigned(1); - pXWall->triggerVector = bitReader.readUnsigned(1); - pXWall->triggerTouch = bitReader.readUnsigned(1); - bitReader.readUnsigned(2); - pWall->xpan_ += bitReader.readUnsigned(8) / 256.f; - pWall->ypan_ += bitReader.readUnsigned(8) / 256.f; - pXWall->locked = bitReader.readUnsigned(1); - pXWall->dudeLockout = bitReader.readUnsigned(1); - bitReader.readUnsigned(4); - bitReader.readUnsigned(32); - pXWall->busy = IntToFixed(pXWall->state); + if (pWall->extra > 0) + { + char pBuffer[nXWallSize]; + pWall->allocX(); + XWALL* pXWall = &pWall->xw(); + int nCount; + if (!encrypted) + { + nCount = nXWallSize; + } + else + { + nCount = xheader.numxwalls; + } + assert(nCount <= nXWallSize); + fr.Read(pBuffer, nCount); + BitReader bitReader(pBuffer, nCount); + /*pXWall->reference =*/ bitReader.readSigned(14); + pXWall->state = bitReader.readUnsigned(1); + pXWall->busy = bitReader.readUnsigned(17); + pXWall->data = bitReader.readSigned(16); + pXWall->txID = bitReader.readUnsigned(10); + bitReader.readUnsigned(6); + pXWall->rxID = bitReader.readUnsigned(10); + pXWall->command = bitReader.readUnsigned(8); + pXWall->triggerOn = bitReader.readUnsigned(1); + pXWall->triggerOff = bitReader.readUnsigned(1); + pXWall->busyTime = bitReader.readUnsigned(12); + pXWall->waitTime = bitReader.readUnsigned(12); + pXWall->restState = bitReader.readUnsigned(1); + pXWall->interruptable = bitReader.readUnsigned(1); + pXWall->panAlways = bitReader.readUnsigned(1); + pXWall->panXVel = bitReader.readSigned(8); + pXWall->panYVel = bitReader.readSigned(8); + pXWall->decoupled = bitReader.readUnsigned(1); + pXWall->triggerOnce = bitReader.readUnsigned(1); + pXWall->isTriggered = bitReader.readUnsigned(1); + pXWall->key = bitReader.readUnsigned(3); + pXWall->triggerPush = bitReader.readUnsigned(1); + pXWall->triggerVector = bitReader.readUnsigned(1); + pXWall->triggerTouch = bitReader.readUnsigned(1); + bitReader.readUnsigned(2); + pWall->xpan_ += bitReader.readUnsigned(8) / 256.f; + pWall->ypan_ += bitReader.readUnsigned(8) / 256.f; + pXWall->locked = bitReader.readUnsigned(1); + pXWall->dudeLockout = bitReader.readUnsigned(1); + bitReader.readUnsigned(4); + bitReader.readUnsigned(32); + pXWall->busy = IntToFixed(pXWall->state); - } - } - leveltimer = mapHeader.numsprites; - sprites.sprites.Resize(mapHeader.numsprites); - sprites.xspr.Resize(mapHeader.numsprites); - for (int i = 0; i < mapHeader.numsprites; i++) - { - spritetypedisk load; - fr.Read(&load, sizeof(spritetypedisk)); - if (encrypted) // What were these people thinking? :( - { - dbCrypt((char*)&load, sizeof(spritetypedisk), (gMapRev * sizeof(spritetypedisk)) | 0x7474614d); - } - auto pSprite = &sprites.sprites[i]; - pSprite->clear(); - pSprite->pos.X = LittleLong(load.x); - pSprite->pos.Y = LittleLong(load.y); - pSprite->pos.Z = LittleLong(load.z); - pSprite->cstat = ESpriteFlags::FromInt(LittleShort(load.cstat)); - pSprite->picnum = LittleShort(load.picnum); - int secno = LittleShort(load.sectnum); - pSprite->statnum = LittleShort(load.statnum); - pSprite->ang = LittleShort(load.ang); - pSprite->owner = LittleShort(load.owner); - pSprite->xvel = LittleShort(load.index); - pSprite->yvel = LittleShort(load.yvel); - pSprite->inittype = LittleShort(load.inittype); - pSprite->type = LittleShort(load.type); - pSprite->flags = LittleShort(load.hitag); - pSprite->extra = LittleShort(load.extra); - pSprite->pal = load.pal; - pSprite->clipdist = load.clipdist; - pSprite->xrepeat = load.xrepeat; - pSprite->yrepeat = load.yrepeat; - pSprite->xoffset = load.xoffset; - pSprite->yoffset = load.yoffset; - pSprite->detail = load.detail; - pSprite->shade = load.shade; - pSprite->blend = 0; - pSprite->time = i; - validateSprite(*pSprite, secno, i); + } + } + leveltimer = mapHeader.numsprites; + sprites.sprites.Resize(mapHeader.numsprites); + sprites.xspr.Resize(mapHeader.numsprites); + for (int i = 0; i < mapHeader.numsprites; i++) + { + spritetypedisk load; + fr.Read(&load, sizeof(spritetypedisk)); + if (encrypted) // What were these people thinking? :( + { + dbCrypt((char*)&load, sizeof(spritetypedisk), (gMapRev * sizeof(spritetypedisk)) | 0x7474614d); + } + auto pSprite = &sprites.sprites[i]; + pSprite->clear(); + pSprite->pos.X = LittleLong(load.x); + pSprite->pos.Y = LittleLong(load.y); + pSprite->pos.Z = LittleLong(load.z); + pSprite->cstat = ESpriteFlags::FromInt(LittleShort(load.cstat)); + pSprite->picnum = LittleShort(load.picnum); + int secno = LittleShort(load.sectnum); + pSprite->statnum = LittleShort(load.statnum); + pSprite->ang = LittleShort(load.ang); + pSprite->owner = LittleShort(load.owner); + pSprite->xvel = LittleShort(load.index); + pSprite->yvel = LittleShort(load.yvel); + pSprite->inittype = LittleShort(load.inittype); + pSprite->type = LittleShort(load.type); + pSprite->flags = LittleShort(load.hitag); + pSprite->extra = LittleShort(load.extra); + pSprite->pal = load.pal; + pSprite->clipdist = load.clipdist; + pSprite->xrepeat = load.xrepeat; + pSprite->yrepeat = load.yrepeat; + pSprite->xoffset = load.xoffset; + pSprite->yoffset = load.yoffset; + pSprite->detail = load.detail; + pSprite->shade = load.shade; + pSprite->blend = 0; + pSprite->time = i; + validateSprite(*pSprite, secno, i); - if (pSprite->extra > 0) - { - char pBuffer[nXSpriteSize]; - XSPRITE* pXSprite = &sprites.xspr[i]; - *pXSprite = {}; - int nCount; - if (!encrypted) - { - nCount = nXSpriteSize; - } - else - { - nCount = xheader.numxsprites; - } - assert(nCount <= nXSpriteSize); - fr.Read(pBuffer, nCount); - BitReader bitReader(pBuffer, nCount); - /*pXSprite->reference =*/ bitReader.readSigned(14); - pXSprite->state = bitReader.readUnsigned(1); - pXSprite->busy = bitReader.readUnsigned(17); - pXSprite->txID = bitReader.readUnsigned(10); - pXSprite->rxID = bitReader.readUnsigned(10); - pXSprite->command = bitReader.readUnsigned(8); - pXSprite->triggerOn = bitReader.readUnsigned(1); - pXSprite->triggerOff = bitReader.readUnsigned(1); - pXSprite->wave = bitReader.readUnsigned(2); - pXSprite->busyTime = bitReader.readUnsigned(12); - pXSprite->waitTime = bitReader.readUnsigned(12); - pXSprite->restState = bitReader.readUnsigned(1); - pXSprite->Interrutable = bitReader.readUnsigned(1); - pXSprite->unused1 = bitReader.readUnsigned(2); - pXSprite->respawnPending = bitReader.readUnsigned(2); - pXSprite->unused2 = bitReader.readUnsigned(1); - pXSprite->lT = bitReader.readUnsigned(1); - pXSprite->dropMsg = bitReader.readUnsigned(8); - pXSprite->Decoupled = bitReader.readUnsigned(1); - pXSprite->triggerOnce = bitReader.readUnsigned(1); - pXSprite->isTriggered = bitReader.readUnsigned(1); - pXSprite->key = bitReader.readUnsigned(3); - pXSprite->Push = bitReader.readUnsigned(1); - pXSprite->Vector = bitReader.readUnsigned(1); - pXSprite->Impact = bitReader.readUnsigned(1); - pXSprite->Pickup = bitReader.readUnsigned(1); - pXSprite->Touch = bitReader.readUnsigned(1); - pXSprite->Sight = bitReader.readUnsigned(1); - pXSprite->Proximity = bitReader.readUnsigned(1); - pXSprite->unused3 = bitReader.readUnsigned(2); - pXSprite->lSkill = bitReader.readUnsigned(5); - pXSprite->lS = bitReader.readUnsigned(1); - pXSprite->lB = bitReader.readUnsigned(1); - pXSprite->lC = bitReader.readUnsigned(1); - pXSprite->DudeLockout = bitReader.readUnsigned(1); - pXSprite->data1 = bitReader.readSigned(16); - pXSprite->data2 = bitReader.readSigned(16); - pXSprite->data3 = bitReader.readSigned(16); - pXSprite->goalAng = bitReader.readUnsigned(11); - pXSprite->dodgeDir = bitReader.readSigned(2); - pXSprite->locked = bitReader.readUnsigned(1); - pXSprite->medium = bitReader.readUnsigned(2); - pXSprite->respawn = bitReader.readUnsigned(2); - pXSprite->data4 = bitReader.readUnsigned(16); - pXSprite->unused4 = bitReader.readUnsigned(6); - pXSprite->lockMsg = bitReader.readUnsigned(8); - pXSprite->health = bitReader.readUnsigned(12); - pXSprite->dudeDeaf = bitReader.readUnsigned(1); - pXSprite->dudeAmbush = bitReader.readUnsigned(1); - pXSprite->dudeGuard = bitReader.readUnsigned(1); - pXSprite->dudeFlag4 = bitReader.readUnsigned(1); - /*pXSprite->target_i = */ bitReader.readSigned(16); - pXSprite->targetX = bitReader.readSigned(32); - pXSprite->targetY = bitReader.readSigned(32); - pXSprite->targetZ = bitReader.readSigned(32); - pXSprite->burnTime = bitReader.readUnsigned(16); - /*pXSprite->burnSource =*/ bitReader.readSigned(16); - pXSprite->height = bitReader.readUnsigned(16); - pXSprite->stateTimer = bitReader.readUnsigned(16); - pXSprite->aiState = NULL; - bitReader.skipBits(32); - pXSprite->busy = IntToFixed(pXSprite->state); - if (!encrypted) { - pXSprite->lT |= pXSprite->lB; - } + if (pSprite->extra > 0) + { + char pBuffer[nXSpriteSize]; + XSPRITE* pXSprite = &sprites.xspr[i]; + *pXSprite = {}; + int nCount; + if (!encrypted) + { + nCount = nXSpriteSize; + } + else + { + nCount = xheader.numxsprites; + } + assert(nCount <= nXSpriteSize); + fr.Read(pBuffer, nCount); + BitReader bitReader(pBuffer, nCount); + /*pXSprite->reference =*/ bitReader.readSigned(14); + pXSprite->state = bitReader.readUnsigned(1); + pXSprite->busy = bitReader.readUnsigned(17); + pXSprite->txID = bitReader.readUnsigned(10); + pXSprite->rxID = bitReader.readUnsigned(10); + pXSprite->command = bitReader.readUnsigned(8); + pXSprite->triggerOn = bitReader.readUnsigned(1); + pXSprite->triggerOff = bitReader.readUnsigned(1); + pXSprite->wave = bitReader.readUnsigned(2); + pXSprite->busyTime = bitReader.readUnsigned(12); + pXSprite->waitTime = bitReader.readUnsigned(12); + pXSprite->restState = bitReader.readUnsigned(1); + pXSprite->Interrutable = bitReader.readUnsigned(1); + pXSprite->unused1 = bitReader.readUnsigned(2); + pXSprite->respawnPending = bitReader.readUnsigned(2); + pXSprite->unused2 = bitReader.readUnsigned(1); + pXSprite->lT = bitReader.readUnsigned(1); + pXSprite->dropMsg = bitReader.readUnsigned(8); + pXSprite->Decoupled = bitReader.readUnsigned(1); + pXSprite->triggerOnce = bitReader.readUnsigned(1); + pXSprite->isTriggered = bitReader.readUnsigned(1); + pXSprite->key = bitReader.readUnsigned(3); + pXSprite->Push = bitReader.readUnsigned(1); + pXSprite->Vector = bitReader.readUnsigned(1); + pXSprite->Impact = bitReader.readUnsigned(1); + pXSprite->Pickup = bitReader.readUnsigned(1); + pXSprite->Touch = bitReader.readUnsigned(1); + pXSprite->Sight = bitReader.readUnsigned(1); + pXSprite->Proximity = bitReader.readUnsigned(1); + pXSprite->unused3 = bitReader.readUnsigned(2); + pXSprite->lSkill = bitReader.readUnsigned(5); + pXSprite->lS = bitReader.readUnsigned(1); + pXSprite->lB = bitReader.readUnsigned(1); + pXSprite->lC = bitReader.readUnsigned(1); + pXSprite->DudeLockout = bitReader.readUnsigned(1); + pXSprite->data1 = bitReader.readSigned(16); + pXSprite->data2 = bitReader.readSigned(16); + pXSprite->data3 = bitReader.readSigned(16); + pXSprite->goalAng = bitReader.readUnsigned(11); + pXSprite->dodgeDir = bitReader.readSigned(2); + pXSprite->locked = bitReader.readUnsigned(1); + pXSprite->medium = bitReader.readUnsigned(2); + pXSprite->respawn = bitReader.readUnsigned(2); + pXSprite->data4 = bitReader.readUnsigned(16); + pXSprite->unused4 = bitReader.readUnsigned(6); + pXSprite->lockMsg = bitReader.readUnsigned(8); + pXSprite->health = bitReader.readUnsigned(12); + pXSprite->dudeDeaf = bitReader.readUnsigned(1); + pXSprite->dudeAmbush = bitReader.readUnsigned(1); + pXSprite->dudeGuard = bitReader.readUnsigned(1); + pXSprite->dudeFlag4 = bitReader.readUnsigned(1); + /*pXSprite->target_i = */ bitReader.readSigned(16); + pXSprite->targetX = bitReader.readSigned(32); + pXSprite->targetY = bitReader.readSigned(32); + pXSprite->targetZ = bitReader.readSigned(32); + pXSprite->burnTime = bitReader.readUnsigned(16); + /*pXSprite->burnSource =*/ bitReader.readSigned(16); + pXSprite->height = bitReader.readUnsigned(16); + pXSprite->stateTimer = bitReader.readUnsigned(16); + pXSprite->aiState = NULL; + bitReader.skipBits(32); + pXSprite->busy = IntToFixed(pXSprite->state); + if (!encrypted) { + pXSprite->lT |= pXSprite->lB; + } #ifdef NOONE_EXTENSIONS - // indicate if the map requires modern features to work properly - // for maps wich created in different editors (include vanilla MAPEDIT) or in PMAPEDIT version below than BETA13 - if (!gModernMap && pXSprite->rxID == kChannelMapModernize && pXSprite->rxID == pXSprite->txID && pXSprite->command == kCmdModernFeaturesEnable) - gModernMap = true; + // indicate if the map requires modern features to work properly + // for maps wich created in different editors (include vanilla MAPEDIT) or in PMAPEDIT version below than BETA13 + if (!gModernMap && pXSprite->rxID == kChannelMapModernize && pXSprite->rxID == pXSprite->txID && pXSprite->command == kCmdModernFeaturesEnable) + gModernMap = true; #endif - } - } - fixSectors(); - - unsigned int nCRC = fr.ReadUInt32(); + } + } + fixSectors(); - fr.Seek(0, FileReader::SeekSet); - auto buffer = fr.Read(); - uint8_t md4[16]; - md4once(buffer.Data(), buffer.Size(), md4); - loadMapHack(mapname, md4, sprites); + unsigned int nCRC = fr.ReadUInt32(); - if (CalcCRC32(buffer.Data(), buffer.Size() - 4) != nCRC) - { - I_Error("%s: Map File does not match CRC", mapname.GetChars()); - } - if (pCRC) - *pCRC = nCRC; - if (encrypted) - { - if (!(gMattId == 0x7474614d || gMattId == 0x4d617474 || !gMattId)) - { - I_Error("%s: Corrupted Map file", mapname.GetChars()); - } - } - else if (gMattId != 0) - { - I_Error("%s: Corrupted Map file", mapname.GetChars()); - } + fr.Seek(0, FileReader::SeekSet); + auto buffer = fr.Read(); + uint8_t md4[16]; + md4once(buffer.Data(), buffer.Size(), md4); + loadMapHack(mapname, md4, sprites); - if ((header.version & 0xff00) == 0x600) - { - switch (header.version & 0xff) - { - case 0: - for (auto& sect: sector) - { - sectortype* pSector = § - if (pSector->hasX()) - { - XSECTOR* pXSector = &pSector->xs(); - pXSector->busyTimeB = pXSector->busyTimeA; - if (pXSector->busyTimeA > 0) - { - if (!pXSector->restState) - { - pXSector->reTriggerA = 1; - } - else - { - pXSector->waitTimeB = pXSector->busyTimeA; - pXSector->waitTimeA = 0; - pXSector->reTriggerB = 1; - } - } - } - } - [[fallthrough]]; - case 1: - for (auto& sect: sector) - { - sectortype* pSector = § - if (pSector->hasX()) - { - XSECTOR* pXSector = &pSector->xs(); - pXSector->freq >>= 1; - } - } - [[fallthrough]]; - case 2: - break; + if (CalcCRC32(buffer.Data(), buffer.Size() - 4) != nCRC) + { + I_Error("%s: Map File does not match CRC", mapname.GetChars()); + } + if (pCRC) + *pCRC = nCRC; + if (encrypted) + { + if (!(gMattId == 0x7474614d || gMattId == 0x4d617474 || !gMattId)) + { + I_Error("%s: Corrupted Map file", mapname.GetChars()); + } + } + else if (gMattId != 0) + { + I_Error("%s: Corrupted Map file", mapname.GetChars()); + } - } - } + if ((header.version & 0xff00) == 0x600) + { + switch (header.version & 0xff) + { + case 0: + for (auto& sect : sector) + { + sectortype* pSector = § + if (pSector->hasX()) + { + XSECTOR* pXSector = &pSector->xs(); + pXSector->busyTimeB = pXSector->busyTimeA; + if (pXSector->busyTimeA > 0) + { + if (!pXSector->restState) + { + pXSector->reTriggerA = 1; + } + else + { + pXSector->waitTimeB = pXSector->busyTimeA; + pXSector->waitTimeA = 0; + pXSector->reTriggerB = 1; + } + } + } + } + [[fallthrough]]; + case 1: + for (auto& sect : sector) + { + sectortype* pSector = § + if (pSector->hasX()) + { + XSECTOR* pXSector = &pSector->xs(); + pXSector->freq >>= 1; + } + } + [[fallthrough]]; + case 2: + break; - setWallSectors(); - hw_CreateSections(); - sectionGeometry.SetSize(sections.Size()); - wallbackup = wall; - sectorbackup = sector; + } + } + + setWallSectors(); + hw_CreateSections(); + sectionGeometry.SetSize(sections.Size()); + wallbackup = wall; + sectorbackup = sector; } @@ -686,8 +686,7 @@ END_BLD_NS void qloadboard(const char* filename, char flags, vec3_t* dapos, int16_t* daang) { - Blood::BloodSpawnSpriteDef sprites; - sectortype* sp; - Blood::dbLoadMap(filename, &dapos->X, &dapos->Y, &dapos->Z, daang, &sp, nullptr, sprites); + Blood::BloodSpawnSpriteDef sprites; + sectortype* sp; + Blood::dbLoadMap(filename, &dapos->X, &dapos->Y, &dapos->Z, daang, &sp, nullptr, sprites); } - \ No newline at end of file diff --git a/source/games/blood/src/db.h b/source/games/blood/src/db.h index 6db212857..180610fd6 100644 --- a/source/games/blood/src/db.h +++ b/source/games/blood/src/db.h @@ -35,7 +35,7 @@ enum kAttrRespawn = 0x0010, kAttrFree = 0x0020, kAttrSmoke = 0x0100, // receives tsprite smoke/steam - }; +}; #pragma pack(push, 1) @@ -44,63 +44,63 @@ struct AISTATE; struct MAPSIGNATURE { - char signature[4]; - int16_t version; + char signature[4]; + int16_t version; }; -struct MAPHEADER { - int32_t x; // x - int32_t y; // y - int32_t z; // z - int16_t ang; // ang - int16_t sect; // sect - int16_t pskybits; // pskybits - int32_t visibility; // visibility - int32_t mattid; // song id, Matt - uint8_t parallax; // parallaxtype - int32_t revision; // map revision - int16_t numsectors; // numsectors - int16_t numwalls; // numwalls - int16_t numsprites; // numsprites +struct MAPHEADER { + int32_t x; // x + int32_t y; // y + int32_t z; // z + int16_t ang; // ang + int16_t sect; // sect + int16_t pskybits; // pskybits + int32_t visibility; // visibility + int32_t mattid; // song id, Matt + uint8_t parallax; // parallaxtype + int32_t revision; // map revision + int16_t numsectors; // numsectors + int16_t numwalls; // numwalls + int16_t numsprites; // numsprites }; struct MAPHEADER2 { - char name[64]; - int numxsprites; // xsprite size - int numxwalls; // xwall size - int numxsectors; // xsector size - uint8_t pad[52]; + char name[64]; + int numxsprites; // xsprite size + int numxwalls; // xwall size + int numxsectors; // xsector size + uint8_t pad[52]; }; #pragma pack(pop) extern int gVisibility; -extern const char *gItemText[]; -extern const char *gAmmoText[]; -extern const char *gWeaponText[]; +extern const char* gItemText[]; +extern const char* gAmmoText[]; +extern const char* gWeaponText[]; extern int gSkyCount; -void GetSpriteExtents(spritetypebase const * const pSprite, int *top, int *bottom) +void GetSpriteExtents(spritetypebase const* const pSprite, int* top, int* bottom) { - *top = *bottom = pSprite->pos.Z; - if ((pSprite->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) != CSTAT_SPRITE_ALIGNMENT_FLOOR) - { - int height = tileHeight(pSprite->picnum); - int center = height / 2 + tileTopOffset(pSprite->picnum); - *top -= (pSprite->yrepeat << 2)*center; - *bottom += (pSprite->yrepeat << 2)*(height - center); - } + *top = *bottom = pSprite->pos.Z; + if ((pSprite->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) != CSTAT_SPRITE_ALIGNMENT_FLOOR) + { + int height = tileHeight(pSprite->picnum); + int center = height / 2 + tileTopOffset(pSprite->picnum); + *top -= (pSprite->yrepeat << 2) * center; + *bottom += (pSprite->yrepeat << 2) * (height - center); + } } struct BloodSpawnSpriteDef : public SpawnSpriteDef { - TArray xspr; + TArray xspr; }; DBloodActor* InsertSprite(sectortype* pSector, int nStat); int DeleteSprite(DBloodActor* actor); -unsigned int dbReadMapCRC(const char *pPath); +unsigned int dbReadMapCRC(const char* pPath); void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, sectortype** pSector, unsigned int* pCRC, BloodSpawnSpriteDef& sprites); diff --git a/source/games/blood/src/dude.cpp b/source/games/blood/src/dude.cpp index 978a3cbcf..ab3a5ca19 100644 --- a/source/games/blood/src/dude.cpp +++ b/source/games/blood/src/dude.cpp @@ -27,1705 +27,1705 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS -DUDEINFO dudeInfo[kDudeMax-kDudeBase] = +DUDEINFO dudeInfo[kDudeMax - kDudeBase] = { - { - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 4096, //seqStartId - 40, // startHp - 70, // mass - 1200, // ??? - 48, // clipdist - 41, // eye height - 20, // aim height - 10240, // hear dist - 51200, // see dist - 512, // periphery - 0, // melee distance - 10, // flee health - 8, // hinder damage - 256, // change target chance - 16, // change target chance to same type - 32768, // alert chance - 1, // lockout - 46603, // front speed - 34952, // side speed - 13981, // back speed - 256, // ang speed - 15, -1, -1, // gib type - 256, 256, 96, 256, 256, 256, 192, // start damage - 0, 0, 0, 0, 0, 0, 0, // real damage - 0, // ??? - 0 // ??? - }, - { - 11520, - 40, - 70, - 1200, - 48, - 41, - 20, - 10240, - 51200, - 512, - 0, - 10, - 5, - 256, - 16, - 32768, - 1, - 34952, - 34952, - 13981, - 256, - 15, -1, -1, - 256, 256, 128, 256, 256, 256, 192, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 4352, - 60, - 70, - 1200, - 48, - 46, - 20, - 10240, - 51200, - 512, - 0, - 10, - 15, - 256, - 16, - 32768, - 1, - 58254, - 46603, - 34952, - 384, - 15, -1, -1, - 256, 256, 112, 256, 256, 256, 160, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 4608, - 80, - 200, - 1200, - 48, - 128, - 20, - 10240, - 51200, - 512, - 0, - 10, - 15, - 256, - 16, - 32768, - 1, - 23301, - 23301, - 13981, - 256, - 15, -1, -1, - 256, 256, 32, 128, 256, 64, 128, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 4352, - 60, - 70, - 1200, - 48, - 46, - 20, - 5120, - 0, - 341, - 0, - 10, - 15, - 256, - 16, - 32768, - 1, - 58254, - 46603, - 34952, - 384, - 15, -1, -1, - 256, 256, 112, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 4864, - 110, - 120, - 1200, - 64, - 13, - 5, - 10240, - 51200, - 512, - 0, - 10, - 25, - 256, - 16, - 32768, - 1, - 46603, - 34952, - 23301, - 384, - 30, -1, -1, - 0, 128, 48, 208, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 5120, - 200, - 200, - 1200, - 84, - 13, - 5, - 10240, - 51200, - 512, - 0, - 10, - 20, - 256, - 16, - 32768, - 1, - 46603, - 34952, - 23301, - 256, - 19, -1, -1, - 0, 0, 10, 10, 0, 128, 64, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 11008, - 100, - 200, - 1200, - 64, - 13, - 5, - 2048, - 5120, - 512, - 0, - 10, - 15, - 256, - 16, - 32768, - 0, - 0, - 0, - 0, - 0, - -1, -1, -1, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 11264, - 100, - 200, - 1200, - 64, - 13, - 5, - 2048, - 5120, - 512, - 0, - 10, - 10, - 256, - 16, - 32768, - 0, - 0, - 0, - 0, - 0, - -1, -1, -1, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 5376, - 100, - 70, - 1200, - 64, - 25, - 15, - 10240, - 51200, - 341, - 0, - 10, - 10, - 256, - 0, - 32768, - 1, - 58254, - 46603, - 34952, - 384, - -1, -1, -1, - 0, 0, 48, 0, 0, 16, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 5632, - 70, - 120, - 1200, - 80, - 6, - 0, - 10240, - 51200, - 682, - 0, - 10, - 20, - 256, - 16, - 32768, - 0, - 116508, - 81555, - 69905, - 384, - 29, -1, -1, - 48, 0, 48, 48, 256, 128, 192, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 5888, - 10, - 70, - 1200, - 32, - 0, - 0, - 5120, - 51200, - 341, - 0, - 10, - 10, - 256, - 16, - 32768, - 1, - 58254, - 46603, - 34952, - 384, - 7, -1, -1, - 64, 256, 256, 256, 0, 64, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 6144, - 10, - 5, - 1200, - 32, - -5, - -5, - 5120, - 51200, - 682, - 0, - 10, - 10, - 256, - 16, - 32768, - 0, - 58254, - 46603, - 34952, - 384, - 7, -1, -1, - 64, 256, 256, 96, 256, 64, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 6400, - 25, - 10, - 1200, - 32, - -5, - -5, - 5120, - 51200, - 682, - 0, - 10, - 10, - 256, - 16, - 32768, - 0, - 58254, - 46603, - 34952, - 384, - 7, -1, -1, - 64, 128, 256, 96, 256, 64, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 6656, - 75, - 20, - 1200, - 32, - -5, - -5, - 5120, - 51200, - 682, - 0, - 10, - 10, - 256, - 16, - 32768, - 0, - 58254, - 46603, - 34952, - 384, - 7, -1, -1, - 128, 256, 256, 96, 256, 64, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 6912, - 100, - 40, - 1200, - 32, - -5, - -5, - 5120, - 51200, - 682, - 0, - 10, - 10, - 256, - 16, - 32768, - 0, - 58254, - 46603, - 34952, - 384, - 7, -1, -1, - 32, 16, 16, 16, 32, 32, 32, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 7168, - 50, - 200, - 1200, - 64, - 37, - 20, - 5120, - 51200, - 682, - 0, - 10, - 10, - 256, - 16, - 32768, - 1, - 58254, - 46603, - 34952, - 384, - 7, -1, -1, - 48, 80, 64, 128, 0, 128, 48, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 7424, - 25, - 30, - 1200, - 32, - 4, - 0, - 5120, - 51200, - 512, - 0, - 10, - 10, - 256, - 16, - 32768, - 0, - 34952, - 23301, - 23301, - 128, - 7, -1, -1, - 256, 256, 256, 256, 0, 256, 192, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 7680, - 10, - 5, - 1200, - 32, - 2, - 0, - 10240, - 25600, - 512, - 0, - 10, - 10, - 256, - 16, - 32768, - 0, - 23301, - 23301, - 13981, - 384, - 7, -1, -1, - 256, 256, 256, 256, 256, 64, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 7936, - 10, - 5, - 1200, - 32, - 3, - 0, - 12800, - 51200, - 512, - 0, - 10, - 10, - 256, - 16, - 32768, - 0, - 58254, - 46603, - 34952, - 384, - 7, -1, -1, - 256, 256, 256, 256, 256, 128, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 8192, - 50, - 65535, - 1200, - 64, - 40, - 0, - 2048, - 11264, - 1024, - 0, - 10, - 10, - 256, - 0, - 32768, - 0, - 0, - 0, - 0, - 384, - 7, -1, -1, - 160, 160, 128, 160, 0, 0, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 8448, - 10, - 65535, - 1200, - 32, - 0, - 0, - 2048, - 5120, - 1024, - 0, - 10, - 10, - 256, - 0, - 32768, - 0, - 0, - 0, - 0, - 384, - 7, -1, -1, - 256, 256, 256, 80, 0, 0, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 8704, - 100, - 65535, - 1200, - 64, - 40, - 0, - 2048, - 15360, - 1024, - 0, - 10, - 10, - 256, - 0, - 32768, - 0, - 0, - 0, - 0, - 384, - 7, -1, -1, - 96, 0, 128, 64, 256, 64, 160, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 8960, - 20, - 65535, - 1200, - 32, - 0, - 0, - 2048, - 5120, - 1024, - 0, - 10, - 10, - 256, - 0, - 32768, - 0, - 0, - 0, - 0, - 384, - 7, -1, -1, - 128, 0, 128, 128, 0, 0, 128, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 9216, - 200, - 65535, - 1200, - 64, - 40, - 0, - 2048, - 51200, - 1024, - 0, - 10, - 10, - 256, - 0, - 32768, - 0, - 0, - 0, - 0, - 0, - 7, -1, -1, - 256, 256, 256, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 9472, - 50, - 65535, - 1200, - 32, - 0, - 0, - 2048, - 51200, - 1024, - 0, - 10, - 10, - 256, - 0, - 32768, - 0, - 0, - 0, - 0, - 0, - 7, -1, -1, - 256, 256, 128, 256, 128, 128, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 9728, - 200, - 1000, - 1200, - 64, - 29, - 10, - 40960, - 102400, - 682, - 0, - 10, - 10, - 256, - 0, - 32768, - 0, - 69905, - 58254, - 46603, - 384, - 7, -1, -1, - 16, 0, 16, 16, 0, 96, 48, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 9984, - 100, - 1000, - 1200, - 64, - 29, - 10, - 20480, - 51200, - 682, - 0, - 10, - 10, - 256, - 0, - 32768, - 0, - 58254, - 34952, - 25631, - 384, - 7, -1, -1, - 16, 0, 16, 16, 0, 96, 48, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 10240, - 32, // 800, - 1500, - 1200, - 128, - 0, - 0, - 25600, - 51200, - 512, - 0, - 10, - 10, - 256, - 16, - 32768, - 1, - 58254, - 58254, - 34952, - 384, - 7, -1, -1, - 3, 1, 4, 4, 0, 4, 3, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 4096, - 25, - 20, - 1200, - 32, - 0, - 0, - 2048, - 51200, - 341, - 0, - 10, - 10, - 256, - 16, - 32768, - 1, - 58254, - 46603, - 34952, - 384, - 15, -1, -1, - 256, 256, 96, 256, 256, 256, 192, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 12032, - 100, - 70, - 1200, - 48, - 0, - 16, - 2048, - 51200, - 341, - 0, - 10, - 10, - 256, - 16, - 32768, - 1, - 0, - 0, - 0, - 64, - 15, -1, -1, - 256, 256, 256, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 12032, - 100, - 70, - 1200, - 48, - 0, - 16, - 2048, - 51200, - 341, - 0, - 10, - 10, - 256, - 16, - 32768, - 1, - 0, - 0, - 0, - 64, - 15, -1, -1, - 256, 256, 256, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 12032, - 100, - 70, - 1200, - 48, - 0, - 16, - 2048, - 51200, - 341, - 0, - 10, - 10, - 256, - 16, - 32768, - 1, - 0, - 0, - 0, - 64, - 15, -1, -1, - 256, 256, 256, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 12032, - 100, - 70, - 1200, - 48, - 0, - 16, - 2048, - 51200, - 341, - 0, - 10, - 10, - 256, - 16, - 32768, - 1, - 0, - 0, - 0, - 64, - 15, -1, -1, - 256, 256, 256, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 12032, - 100, - 70, - 1200, - 48, - 0, - 16, - 2048, - 51200, - 341, - 0, - 10, - 10, - 256, - 16, - 32768, - 1, - 0, - 0, - 0, - 64, - 15, -1, -1, - 256, 256, 256, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 12032, - 100, - 70, - 1200, - 48, - 0, - 16, - 2048, - 51200, - 341, - 0, - 10, - 10, - 256, - 16, - 32768, - 1, - 0, - 0, - 0, - 64, - 15, -1, -1, - 256, 256, 256, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 12032, - 100, - 70, - 1200, - 48, - 0, - 16, - 2048, - 51200, - 341, - 0, - 10, - 10, - 256, - 16, - 32768, - 1, - 0, - 0, - 0, - 64, - 15, -1, -1, - 256, 256, 256, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 12032, - 100, - 70, - 1200, - 48, - 0, - 16, - 2048, - 51200, - 341, - 0, - 10, - 10, - 256, - 16, - 32768, - 1, - 0, - 0, - 0, - 64, - 15, -1, -1, - 256, 256, 256, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 12544, - 25, - 70, - 1200, - 48, - 41, - 20, - 10240, - 51200, - 341, - 0, - 100, - 100, - 0, - 0, - 32768, - 0, - 0, - 0, - 0, - 160, - 7, 5, -1, - 256, 256, 256, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 4096, - 30, - 70, - 1200, - 48, - 41, - 20, - 10240, - 51200, - 341, - 0, - 100, - 100, - 0, - 0, - 32768, - 0, - 46603, - 34952, - 13981, - 160, - 7, 5, -1, - 256, 256, 256, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 4352, - 12, - 70, - 1200, - 48, - 46, - 20, - 10240, - 51200, - 341, - 0, - 10, - 15, - 256, - 16, - 32768, - 0, - 58254, - 46603, - 34952, - 160, - 7, 5, -1, - 256, 256, 256, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 4352, - 25, - 120, - 1200, - 48, - 44, - 20, - 10240, - 51200, - 341, - 0, - 10, - 15, - 256, - 16, - 32768, - 0, - 39612, - 27962, - 13981, - 100, - 7, 5, -1, - 256, 256, 256, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 4096, - 100, - 70, - 1200, - 64, - 38, - 20, - 2048, - 51200, - 341, - 0, - 10, - 10, - 256, - 16, - 32768, - 0, - 0, - 0, - 0, - 64, - 15, -1, -1, - 256, 256, 256, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 4352, - 60, - 70, - 1200, - 48, - 46, - 20, - 5120, - 0, - 341, - 0, - 10, - 15, - 256, - 16, - 32768, - 1, - 58254, - 46603, - 34952, - 384, - 15, -1, -1, - 256, 256, 112, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 12544, - 50, - 70, - 1200, - 48, - 46, - 20, - 2560, - 0, - 341, - 0, - 10, - 8, - 256, - 16, - 32768, - 1, - 58254, - 46603, - 34952, - 384, - 15, -1, -1, - 288, 288, 288, 288, 288, 288, 288, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 11520, - 25, - 70, - 1200, - 32, - -5, - 0, - 2048, - 51200, - 341, - 0, - 10, - 10, - 256, - 16, - 32768, - 0, - 0, - 0, - 0, - 64, - 7, 5, -1, - 256, 256, 256, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 12800, - 40, - 70, - 1200, - 48, - 41, - 20, - 10240, - 51200, - 512, - 0, - 10, - 8, - 256, - 16, - 32768, - 1, - 46603, - 34952, - 13981, - 256, - 15, -1, -1, - 256, 256, 96, 160, 256, 256, 12, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 13056, - 40, - 70, - 1200, - 48, - 41, - 20, - 10240, - 51200, - 512, - 0, - 10, - 8, - 256, - 16, - 32768, - 1, - 46603, - 34952, - 13981, - 256, - 15, -1, -1, - 256, 160, 96, 64, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 13312, - 40, - 70, - 1200, - 48, - 41, - 20, - 10240, - 51200, - 512, - 0, - 10, - 12, - 256, - 16, - 32768, - 1, - 46603, - 34952, - 13981, - 256, - 15, -1, -1, - 128, 128, 16, 16, 0, 64, 48, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 13568, - 10, - 5, - 1200, - 32, - 3, - 0, - 12800, - 51200, - 512, - 0, - 10, - 10, - 256, - 16, - 32768, - 0, - 58254, - 46603, - 34952, - 384, - 7, -1, -1, - 160, 160, 160, 160, 256, 128, 288, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 10752, - 120, - 70, - 1200, - 48, - 41, - 20, - 12800, - 51200, - 341, - 0, - 10, - 10, - 256, - 16, - 32768, - 1, - 116508, - 81555, - 69905, - 384, - 7, -1, -1, - 5, 5, 15, 8, 0, 15, 15, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 13568, - 10, - 5, - 1200, - 32, - 3, - 0, - 12800, - 51200, - 512, - 0, - 10, - 10, - 256, - 16, - 32768, - 0, - 58254, - 46603, - 34952, - 384, - 7, -1, -1, - 256, 256, 256, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - { - 10752, - 25, - 70, - 1200, - 48, - 41, - 20, - 12800, - 51200, - 341, - 0, - 10, - 10, - 256, - 16, - 32768, - 1, - 116508, - 81555, - 69905, - 384, - 7, -1, -1, - 256, 256, 256, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - //254 - kDudeModernCustom - { - 11520, // start sequence ID - 85, // start health - 75, // mass - 120, - 48, // clip distance - 48, // eye above z - 20, - 10240, // hear distance - 51200, // seeing distance - kAng90, // vision periphery - // 0, - 618, // melee distance - 5, // flee health - 5, // hinder damage - 0x0000, // change target chance - 0x0000, // change target to kin chance - 0x8000, // alertChance - 1, // lockout - 46603, // frontSpeed - 34952, // sideSpeed - 13981, // backSpeed - 256, // angSpeed - // 0, - 7, -1, 18, // nGibType - 64, 256, 256, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, - //255 - kDudeModernCustomBurning - { - 4096, // start sequence ID - 25, // start health - 5, // mass - 120, - 48, // clip distance - 41, // eye above z - 20, - 12800, // hear distance - 51200, // seeing distance - kAng60, // vision periphery - // 0, - 0, // melee distance - 10, // flee health - 10, // hinder damage - 0x0100, // change target chance - 0x0010, // change target to kin chance - 0x8000, // alertChance - true, // lockout - 58254, // frontSpeed - 46603, // sideSpeed - 34952, // backSpeed - 384, // angSpeed - // 0, - 7, -1, -1, // nGibType - 256, 256, 256, 256, 256, 256, 256, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - } + { + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 4096, //seqStartId + 40, // startHp + 70, // mass + 1200, // ??? + 48, // clipdist + 41, // eye height + 20, // aim height + 10240, // hear dist + 51200, // see dist + 512, // periphery + 0, // melee distance + 10, // flee health + 8, // hinder damage + 256, // change target chance + 16, // change target chance to same type + 32768, // alert chance + 1, // lockout + 46603, // front speed + 34952, // side speed + 13981, // back speed + 256, // ang speed + 15, -1, -1, // gib type + 256, 256, 96, 256, 256, 256, 192, // start damage + 0, 0, 0, 0, 0, 0, 0, // real damage + 0, // ??? + 0 // ??? + }, + { + 11520, + 40, + 70, + 1200, + 48, + 41, + 20, + 10240, + 51200, + 512, + 0, + 10, + 5, + 256, + 16, + 32768, + 1, + 34952, + 34952, + 13981, + 256, + 15, -1, -1, + 256, 256, 128, 256, 256, 256, 192, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 4352, + 60, + 70, + 1200, + 48, + 46, + 20, + 10240, + 51200, + 512, + 0, + 10, + 15, + 256, + 16, + 32768, + 1, + 58254, + 46603, + 34952, + 384, + 15, -1, -1, + 256, 256, 112, 256, 256, 256, 160, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 4608, + 80, + 200, + 1200, + 48, + 128, + 20, + 10240, + 51200, + 512, + 0, + 10, + 15, + 256, + 16, + 32768, + 1, + 23301, + 23301, + 13981, + 256, + 15, -1, -1, + 256, 256, 32, 128, 256, 64, 128, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 4352, + 60, + 70, + 1200, + 48, + 46, + 20, + 5120, + 0, + 341, + 0, + 10, + 15, + 256, + 16, + 32768, + 1, + 58254, + 46603, + 34952, + 384, + 15, -1, -1, + 256, 256, 112, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 4864, + 110, + 120, + 1200, + 64, + 13, + 5, + 10240, + 51200, + 512, + 0, + 10, + 25, + 256, + 16, + 32768, + 1, + 46603, + 34952, + 23301, + 384, + 30, -1, -1, + 0, 128, 48, 208, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 5120, + 200, + 200, + 1200, + 84, + 13, + 5, + 10240, + 51200, + 512, + 0, + 10, + 20, + 256, + 16, + 32768, + 1, + 46603, + 34952, + 23301, + 256, + 19, -1, -1, + 0, 0, 10, 10, 0, 128, 64, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 11008, + 100, + 200, + 1200, + 64, + 13, + 5, + 2048, + 5120, + 512, + 0, + 10, + 15, + 256, + 16, + 32768, + 0, + 0, + 0, + 0, + 0, + -1, -1, -1, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 11264, + 100, + 200, + 1200, + 64, + 13, + 5, + 2048, + 5120, + 512, + 0, + 10, + 10, + 256, + 16, + 32768, + 0, + 0, + 0, + 0, + 0, + -1, -1, -1, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 5376, + 100, + 70, + 1200, + 64, + 25, + 15, + 10240, + 51200, + 341, + 0, + 10, + 10, + 256, + 0, + 32768, + 1, + 58254, + 46603, + 34952, + 384, + -1, -1, -1, + 0, 0, 48, 0, 0, 16, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 5632, + 70, + 120, + 1200, + 80, + 6, + 0, + 10240, + 51200, + 682, + 0, + 10, + 20, + 256, + 16, + 32768, + 0, + 116508, + 81555, + 69905, + 384, + 29, -1, -1, + 48, 0, 48, 48, 256, 128, 192, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 5888, + 10, + 70, + 1200, + 32, + 0, + 0, + 5120, + 51200, + 341, + 0, + 10, + 10, + 256, + 16, + 32768, + 1, + 58254, + 46603, + 34952, + 384, + 7, -1, -1, + 64, 256, 256, 256, 0, 64, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 6144, + 10, + 5, + 1200, + 32, + -5, + -5, + 5120, + 51200, + 682, + 0, + 10, + 10, + 256, + 16, + 32768, + 0, + 58254, + 46603, + 34952, + 384, + 7, -1, -1, + 64, 256, 256, 96, 256, 64, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 6400, + 25, + 10, + 1200, + 32, + -5, + -5, + 5120, + 51200, + 682, + 0, + 10, + 10, + 256, + 16, + 32768, + 0, + 58254, + 46603, + 34952, + 384, + 7, -1, -1, + 64, 128, 256, 96, 256, 64, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 6656, + 75, + 20, + 1200, + 32, + -5, + -5, + 5120, + 51200, + 682, + 0, + 10, + 10, + 256, + 16, + 32768, + 0, + 58254, + 46603, + 34952, + 384, + 7, -1, -1, + 128, 256, 256, 96, 256, 64, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 6912, + 100, + 40, + 1200, + 32, + -5, + -5, + 5120, + 51200, + 682, + 0, + 10, + 10, + 256, + 16, + 32768, + 0, + 58254, + 46603, + 34952, + 384, + 7, -1, -1, + 32, 16, 16, 16, 32, 32, 32, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 7168, + 50, + 200, + 1200, + 64, + 37, + 20, + 5120, + 51200, + 682, + 0, + 10, + 10, + 256, + 16, + 32768, + 1, + 58254, + 46603, + 34952, + 384, + 7, -1, -1, + 48, 80, 64, 128, 0, 128, 48, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 7424, + 25, + 30, + 1200, + 32, + 4, + 0, + 5120, + 51200, + 512, + 0, + 10, + 10, + 256, + 16, + 32768, + 0, + 34952, + 23301, + 23301, + 128, + 7, -1, -1, + 256, 256, 256, 256, 0, 256, 192, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 7680, + 10, + 5, + 1200, + 32, + 2, + 0, + 10240, + 25600, + 512, + 0, + 10, + 10, + 256, + 16, + 32768, + 0, + 23301, + 23301, + 13981, + 384, + 7, -1, -1, + 256, 256, 256, 256, 256, 64, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 7936, + 10, + 5, + 1200, + 32, + 3, + 0, + 12800, + 51200, + 512, + 0, + 10, + 10, + 256, + 16, + 32768, + 0, + 58254, + 46603, + 34952, + 384, + 7, -1, -1, + 256, 256, 256, 256, 256, 128, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 8192, + 50, + 65535, + 1200, + 64, + 40, + 0, + 2048, + 11264, + 1024, + 0, + 10, + 10, + 256, + 0, + 32768, + 0, + 0, + 0, + 0, + 384, + 7, -1, -1, + 160, 160, 128, 160, 0, 0, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 8448, + 10, + 65535, + 1200, + 32, + 0, + 0, + 2048, + 5120, + 1024, + 0, + 10, + 10, + 256, + 0, + 32768, + 0, + 0, + 0, + 0, + 384, + 7, -1, -1, + 256, 256, 256, 80, 0, 0, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 8704, + 100, + 65535, + 1200, + 64, + 40, + 0, + 2048, + 15360, + 1024, + 0, + 10, + 10, + 256, + 0, + 32768, + 0, + 0, + 0, + 0, + 384, + 7, -1, -1, + 96, 0, 128, 64, 256, 64, 160, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 8960, + 20, + 65535, + 1200, + 32, + 0, + 0, + 2048, + 5120, + 1024, + 0, + 10, + 10, + 256, + 0, + 32768, + 0, + 0, + 0, + 0, + 384, + 7, -1, -1, + 128, 0, 128, 128, 0, 0, 128, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 9216, + 200, + 65535, + 1200, + 64, + 40, + 0, + 2048, + 51200, + 1024, + 0, + 10, + 10, + 256, + 0, + 32768, + 0, + 0, + 0, + 0, + 0, + 7, -1, -1, + 256, 256, 256, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 9472, + 50, + 65535, + 1200, + 32, + 0, + 0, + 2048, + 51200, + 1024, + 0, + 10, + 10, + 256, + 0, + 32768, + 0, + 0, + 0, + 0, + 0, + 7, -1, -1, + 256, 256, 128, 256, 128, 128, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 9728, + 200, + 1000, + 1200, + 64, + 29, + 10, + 40960, + 102400, + 682, + 0, + 10, + 10, + 256, + 0, + 32768, + 0, + 69905, + 58254, + 46603, + 384, + 7, -1, -1, + 16, 0, 16, 16, 0, 96, 48, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 9984, + 100, + 1000, + 1200, + 64, + 29, + 10, + 20480, + 51200, + 682, + 0, + 10, + 10, + 256, + 0, + 32768, + 0, + 58254, + 34952, + 25631, + 384, + 7, -1, -1, + 16, 0, 16, 16, 0, 96, 48, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 10240, + 32, // 800, + 1500, + 1200, + 128, + 0, + 0, + 25600, + 51200, + 512, + 0, + 10, + 10, + 256, + 16, + 32768, + 1, + 58254, + 58254, + 34952, + 384, + 7, -1, -1, + 3, 1, 4, 4, 0, 4, 3, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 4096, + 25, + 20, + 1200, + 32, + 0, + 0, + 2048, + 51200, + 341, + 0, + 10, + 10, + 256, + 16, + 32768, + 1, + 58254, + 46603, + 34952, + 384, + 15, -1, -1, + 256, 256, 96, 256, 256, 256, 192, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 12032, + 100, + 70, + 1200, + 48, + 0, + 16, + 2048, + 51200, + 341, + 0, + 10, + 10, + 256, + 16, + 32768, + 1, + 0, + 0, + 0, + 64, + 15, -1, -1, + 256, 256, 256, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 12032, + 100, + 70, + 1200, + 48, + 0, + 16, + 2048, + 51200, + 341, + 0, + 10, + 10, + 256, + 16, + 32768, + 1, + 0, + 0, + 0, + 64, + 15, -1, -1, + 256, 256, 256, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 12032, + 100, + 70, + 1200, + 48, + 0, + 16, + 2048, + 51200, + 341, + 0, + 10, + 10, + 256, + 16, + 32768, + 1, + 0, + 0, + 0, + 64, + 15, -1, -1, + 256, 256, 256, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 12032, + 100, + 70, + 1200, + 48, + 0, + 16, + 2048, + 51200, + 341, + 0, + 10, + 10, + 256, + 16, + 32768, + 1, + 0, + 0, + 0, + 64, + 15, -1, -1, + 256, 256, 256, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 12032, + 100, + 70, + 1200, + 48, + 0, + 16, + 2048, + 51200, + 341, + 0, + 10, + 10, + 256, + 16, + 32768, + 1, + 0, + 0, + 0, + 64, + 15, -1, -1, + 256, 256, 256, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 12032, + 100, + 70, + 1200, + 48, + 0, + 16, + 2048, + 51200, + 341, + 0, + 10, + 10, + 256, + 16, + 32768, + 1, + 0, + 0, + 0, + 64, + 15, -1, -1, + 256, 256, 256, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 12032, + 100, + 70, + 1200, + 48, + 0, + 16, + 2048, + 51200, + 341, + 0, + 10, + 10, + 256, + 16, + 32768, + 1, + 0, + 0, + 0, + 64, + 15, -1, -1, + 256, 256, 256, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 12032, + 100, + 70, + 1200, + 48, + 0, + 16, + 2048, + 51200, + 341, + 0, + 10, + 10, + 256, + 16, + 32768, + 1, + 0, + 0, + 0, + 64, + 15, -1, -1, + 256, 256, 256, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 12544, + 25, + 70, + 1200, + 48, + 41, + 20, + 10240, + 51200, + 341, + 0, + 100, + 100, + 0, + 0, + 32768, + 0, + 0, + 0, + 0, + 160, + 7, 5, -1, + 256, 256, 256, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 4096, + 30, + 70, + 1200, + 48, + 41, + 20, + 10240, + 51200, + 341, + 0, + 100, + 100, + 0, + 0, + 32768, + 0, + 46603, + 34952, + 13981, + 160, + 7, 5, -1, + 256, 256, 256, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 4352, + 12, + 70, + 1200, + 48, + 46, + 20, + 10240, + 51200, + 341, + 0, + 10, + 15, + 256, + 16, + 32768, + 0, + 58254, + 46603, + 34952, + 160, + 7, 5, -1, + 256, 256, 256, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 4352, + 25, + 120, + 1200, + 48, + 44, + 20, + 10240, + 51200, + 341, + 0, + 10, + 15, + 256, + 16, + 32768, + 0, + 39612, + 27962, + 13981, + 100, + 7, 5, -1, + 256, 256, 256, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 4096, + 100, + 70, + 1200, + 64, + 38, + 20, + 2048, + 51200, + 341, + 0, + 10, + 10, + 256, + 16, + 32768, + 0, + 0, + 0, + 0, + 64, + 15, -1, -1, + 256, 256, 256, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 4352, + 60, + 70, + 1200, + 48, + 46, + 20, + 5120, + 0, + 341, + 0, + 10, + 15, + 256, + 16, + 32768, + 1, + 58254, + 46603, + 34952, + 384, + 15, -1, -1, + 256, 256, 112, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 12544, + 50, + 70, + 1200, + 48, + 46, + 20, + 2560, + 0, + 341, + 0, + 10, + 8, + 256, + 16, + 32768, + 1, + 58254, + 46603, + 34952, + 384, + 15, -1, -1, + 288, 288, 288, 288, 288, 288, 288, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 11520, + 25, + 70, + 1200, + 32, + -5, + 0, + 2048, + 51200, + 341, + 0, + 10, + 10, + 256, + 16, + 32768, + 0, + 0, + 0, + 0, + 64, + 7, 5, -1, + 256, 256, 256, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 12800, + 40, + 70, + 1200, + 48, + 41, + 20, + 10240, + 51200, + 512, + 0, + 10, + 8, + 256, + 16, + 32768, + 1, + 46603, + 34952, + 13981, + 256, + 15, -1, -1, + 256, 256, 96, 160, 256, 256, 12, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 13056, + 40, + 70, + 1200, + 48, + 41, + 20, + 10240, + 51200, + 512, + 0, + 10, + 8, + 256, + 16, + 32768, + 1, + 46603, + 34952, + 13981, + 256, + 15, -1, -1, + 256, 160, 96, 64, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 13312, + 40, + 70, + 1200, + 48, + 41, + 20, + 10240, + 51200, + 512, + 0, + 10, + 12, + 256, + 16, + 32768, + 1, + 46603, + 34952, + 13981, + 256, + 15, -1, -1, + 128, 128, 16, 16, 0, 64, 48, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 13568, + 10, + 5, + 1200, + 32, + 3, + 0, + 12800, + 51200, + 512, + 0, + 10, + 10, + 256, + 16, + 32768, + 0, + 58254, + 46603, + 34952, + 384, + 7, -1, -1, + 160, 160, 160, 160, 256, 128, 288, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 10752, + 120, + 70, + 1200, + 48, + 41, + 20, + 12800, + 51200, + 341, + 0, + 10, + 10, + 256, + 16, + 32768, + 1, + 116508, + 81555, + 69905, + 384, + 7, -1, -1, + 5, 5, 15, 8, 0, 15, 15, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 13568, + 10, + 5, + 1200, + 32, + 3, + 0, + 12800, + 51200, + 512, + 0, + 10, + 10, + 256, + 16, + 32768, + 0, + 58254, + 46603, + 34952, + 384, + 7, -1, -1, + 256, 256, 256, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + { + 10752, + 25, + 70, + 1200, + 48, + 41, + 20, + 12800, + 51200, + 341, + 0, + 10, + 10, + 256, + 16, + 32768, + 1, + 116508, + 81555, + 69905, + 384, + 7, -1, -1, + 256, 256, 256, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + //254 - kDudeModernCustom + { + 11520, // start sequence ID + 85, // start health + 75, // mass + 120, + 48, // clip distance + 48, // eye above z + 20, + 10240, // hear distance + 51200, // seeing distance + kAng90, // vision periphery + // 0, + 618, // melee distance + 5, // flee health + 5, // hinder damage + 0x0000, // change target chance + 0x0000, // change target to kin chance + 0x8000, // alertChance + 1, // lockout + 46603, // frontSpeed + 34952, // sideSpeed + 13981, // backSpeed + 256, // angSpeed + // 0, + 7, -1, 18, // nGibType + 64, 256, 256, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, + //255 - kDudeModernCustomBurning + { + 4096, // start sequence ID + 25, // start health + 5, // mass + 120, + 48, // clip distance + 41, // eye above z + 20, + 12800, // hear distance + 51200, // seeing distance + kAng60, // vision periphery + // 0, + 0, // melee distance + 10, // flee health + 10, // hinder damage + 0x0100, // change target chance + 0x0010, // change target to kin chance + 0x8000, // alertChance + true, // lockout + 58254, // frontSpeed + 46603, // sideSpeed + 34952, // backSpeed + 384, // angSpeed + // 0, + 7, -1, -1, // nGibType + 256, 256, 256, 256, 256, 256, 256, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + } }; -DUDEINFO gPlayerTemplate[4] = +DUDEINFO gPlayerTemplate[4] = { - // normal human - { - 0x2f00, - 100, - 70, - 1200, - 0x30, - 0, - 0x10, - 0x800, - 0xc800, - 0x155, - 0, - 10, - 10, - 0x100, - 0x10, - 0x8000, - 0x1, - 0, - 0, - 0, - 0x40, - 15, -1, -1, - 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x120, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, + // normal human + { + 0x2f00, + 100, + 70, + 1200, + 0x30, + 0, + 0x10, + 0x800, + 0xc800, + 0x155, + 0, + 10, + 10, + 0x100, + 0x10, + 0x8000, + 0x1, + 0, + 0, + 0, + 0x40, + 15, -1, -1, + 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x120, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, - // normal beast - { - 0x2900, - 100, - 70, - 1200, - 0x30, - 0, - 0x14, - 0x800, - 0xc800, - 0x155, - 0, - 10, - 10, - 0x100, - 0x10, - 0x8000, - 0x1, - 0, - 0, - 0, - 0x40, - 7, -1, -1, - 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x120, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, + // normal beast + { + 0x2900, + 100, + 70, + 1200, + 0x30, + 0, + 0x14, + 0x800, + 0xc800, + 0x155, + 0, + 10, + 10, + 0x100, + 0x10, + 0x8000, + 0x1, + 0, + 0, + 0, + 0x40, + 7, -1, -1, + 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x120, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, - // shrink human - { - 12032, - 100, - 10, // mass - 1200, - 16, // clipdist - 0, - 0x10, - 0x800, - 0xc800, - 0x155, - 0, - 10, - 10, - 0x100, - 0x10, - 0x8000, - 0x1, - 0, - 0, - 0, - 0x40, - 15, -1, -1, // gib type - 1024, 1024, 1024, 1024, 256, 1024, 1024, //damage shift - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, + // shrink human + { + 12032, + 100, + 10, // mass + 1200, + 16, // clipdist + 0, + 0x10, + 0x800, + 0xc800, + 0x155, + 0, + 10, + 10, + 0x100, + 0x10, + 0x8000, + 0x1, + 0, + 0, + 0, + 0x40, + 15, -1, -1, // gib type + 1024, 1024, 1024, 1024, 256, 1024, 1024, //damage shift + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, - // grown human - { - 12032, - 100, - 1100, // mass - 1200, - 100, // clipdist - 0, - 0x10, - 0x800, - 0xc800, - 0x155, - 0, - 10, - 10, - 0x100, - 0x10, - 0x8000, - 0x1, - 0, - 0, - 0, - 0x40, - 15, 7, 7, // gib type - 64, 64, 64, 64, 256, 64, 64, // damage shift - 0, 0, 0, 0, 0, 0, 0, - 0, - 0 - }, + // grown human + { + 12032, + 100, + 1100, // mass + 1200, + 100, // clipdist + 0, + 0x10, + 0x800, + 0xc800, + 0x155, + 0, + 10, + 10, + 0x100, + 0x10, + 0x8000, + 0x1, + 0, + 0, + 0, + 0x40, + 15, 7, 7, // gib type + 64, 64, 64, 64, 256, 64, 64, // damage shift + 0, 0, 0, 0, 0, 0, 0, + 0, + 0 + }, }; DUDEINFO fakeDudeInfo = {}; diff --git a/source/games/blood/src/dude.h b/source/games/blood/src/dude.h index a7983125e..41a129c95 100644 --- a/source/games/blood/src/dude.h +++ b/source/games/blood/src/dude.h @@ -26,43 +26,43 @@ BEGIN_BLD_NS // By NoOne: renamed dude struct struct DUDEINFO { - int16_t seqStartID; // seq - int16_t startHealth; // health - uint16_t mass; // mass - int at6; // unused? - uint8_t clipdist; // clipdist - int eyeHeight; - int aimHeight; // used by just Cerberus - int hearDist; // hear radius - int seeDist; // sight radius - int periphery; // periphery - int meleeDist; // unused? - int fleeHealth; // at which hp level enemy will turn in burning dude - int hinderDamage; // recoil damage - int changeTarget; // chance to change target when attacked someone else - int changeTargetKin; // chance to change target when attacked by same type - int alertChance; - uint8_t lockOut; // indicates if this dude can trigger something via trigger flags - int frontSpeed; // acceleration - int sideSpeed; // dodge - int backSpeed; // backward speed (unused) - int angSpeed; // turn speed - int nGibType[3]; // which gib used when explode dude - int startDamage[7]; // start damage shift - int damageVal[7]; // real damage? Hmm? - int at8c; // unused ? - int at90; // unused ? + int16_t seqStartID; // seq + int16_t startHealth; // health + uint16_t mass; // mass + int at6; // unused? + uint8_t clipdist; // clipdist + int eyeHeight; + int aimHeight; // used by just Cerberus + int hearDist; // hear radius + int seeDist; // sight radius + int periphery; // periphery + int meleeDist; // unused? + int fleeHealth; // at which hp level enemy will turn in burning dude + int hinderDamage; // recoil damage + int changeTarget; // chance to change target when attacked someone else + int changeTargetKin; // chance to change target when attacked by same type + int alertChance; + uint8_t lockOut; // indicates if this dude can trigger something via trigger flags + int frontSpeed; // acceleration + int sideSpeed; // dodge + int backSpeed; // backward speed (unused) + int angSpeed; // turn speed + int nGibType[3]; // which gib used when explode dude + int startDamage[7]; // start damage shift + int damageVal[7]; // real damage? Hmm? + int at8c; // unused ? + int at90; // unused ? }; -extern DUDEINFO dudeInfo[kDudeMax-kDudeBase]; +extern DUDEINFO dudeInfo[kDudeMax - kDudeBase]; extern DUDEINFO gPlayerTemplate[4]; extern DUDEINFO fakeDudeInfo; -inline DUDEINFO *getDudeInfo(int const nType) +inline DUDEINFO* getDudeInfo(int const nType) { - if (nType >= kDudeBase && nType < kDudeMax) - return &dudeInfo[nType - kDudeBase]; - return &fakeDudeInfo; + if (nType >= kDudeBase && nType < kDudeMax) + return &dudeInfo[nType - kDudeBase]; + return &fakeDudeInfo; } END_BLD_NS diff --git a/source/games/blood/src/endgame.cpp b/source/games/blood/src/endgame.cpp index 161f8dd5d..c1d1edae5 100644 --- a/source/games/blood/src/endgame.cpp +++ b/source/games/blood/src/endgame.cpp @@ -36,7 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS -void GameInterface::LevelCompleted(MapRecord *map, int skill) +void GameInterface::LevelCompleted(MapRecord* map, int skill) { // Save the player state before taking down anything. for (int i = connecthead; i >= 0; i = connectpoint2[i]) @@ -63,7 +63,7 @@ void GameInterface::LevelCompleted(MapRecord *map, int skill) ShowIntermission(currentLevel, map, &info, [=](bool) { soundEngine->StopAllChannels(); - gameaction = map? ga_nextlevel : ga_creditsmenu; + gameaction = map ? ga_nextlevel : ga_creditsmenu; }); } diff --git a/source/games/blood/src/endgame.h b/source/games/blood/src/endgame.h index d6c6647b0..8fd7b2587 100644 --- a/source/games/blood/src/endgame.h +++ b/source/games/blood/src/endgame.h @@ -28,20 +28,20 @@ BEGIN_BLD_NS class CKillMgr { public: - int TotalKills, Kills; - void SetCount(int); - void AddNewKill(int); - void AddKill(DBloodActor *actor); - void CountTotalKills(void); - void Clear(void); + int TotalKills, Kills; + void SetCount(int); + void AddNewKill(int); + void AddKill(DBloodActor* actor); + void CountTotalKills(void); + void Clear(void); }; class CSecretMgr { public: - int Total, Founds, Super; - void SetCount(int); - void Found(int); - void Clear(void); + int Total, Founds, Super; + void SetCount(int); + void Found(int); + void Clear(void); }; extern CSecretMgr gSecretMgr; diff --git a/source/games/blood/src/eventq.cpp b/source/games/blood/src/eventq.cpp index 62bf96f98..8cb9cc2f6 100644 --- a/source/games/blood/src/eventq.cpp +++ b/source/games/blood/src/eventq.cpp @@ -72,7 +72,7 @@ static int GetBucketChannel(EventObject* pBucket) if (pBucket->isActor()) { auto pActor = pBucket->actor(); - return pActor? pActor->xspr.rxID : 0; + return pActor ? pActor->xspr.rxID : 0; } Printf(PRINT_HIGH, "Unexpected rxBucket %s", pBucket->description().GetChars()); @@ -157,7 +157,7 @@ static void SortRXBucket(int nCount) } break; } - EventObject * middle = pArray + nCount / 2; + EventObject* middle = pArray + nCount / 2; if (nCount > 29) { EventObject* first = pArray; @@ -280,7 +280,7 @@ void evInit(TArray& actors) memset(rxBucket, 0, sizeof(rxBucket)); // add all the tags to the bucket array - for(auto& sect: sector) + for (auto& sect : sector) { if (sect.hasX() && sect.xs().rxID > 0) { @@ -290,7 +290,7 @@ void evInit(TArray& actors) } } - for(auto& wal: wall) + for (auto& wal : wall) { if (wal.hasX() && wal.xw().rxID > 0) { @@ -389,7 +389,7 @@ void evSend(EventObject& eob, int rxId, COMMAND_ID command) else viewSetSystemMessage("Invalid Total-Secrets command by %s", eob.description().GetChars()); break; case kChannelSecretFound: - { + { int nIndex = -1; if (eob.isActor() && eob.actor()) nIndex = eob.actor()->GetIndex() + 3 * 65536; // the hint system needs the sprite index. else if (eob.isSector()) nIndex = eob.rawindex() + 6 * 65536; @@ -451,28 +451,28 @@ void evSend(EventObject& eob, int rxId, COMMAND_ID command) } #ifdef NOONE_EXTENSIONS - if (gModernMap) + if (gModernMap) { // allow to send commands on player sprites PLAYER* pPlayer = NULL; - if (playerRXRngIsFine(rxId)) + if (playerRXRngIsFine(rxId)) { if ((pPlayer = getPlayerById((rxId - kChannelPlayer7) + kMaxPlayers)) != nullptr) trMessageSprite(pPlayer->actor, event); } - else if (rxId == kChannelAllPlayers) + else if (rxId == kChannelAllPlayers) { - for (int i = 0; i < kMaxPlayers; i++) + for (int i = 0; i < kMaxPlayers; i++) { if ((pPlayer = getPlayerById(i)) != nullptr) trMessageSprite(pPlayer->actor, event); } - return; + return; } } #endif - for (int i = bucketHead[rxId]; i < bucketHead[rxId + 1]; i++) + for (int i = bucketHead[rxId]; i < bucketHead[rxId + 1]; i++) { auto eo = rxBucket[i]; if (!event.event_isObject(eo)) @@ -510,13 +510,13 @@ void evPost_(EventObject& eob, unsigned int nDelta, COMMAND_ID command) assert(command != kCmdCallback); if (command == kCmdState) command = evGetSourceState(eob) ? kCmdOn : kCmdOff; else if (command == kCmdNotState) command = evGetSourceState(eob) ? kCmdOff : kCmdOn; - EVENT evn = {eob, (int8_t)command, 0, PlayClock + (int)nDelta }; + EVENT evn = { eob, (int8_t)command, 0, PlayClock + (int)nDelta }; queue.insert(evn); } void evPost_(const EventObject& eob, unsigned int nDelta, CALLBACK_ID callback) { - EVENT evn = {eob, kCmdCallback, (int16_t)callback, PlayClock + (int)nDelta }; + EVENT evn = { eob, kCmdCallback, (int16_t)callback, PlayClock + (int)nDelta }; queue.insert(evn); } @@ -649,8 +649,8 @@ void evProcess(unsigned int time) if (event.target.isActor()) trMessageSprite(event.target.actor(), event); else if (event.target.isSector()) trMessageSector(event.target.sector(), event); else if (event.target.isWall()) trMessageWall(event.target.wall(), event); - } } + } } //--------------------------------------------------------------------------- @@ -669,21 +669,21 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, EventObject& w, Ev { case 0: { - DBloodActor* a = arc.isWriting()? w.actor() : nullptr; + DBloodActor* a = arc.isWriting() ? w.actor() : nullptr; arc("actor", a); if (arc.isReading()) w = EventObject(a); break; } case 1: { - auto s = arc.isWriting()? w.sector() : nullptr; + auto s = arc.isWriting() ? w.sector() : nullptr; arc("sector", s); if (arc.isReading()) w = EventObject(s); break; } case 2: { - auto s = arc.isWriting()? w.wall() : nullptr; + auto s = arc.isWriting() ? w.wall() : nullptr; arc("wall", s); if (arc.isReading()) w = EventObject(s); break; diff --git a/source/games/blood/src/eventq.h b/source/games/blood/src/eventq.h index 6cbd9291e..d03aca008 100644 --- a/source/games/blood/src/eventq.h +++ b/source/games/blood/src/eventq.h @@ -39,18 +39,18 @@ class EventObject DBloodActor* ActorP; uint64_t index; }; - + public: EventObject() = default; explicit EventObject(std::nullptr_t) { index = -1; } explicit EventObject(DBloodActor* actor_) { ActorP = actor_; assert(isActor()); } - explicit EventObject(sectortype *sect) { index = (sectnum(sect) << 8) | Sector; } + explicit EventObject(sectortype* sect) { index = (sectnum(sect) << 8) | Sector; } explicit EventObject(walltype* wall) { index = (wallnum(wall) << 8) | Wall; } - bool isActor() const { return (index&7) == Actor; } - bool isSector() const { return (index&7) == Sector; } - bool isWall() const { return (index&7) == Wall; } - + bool isActor() const { return (index & 7) == Actor; } + bool isSector() const { return (index & 7) == Sector; } + bool isWall() const { return (index & 7) == Wall; } + DBloodActor* actor() { assert(isActor()); return GC::ReadBarrier(ActorP); } sectortype* sector() { assert(isSector()); return &::sector[index >> 8]; } walltype* wall() { assert(isWall()); return &::wall[index >> 8]; } @@ -117,50 +117,50 @@ extern EventObject rxBucket[]; extern unsigned short bucketHead[]; enum COMMAND_ID { -kCmdOff = 0, -kCmdOn = 1, -kCmdState = 2, -kCmdToggle = 3, -kCmdNotState = 4, -kCmdLink = 5, -kCmdLock = 6, -kCmdUnlock = 7, -kCmdToggleLock = 8, -kCmdStopOff = 9, -kCmdStopOn = 10, -kCmdStopNext = 11, -kCmdCounterSector = 12, -kCmdCallback = 20, -kCmdRepeat = 21, + kCmdOff = 0, + kCmdOn = 1, + kCmdState = 2, + kCmdToggle = 3, + kCmdNotState = 4, + kCmdLink = 5, + kCmdLock = 6, + kCmdUnlock = 7, + kCmdToggleLock = 8, + kCmdStopOff = 9, + kCmdStopOn = 10, + kCmdStopNext = 11, + kCmdCounterSector = 12, + kCmdCallback = 20, + kCmdRepeat = 21, -kCmdSpritePush = 30, -kCmdSpriteImpact = 31, -kCmdSpritePickup = 32, -kCmdSpriteTouch = 33, -kCmdSpriteSight = 34, -kCmdSpriteProximity = 35, -kCmdSpriteExplode = 36, + kCmdSpritePush = 30, + kCmdSpriteImpact = 31, + kCmdSpritePickup = 32, + kCmdSpriteTouch = 33, + kCmdSpriteSight = 34, + kCmdSpriteProximity = 35, + kCmdSpriteExplode = 36, -kCmdSectorPush = 40, -kCmdSectorImpact = 41, -kCmdSectorEnter = 42, -kCmdSectorExit = 43, + kCmdSectorPush = 40, + kCmdSectorImpact = 41, + kCmdSectorEnter = 42, + kCmdSectorExit = 43, -kCmdWallPush = 50, -kCmdWallImpact = 51, -kCmdWallTouch = 52, + kCmdWallPush = 50, + kCmdWallImpact = 51, + kCmdWallTouch = 52, #ifdef NOONE_EXTENSIONS -kCmdSectorMotionPause = 13, // stops motion of the sector -kCmdSectorMotionContinue = 14, // continues motion of the sector -kCmdDudeFlagsSet = 15, // copy dudeFlags from sprite to dude -kCmdModernUse = 53, // used by most of modern types + kCmdSectorMotionPause = 13, // stops motion of the sector + kCmdSectorMotionContinue = 14, // continues motion of the sector + kCmdDudeFlagsSet = 15, // copy dudeFlags from sprite to dude + kCmdModernUse = 53, // used by most of modern types #endif -kCmdNumberic = 64, // 64: 0, 65: 1 and so on up to 255 -kCmdModernFeaturesEnable = 100, // must be in object with kChannelMapModernize RX / TX -kCmdModernFeaturesDisable = 200, // must be in object with kChannelMapModernize RX / TX -kCmdNumbericMax = 255, + kCmdNumberic = 64, // 64: 0, 65: 1 and so on up to 255 + kCmdModernFeaturesEnable = 100, // must be in object with kChannelMapModernize RX / TX + kCmdModernFeaturesDisable = 200, // must be in object with kChannelMapModernize RX / TX + kCmdNumbericMax = 255, }; enum SSType @@ -175,11 +175,11 @@ enum SSType }; inline bool playerRXRngIsFine(int rx) { - return (rx >= kChannelPlayer0 && rx < kChannelPlayer7); + return (rx >= kChannelPlayer0 && rx < kChannelPlayer7); } inline bool channelRangeIsFine(int channel) { - return (channel >= kChannelUser && channel < kChannelUserMax); + return (channel >= kChannelUser && channel < kChannelUserMax); } struct EVENT @@ -214,19 +214,19 @@ struct EVENT return target.isWall(); } - DBloodActor* getActor() + DBloodActor* getActor() { assert(isActor()); return target.actor(); } - sectortype* getSector() + sectortype* getSector() { assert(isSector()); return target.sector(); } - walltype* getWall() + walltype* getWall() { assert(isWall()); return target.wall(); diff --git a/source/games/blood/src/fire.cpp b/source/games/blood/src/fire.cpp index 332f19670..96dfb7a7f 100644 --- a/source/games/blood/src/fire.cpp +++ b/source/games/blood/src/fire.cpp @@ -36,93 +36,123 @@ int gDamping = 6; uint8_t CoolTable[1024]; -void CellularFrame(uint8_t *pFrame, int sizeX, int sizeY); +void CellularFrame(uint8_t* pFrame, int sizeX, int sizeY); static uint8_t FrameBuffer[17280]; static uint8_t SeedBuffer[16][128]; static TArray gCLU; +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + void InitSeedBuffers(void) { - for (int i = 0; i < 16; i++) - for (int j = 0; j < fireSize; j += 2) - SeedBuffer[i][j] = SeedBuffer[i][j+1] = wrand(); + for (int i = 0; i < 16; i++) + for (int j = 0; j < fireSize; j += 2) + SeedBuffer[i][j] = SeedBuffer[i][j + 1] = wrand(); } void BuildCoolTable(void) { - for (int i = 0; i < 1024; i++) - CoolTable[i] = ClipLow((i-gDamping) / 4, 0); + for (int i = 0; i < 1024; i++) + CoolTable[i] = ClipLow((i - gDamping) / 4, 0); } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + void DoFireFrame(void) { - int nRand = qrand()&15; - for (int i = 0; i < 3; i++) - { - memcpy(FrameBuffer+16896+i*128, SeedBuffer[nRand], 128); - } - CellularFrame(FrameBuffer, 128, 132); + int nRand = qrand() & 15; + for (int i = 0; i < 3; i++) + { + memcpy(FrameBuffer + 16896 + i * 128, SeedBuffer[nRand], 128); + } + CellularFrame(FrameBuffer, 128, 132); auto pData = TileFiles.tileMakeWritable(2342); - uint8_t *pSource = FrameBuffer; - int x = fireSize; - do - { - int y = fireSize; - auto pDataBak = pData; - do - { - *pData = gCLU[*pSource]; - pSource++; - pData += fireSize; - } while (--y); - pData = pDataBak + 1; - } while (--x); + uint8_t* pSource = FrameBuffer; + int x = fireSize; + do + { + int y = fireSize; + auto pDataBak = pData; + do + { + *pData = gCLU[*pSource]; + pSource++; + pData += fireSize; + } while (--y); + pData = pDataBak + 1; + } while (--x); } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + void FireInit(void) { - memset(FrameBuffer, 0, sizeof(FrameBuffer)); - BuildCoolTable(); - InitSeedBuffers(); - auto fr = fileSystem.OpenFileReader("rfire.clu"); - if (!fr.isOpen()) - I_Error("RFIRE.CLU not found"); - gCLU = fr.Read(); - for (int i = 0; i < 100; i++) - DoFireFrame(); + memset(FrameBuffer, 0, sizeof(FrameBuffer)); + BuildCoolTable(); + InitSeedBuffers(); + auto fr = fileSystem.OpenFileReader("rfire.clu"); + if (!fr.isOpen()) + I_Error("RFIRE.CLU not found"); + gCLU = fr.Read(); + for (int i = 0; i < 100; i++) + DoFireFrame(); } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + void FireProcess(void) { // This assumes a smooth high frame rate. Ugh... - static int lastUpdate; - int clock = I_GetBuildTime()/ 2; - if (clock < lastUpdate || lastUpdate + 2 < clock) - { - DoFireFrame(); - lastUpdate = clock; - TileFiles.InvalidateTile(2342); - } + static int lastUpdate; + int clock = I_GetBuildTime() / 2; + if (clock < lastUpdate || lastUpdate + 2 < clock) + { + DoFireFrame(); + lastUpdate = clock; + TileFiles.InvalidateTile(2342); + } } -void CellularFrame(uint8_t *pFrame, int sizeX, int sizeY) +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void CellularFrame(uint8_t* pFrame, int sizeX, int sizeY) { - int nSquare = sizeX * sizeY; - uint8_t *pPtr1 = (uint8_t*)pFrame; - while (nSquare--) - { - uint8_t *pPtr2 = pPtr1+sizeX; - int sum = *(pPtr2-1) + *pPtr2 + *(pPtr2+1) + *(pPtr2+sizeX); - if (*(pPtr2+sizeX) > 96) - { - pPtr2 += sizeX; - sum += *(pPtr2-1) + *pPtr2 + *(pPtr2+1) + *(pPtr2+sizeX); - sum >>= 1; - } - *pPtr1 = CoolTable[sum]; - pPtr1++; - } + int nSquare = sizeX * sizeY; + uint8_t* pPtr1 = (uint8_t*)pFrame; + while (nSquare--) + { + uint8_t* pPtr2 = pPtr1 + sizeX; + int sum = *(pPtr2 - 1) + *pPtr2 + *(pPtr2 + 1) + *(pPtr2 + sizeX); + if (*(pPtr2 + sizeX) > 96) + { + pPtr2 += sizeX; + sum += *(pPtr2 - 1) + *pPtr2 + *(pPtr2 + 1) + *(pPtr2 + sizeX); + sum >>= 1; + } + *pPtr1 = CoolTable[sum]; + pPtr1++; + } } END_BLD_NS diff --git a/source/games/blood/src/fx.cpp b/source/games/blood/src/fx.cpp index c17ca4d60..b8fd49f2e 100644 --- a/source/games/blood/src/fx.cpp +++ b/source/games/blood/src/fx.cpp @@ -32,306 +32,354 @@ BEGIN_BLD_NS CFX gFX; struct FXDATA { - CALLBACK_ID funcID; // callback - uint8_t detail; // detail - int16_t seq; // seq - int16_t flags; // flags - int32_t gravity; // gravity - int32_t drag; // air drag - int32_t ate; - int16_t picnum; // picnum - uint8_t xrepeat; // xrepeat - uint8_t yrepeat; // yrepeat - ESpriteFlags cstat; // cstat - int8_t shade; // shade - uint8_t pal; // pal + CALLBACK_ID funcID; // callback + uint8_t detail; // detail + int16_t seq; // seq + int16_t flags; // flags + int32_t gravity; // gravity + int32_t drag; // air drag + int32_t ate; + int16_t picnum; // picnum + uint8_t xrepeat; // xrepeat + uint8_t yrepeat; // yrepeat + ESpriteFlags cstat; // cstat + int8_t shade; // shade + uint8_t pal; // pal }; FXDATA gFXData[] = { - { kCallbackNone, 0, 49, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 0, 50, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 0, 51, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 0, 52, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 0, 7, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 0, 44, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 0, 45, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 0, 46, 1, -128, 8192, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 2, 6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 2, 42, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 2, 43, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 1, 48, 3, -256, 8192, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 1, 60, 3, -256, 8192, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackFXBloodBits, 2, 0, 1, 46603, 2048, 480, 2154, 40, 40, 0, -12, 0 }, - { kCallbackNone, 2, 0, 3, 46603, 5120, 480, 2269, 24, 24, 0, -128, 0 }, - { kCallbackNone, 2, 0, 3, 46603, 5120, 480, 1720, 24, 24, 0, -128, 0 }, - { kCallbackNone, 1, 0, 1, 58254, 3072, 480, 2280, 48, 48, 0, -128, 0 }, - { kCallbackNone, 1, 0, 1, 58254, 3072, 480, 3135, 48, 48, 0, -128, 0 }, - { kCallbackNone, 0, 0, 3, 58254, 1024, 480, 3261, 32, 32, 0, 0, 0 }, - { kCallbackNone, 1, 0, 3, 58254, 1024, 480, 3265, 32, 32, 0, 0, 0 }, - { kCallbackNone, 1, 0, 3, 58254, 1024, 480, 3269, 32, 32, 0, 0, 0 }, - { kCallbackNone, 1, 0, 3, 58254, 1024, 480, 3273, 32, 32, 0, 0, 0 }, - { kCallbackNone, 1, 0, 3, 58254, 1024, 480, 3277, 32, 32, 0, 0, 0 }, - { kCallbackNone, 2, 0, 1, -27962, 8192, 600, 1128, 16, 16, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP, -16, 0 }, // bubble 1 - { kCallbackNone, 2, 0, 1, -18641, 8192, 600, 1128, 12, 12, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP, -16, 0 }, // bubble 2 - { kCallbackNone, 2, 0, 1, -9320, 8192, 600, 1128, 8, 8, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP, -16, 0 }, // bubble 3 - { kCallbackNone, 2, 0, 1, -18641, 8192, 600, 1131, 32, 32, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP, -16, 0 }, - { kCallbackFXBloodBits, 2, 0, 3, 27962, 4096, 480, 733, 32, 32, 0, -16, 0 }, - { kCallbackNone, 1, 0, 3, 18641, 4096, 120, 2261, 12, 12, 0, -128, 0 }, - { kCallbackNone, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 1, 0, 3, 58254, 3328, 480, 2185, 48, 48, 0, 0, 0 }, - { kCallbackNone, 0, 0, 3, 58254, 1024, 480, 2620, 48, 48, 0, 0, 0 }, - { kCallbackNone, 1, 55, 1, -13981, 5120, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 1, 56, 1, -13981, 5120, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 1, 57, 1, 0, 2048, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 1, 58, 1, 0, 2048, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 2, 0, 0, 0, 0, 960, 956, 32, 32, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_FLOOR, 0, 0 }, - { kCallbackFXBouncingSleeve, 2, 62, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackFXBouncingSleeve, 2, 63, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackFXBouncingSleeve, 2, 64, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackFXBouncingSleeve, 2, 65, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackFXBouncingSleeve, 2, 66, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackFXBouncingSleeve, 2, 67, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 1, 0, 3, 0, 0, 0, 838, 16, 16, CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_WALL, -8, 0 }, - { kCallbackNone, 0, 0, 3, 34952, 8192, 0, 2078, 64, 64, 0, -8, 0 }, - { kCallbackNone, 0, 0, 3, 34952, 8192, 0, 1106, 64, 64, 0, -8, 0 }, - { kCallbackNone, 0, 0, 3, 58254, 3328, 480, 2406, 48, 48, 0, 0, 0 }, - { kCallbackNone, 1, 0, 3, 46603, 4096, 480, 3511, 64, 64, 0, -128, 0 }, - { kCallbackNone, 0, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 2, 11, 3, -256, 8192, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 2, 11, 3, 0, 8192, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 1, 30, 3, 0, 0, 0, 0, 40, 40, CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_WALL, -8, 0 }, - { kCallbackFXPodBloodSplat, 2, 0, 3, 27962, 4096, 480, 4023, 32, 32, 0, -16, 0 }, - { kCallbackFXPodBloodSplat, 2, 0, 3, 27962, 4096, 480, 4028, 32, 32, 0, -16, 0 }, - { kCallbackNone, 2, 0, 0, 0, 0, 480, 926, 32, 32, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_FLOOR, -12, 0 }, - { kCallbackNone, 1, 70, 1, -13981, 5120, 0, 0, 0, 0, 0, 0, 0 } + { kCallbackNone, 0, 49, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 0, 50, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 0, 51, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 0, 52, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 0, 7, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 0, 44, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 0, 45, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 0, 46, 1, -128, 8192, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 2, 6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 2, 42, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 2, 43, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 1, 48, 3, -256, 8192, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 1, 60, 3, -256, 8192, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackFXBloodBits, 2, 0, 1, 46603, 2048, 480, 2154, 40, 40, 0, -12, 0 }, + { kCallbackNone, 2, 0, 3, 46603, 5120, 480, 2269, 24, 24, 0, -128, 0 }, + { kCallbackNone, 2, 0, 3, 46603, 5120, 480, 1720, 24, 24, 0, -128, 0 }, + { kCallbackNone, 1, 0, 1, 58254, 3072, 480, 2280, 48, 48, 0, -128, 0 }, + { kCallbackNone, 1, 0, 1, 58254, 3072, 480, 3135, 48, 48, 0, -128, 0 }, + { kCallbackNone, 0, 0, 3, 58254, 1024, 480, 3261, 32, 32, 0, 0, 0 }, + { kCallbackNone, 1, 0, 3, 58254, 1024, 480, 3265, 32, 32, 0, 0, 0 }, + { kCallbackNone, 1, 0, 3, 58254, 1024, 480, 3269, 32, 32, 0, 0, 0 }, + { kCallbackNone, 1, 0, 3, 58254, 1024, 480, 3273, 32, 32, 0, 0, 0 }, + { kCallbackNone, 1, 0, 3, 58254, 1024, 480, 3277, 32, 32, 0, 0, 0 }, + { kCallbackNone, 2, 0, 1, -27962, 8192, 600, 1128, 16, 16, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP, -16, 0 }, // bubble 1 + { kCallbackNone, 2, 0, 1, -18641, 8192, 600, 1128, 12, 12, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP, -16, 0 }, // bubble 2 + { kCallbackNone, 2, 0, 1, -9320, 8192, 600, 1128, 8, 8, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP, -16, 0 }, // bubble 3 + { kCallbackNone, 2, 0, 1, -18641, 8192, 600, 1131, 32, 32, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP, -16, 0 }, + { kCallbackFXBloodBits, 2, 0, 3, 27962, 4096, 480, 733, 32, 32, 0, -16, 0 }, + { kCallbackNone, 1, 0, 3, 18641, 4096, 120, 2261, 12, 12, 0, -128, 0 }, + { kCallbackNone, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 1, 0, 3, 58254, 3328, 480, 2185, 48, 48, 0, 0, 0 }, + { kCallbackNone, 0, 0, 3, 58254, 1024, 480, 2620, 48, 48, 0, 0, 0 }, + { kCallbackNone, 1, 55, 1, -13981, 5120, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 1, 56, 1, -13981, 5120, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 1, 57, 1, 0, 2048, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 1, 58, 1, 0, 2048, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 2, 0, 0, 0, 0, 960, 956, 32, 32, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_FLOOR, 0, 0 }, + { kCallbackFXBouncingSleeve, 2, 62, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackFXBouncingSleeve, 2, 63, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackFXBouncingSleeve, 2, 64, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackFXBouncingSleeve, 2, 65, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackFXBouncingSleeve, 2, 66, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackFXBouncingSleeve, 2, 67, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 1, 0, 3, 0, 0, 0, 838, 16, 16, CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_WALL, -8, 0 }, + { kCallbackNone, 0, 0, 3, 34952, 8192, 0, 2078, 64, 64, 0, -8, 0 }, + { kCallbackNone, 0, 0, 3, 34952, 8192, 0, 1106, 64, 64, 0, -8, 0 }, + { kCallbackNone, 0, 0, 3, 58254, 3328, 480, 2406, 48, 48, 0, 0, 0 }, + { kCallbackNone, 1, 0, 3, 46603, 4096, 480, 3511, 64, 64, 0, -128, 0 }, + { kCallbackNone, 0, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 2, 11, 3, -256, 8192, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 2, 11, 3, 0, 8192, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { kCallbackNone, 1, 30, 3, 0, 0, 0, 0, 40, 40, CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_WALL, -8, 0 }, + { kCallbackFXPodBloodSplat, 2, 0, 3, 27962, 4096, 480, 4023, 32, 32, 0, -16, 0 }, + { kCallbackFXPodBloodSplat, 2, 0, 3, 27962, 4096, 480, 4028, 32, 32, 0, -16, 0 }, + { kCallbackNone, 2, 0, 0, 0, 0, 480, 926, 32, 32, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_FLOOR, -12, 0 }, + { kCallbackNone, 1, 70, 1, -13981, 5120, 0, 0, 0, 0, 0, 0, 0 } }; +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + void CFX::destroy(DBloodActor* actor) { - if (!actor) return; - evKillActor(actor); - if (actor->hasX()) seqKill(actor); - DeleteSprite(actor); + if (!actor) return; + evKillActor(actor); + if (actor->hasX()) seqKill(actor); + DeleteSprite(actor); } void CFX::remove(DBloodActor* actor) { - if (!actor) return; - if (actor->hasX()) seqKill(actor); - if (actor->spr.statnum != kStatFree) - actPostSprite(actor, kStatFree); + if (!actor) return; + if (actor->hasX()) seqKill(actor); + if (actor->spr.statnum != kStatFree) + actPostSprite(actor, kStatFree); } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + DBloodActor* CFX::fxSpawnActor(FX_ID nFx, sectortype* pSector, int x, int y, int z, unsigned int a6) { - if (pSector == nullptr) - return nullptr; - auto pSector2 = pSector; - if (!FindSector(x, y, z, &pSector2)) - return nullptr; - if (adult_lockout && gGameOptions.nGameType <= 0) - { - switch (nFx) - { - case FX_0: - case FX_1: - case FX_2: - case FX_3: - case FX_13: - case FX_34: - case FX_35: - case FX_36: - return nullptr; - default: - break; - } - } - if (nFx < 0 || nFx >= kFXMax) - return nullptr; - FXDATA *pFX = &gFXData[nFx]; + if (pSector == nullptr) + return nullptr; + auto pSector2 = pSector; + if (!FindSector(x, y, z, &pSector2)) + return nullptr; + if (adult_lockout && gGameOptions.nGameType <= 0) + { + switch (nFx) + { + case FX_0: + case FX_1: + case FX_2: + case FX_3: + case FX_13: + case FX_34: + case FX_35: + case FX_36: + return nullptr; + default: + break; + } + } + if (nFx < 0 || nFx >= kFXMax) + return nullptr; + FXDATA* pFX = &gFXData[nFx]; - auto actor = actSpawnSprite(pSector, x, y, z, 1, 0); + auto actor = actSpawnSprite(pSector, x, y, z, 1, 0); - actor->spr.type = nFx; - actor->spr.picnum = pFX->picnum; - actor->spr.cstat |= pFX->cstat; - actor->spr.shade = pFX->shade; - actor->spr.pal = pFX->pal; - actor->spr.detail = pFX->detail; - if (pFX->xrepeat > 0) - actor->spr.xrepeat = pFX->xrepeat; - if (pFX->yrepeat > 0) - actor->spr.yrepeat = pFX->yrepeat; - if ((pFX->flags & 1) && Chance(0x8000)) - actor->spr.cstat |= CSTAT_SPRITE_XFLIP; - if ((pFX->flags & 2) && Chance(0x8000)) - actor->spr.cstat |= CSTAT_SPRITE_YFLIP; - if (pFX->seq) - { - actor->addX(); - seqSpawn(pFX->seq, actor, -1); - } - if (a6 == 0) - a6 = pFX->ate; - if (a6) - evPostActor(actor, a6+Random2(a6>>1), kCallbackRemove); - return actor; + actor->spr.type = nFx; + actor->spr.picnum = pFX->picnum; + actor->spr.cstat |= pFX->cstat; + actor->spr.shade = pFX->shade; + actor->spr.pal = pFX->pal; + actor->spr.detail = pFX->detail; + if (pFX->xrepeat > 0) + actor->spr.xrepeat = pFX->xrepeat; + if (pFX->yrepeat > 0) + actor->spr.yrepeat = pFX->yrepeat; + if ((pFX->flags & 1) && Chance(0x8000)) + actor->spr.cstat |= CSTAT_SPRITE_XFLIP; + if ((pFX->flags & 2) && Chance(0x8000)) + actor->spr.cstat |= CSTAT_SPRITE_YFLIP; + if (pFX->seq) + { + actor->addX(); + seqSpawn(pFX->seq, actor, -1); + } + if (a6 == 0) + a6 = pFX->ate; + if (a6) + evPostActor(actor, a6 + Random2(a6 >> 1), kCallbackRemove); + return actor; } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + void CFX::fxProcess(void) { - BloodStatIterator it(kStatFX); - while (auto actor = it.Next()) - { - viewBackupSpriteLoc(actor); - auto pSector = actor->spr.sector(); - assert(pSector); - assert(actor->spr.type < kFXMax); - FXDATA *pFXData = &gFXData[actor->spr.type]; - actAirDrag(actor, pFXData->drag); - actor->spr.pos.X += actor->xvel>>12; - actor->spr.pos.Y += actor->yvel>>12; - actor->spr.pos.Z += actor->zvel>>8; - // Weird... - if (actor->xvel || (actor->yvel && actor->spr.pos.Z >= actor->spr.sector()->floorz)) - { - updatesector(actor->spr.pos.X, actor->spr.pos.Y, &pSector); - if (pSector == nullptr) - { - remove(actor); - continue; - } - if (getflorzofslopeptr(actor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y) <= actor->spr.pos.Z) - { - if (pFXData->funcID < 0 || pFXData->funcID >= kCallbackMax) - { - remove(actor); - continue; - } - gCallback[pFXData->funcID](actor, nullptr); - continue; - } - if (pSector != actor->spr.sector()) - { - assert(pSector); - ChangeActorSect(actor, pSector); - } - } - if (actor->xvel || actor->yvel || actor->zvel) - { - int32_t floorZ, ceilZ; - getzsofslopeptr(pSector, actor->spr.pos.X, actor->spr.pos.Y, &ceilZ, &floorZ); - if (ceilZ > actor->spr.pos.Z && !(pSector->ceilingstat & CSTAT_SECTOR_SKY)) - { - remove(actor); - continue; - } - if (floorZ < actor->spr.pos.Z) - { - if (pFXData->funcID < 0 || pFXData->funcID >= kCallbackMax) - { - remove(actor); - continue; - } - gCallback[pFXData->funcID](actor, nullptr); - continue; - } - } - actor->zvel += pFXData->gravity; - } + BloodStatIterator it(kStatFX); + while (auto actor = it.Next()) + { + viewBackupSpriteLoc(actor); + auto pSector = actor->spr.sector(); + assert(pSector); + assert(actor->spr.type < kFXMax); + FXDATA* pFXData = &gFXData[actor->spr.type]; + actAirDrag(actor, pFXData->drag); + actor->spr.pos.X += actor->xvel >> 12; + actor->spr.pos.Y += actor->yvel >> 12; + actor->spr.pos.Z += actor->zvel >> 8; + // Weird... + if (actor->xvel || (actor->yvel && actor->spr.pos.Z >= actor->spr.sector()->floorz)) + { + updatesector(actor->spr.pos.X, actor->spr.pos.Y, &pSector); + if (pSector == nullptr) + { + remove(actor); + continue; + } + if (getflorzofslopeptr(actor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y) <= actor->spr.pos.Z) + { + if (pFXData->funcID < 0 || pFXData->funcID >= kCallbackMax) + { + remove(actor); + continue; + } + gCallback[pFXData->funcID](actor, nullptr); + continue; + } + if (pSector != actor->spr.sector()) + { + assert(pSector); + ChangeActorSect(actor, pSector); + } + } + if (actor->xvel || actor->yvel || actor->zvel) + { + int32_t floorZ, ceilZ; + getzsofslopeptr(pSector, actor->spr.pos.X, actor->spr.pos.Y, &ceilZ, &floorZ); + if (ceilZ > actor->spr.pos.Z && !(pSector->ceilingstat & CSTAT_SECTOR_SKY)) + { + remove(actor); + continue; + } + if (floorZ < actor->spr.pos.Z) + { + if (pFXData->funcID < 0 || pFXData->funcID >= kCallbackMax) + { + remove(actor); + continue; + } + gCallback[pFXData->funcID](actor, nullptr); + continue; + } + } + actor->zvel += pFXData->gravity; + } } -void fxSpawnBlood(DBloodActor *actor, int ) +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void fxSpawnBlood(DBloodActor* actor, int) { - if (!actor->spr.insector()) - return; - auto pSector = actor->spr.sector(); - if (!FindSector(actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, &pSector)) - return; - if (adult_lockout && gGameOptions.nGameType <= 0) - return; - auto bloodactor = gFX.fxSpawnActor(FX_27, actor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, 0); - if (bloodactor) - { - bloodactor->spr.ang = 1024; - bloodactor->xvel = Random2(0x6aaaa); - bloodactor->yvel = Random2(0x6aaaa); - bloodactor->zvel = -(int)Random(0x10aaaa)-100; - evPostActor(bloodactor, 8, kCallbackFXBloodSpurt); - } + if (!actor->spr.insector()) + return; + auto pSector = actor->spr.sector(); + if (!FindSector(actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, &pSector)) + return; + if (adult_lockout && gGameOptions.nGameType <= 0) + return; + auto bloodactor = gFX.fxSpawnActor(FX_27, actor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, 0); + if (bloodactor) + { + bloodactor->spr.ang = 1024; + bloodactor->xvel = Random2(0x6aaaa); + bloodactor->yvel = Random2(0x6aaaa); + bloodactor->zvel = -(int)Random(0x10aaaa) - 100; + evPostActor(bloodactor, 8, kCallbackFXBloodSpurt); + } } -void fxSpawnPodStuff(DBloodActor* actor, int ) +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void fxSpawnPodStuff(DBloodActor* actor, int) { - if (!actor->spr.insector()) - return; - auto pSector = actor->spr.sector(); - if (!FindSector(actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, &pSector)) - return; - if (adult_lockout && gGameOptions.nGameType <= 0) - return; - DBloodActor *spawnactor; - if (actor->spr.type == kDudePodGreen) - spawnactor = gFX.fxSpawnActor(FX_53, actor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, 0); - else - spawnactor = gFX.fxSpawnActor(FX_54, actor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, 0); - if (spawnactor) - { - spawnactor->spr.ang = 1024; - spawnactor->xvel = Random2(0x6aaaa); - spawnactor->yvel = Random2(0x6aaaa); - spawnactor->zvel = -(int)Random(0x10aaaa)-100; - evPostActor(spawnactor, 8, kCallbackFXPodBloodSpray); - } + if (!actor->spr.insector()) + return; + auto pSector = actor->spr.sector(); + if (!FindSector(actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, &pSector)) + return; + if (adult_lockout && gGameOptions.nGameType <= 0) + return; + DBloodActor* spawnactor; + if (actor->spr.type == kDudePodGreen) + spawnactor = gFX.fxSpawnActor(FX_53, actor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, 0); + else + spawnactor = gFX.fxSpawnActor(FX_54, actor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, 0); + if (spawnactor) + { + spawnactor->spr.ang = 1024; + spawnactor->xvel = Random2(0x6aaaa); + spawnactor->yvel = Random2(0x6aaaa); + spawnactor->zvel = -(int)Random(0x10aaaa) - 100; + evPostActor(spawnactor, 8, kCallbackFXPodBloodSpray); + } } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + void fxSpawnEjectingBrass(DBloodActor* actor, int z, int a3, int a4) { - int x = actor->spr.pos.X + MulScale(actor->spr.clipdist - 4, Cos(actor->spr.ang), 28); - int y = actor->spr.pos.Y + MulScale(actor->spr.clipdist - 4, Sin(actor->spr.ang), 28); - x += MulScale(a3, Cos(actor->spr.ang + 512), 30); - y += MulScale(a3, Sin(actor->spr.ang + 512), 30); - auto pBrass = gFX.fxSpawnActor((FX_ID)(FX_37 + Random(3)), actor->spr.sector(), x, y, z, 0); - if (pBrass) - { - if (!VanillaMode()) - pBrass->spr.ang = Random(2047); - int nDist = (a4 << 18) / 120 + Random2(((a4 / 4) << 18) / 120); - int nAngle = actor->spr.ang + Random2(56) + 512; - pBrass->xvel = MulScale(nDist, Cos(nAngle), 30); - pBrass->yvel = MulScale(nDist, Sin(nAngle), 30); - pBrass->zvel = actor->zvel - (0x20000 + (Random2(40) << 18) / 120); - } + int x = actor->spr.pos.X + MulScale(actor->spr.clipdist - 4, Cos(actor->spr.ang), 28); + int y = actor->spr.pos.Y + MulScale(actor->spr.clipdist - 4, Sin(actor->spr.ang), 28); + x += MulScale(a3, Cos(actor->spr.ang + 512), 30); + y += MulScale(a3, Sin(actor->spr.ang + 512), 30); + auto pBrass = gFX.fxSpawnActor((FX_ID)(FX_37 + Random(3)), actor->spr.sector(), x, y, z, 0); + if (pBrass) + { + if (!VanillaMode()) + pBrass->spr.ang = Random(2047); + int nDist = (a4 << 18) / 120 + Random2(((a4 / 4) << 18) / 120); + int nAngle = actor->spr.ang + Random2(56) + 512; + pBrass->xvel = MulScale(nDist, Cos(nAngle), 30); + pBrass->yvel = MulScale(nDist, Sin(nAngle), 30); + pBrass->zvel = actor->zvel - (0x20000 + (Random2(40) << 18) / 120); + } } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + void fxSpawnEjectingShell(DBloodActor* actor, int z, int a3, int a4) { - int x = actor->spr.pos.X + MulScale(actor->spr.clipdist - 4, Cos(actor->spr.ang), 28); - int y = actor->spr.pos.Y + MulScale(actor->spr.clipdist - 4, Sin(actor->spr.ang), 28); - x += MulScale(a3, Cos(actor->spr.ang + 512), 30); - y += MulScale(a3, Sin(actor->spr.ang + 512), 30); - auto pShell = gFX.fxSpawnActor((FX_ID)(FX_40 + Random(3)), actor->spr.sector(), x, y, z, 0); - if (pShell) - { - if (!VanillaMode()) - pShell->spr.ang = Random(2047); - int nDist = (a4 << 18) / 120 + Random2(((a4 / 4) << 18) / 120); - int nAngle = actor->spr.ang + Random2(56) + 512; - pShell->xvel = MulScale(nDist, Cos(nAngle), 30); - pShell->yvel = MulScale(nDist, Sin(nAngle), 30); - pShell->zvel = actor->zvel - (0x20000 + (Random2(20) << 18) / 120); - } + int x = actor->spr.pos.X + MulScale(actor->spr.clipdist - 4, Cos(actor->spr.ang), 28); + int y = actor->spr.pos.Y + MulScale(actor->spr.clipdist - 4, Sin(actor->spr.ang), 28); + x += MulScale(a3, Cos(actor->spr.ang + 512), 30); + y += MulScale(a3, Sin(actor->spr.ang + 512), 30); + auto pShell = gFX.fxSpawnActor((FX_ID)(FX_40 + Random(3)), actor->spr.sector(), x, y, z, 0); + if (pShell) + { + if (!VanillaMode()) + pShell->spr.ang = Random(2047); + int nDist = (a4 << 18) / 120 + Random2(((a4 / 4) << 18) / 120); + int nAngle = actor->spr.ang + Random2(56) + 512; + pShell->xvel = MulScale(nDist, Cos(nAngle), 30); + pShell->yvel = MulScale(nDist, Sin(nAngle), 30); + pShell->zvel = actor->zvel - (0x20000 + (Random2(20) << 18) / 120); + } } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + void fxPrecache() { - for (int i = 0; i < kFXMax; i++) - { - tilePrecacheTile(gFXData[i].picnum, 0, 0); - if (gFXData[i].seq) - seqPrecacheId(gFXData[i].seq, 0); - } + for (int i = 0; i < kFXMax; i++) + { + tilePrecacheTile(gFXData[i].picnum, 0, 0); + if (gFXData[i].seq) + seqPrecacheId(gFXData[i].seq, 0); + } } END_BLD_NS diff --git a/source/games/blood/src/fx.h b/source/games/blood/src/fx.h index ed1ef8a3d..8c70eb9e9 100644 --- a/source/games/blood/src/fx.h +++ b/source/games/blood/src/fx.h @@ -28,79 +28,79 @@ BEGIN_BLD_NS enum FX_ID { - FX_NONE = -1, - FX_0 = 0, - FX_1, - FX_2, - FX_3, - FX_4, - FX_5, - FX_6, - FX_7, - FX_8, - FX_9, - FX_10, - FX_11, - FX_12, - FX_13, - FX_14, - FX_15, - FX_16, - FX_17, - FX_18, - FX_19, - FX_20, - FX_21, - FX_22, - FX_23, - FX_24, - FX_25, - FX_26, - FX_27, - FX_28, - FX_29, - FX_30, - FX_31, - FX_32, - FX_33, - FX_34, - FX_35, - FX_36, - FX_37, - FX_38, - FX_39, - FX_40, - FX_41, - FX_42, - FX_43, - FX_44, - FX_45, - FX_46, - FX_47, - FX_48, - FX_49, - FX_50, - FX_51, - FX_52, - FX_53, - FX_54, - FX_55, - FX_56, - kFXMax + FX_NONE = -1, + FX_0 = 0, + FX_1, + FX_2, + FX_3, + FX_4, + FX_5, + FX_6, + FX_7, + FX_8, + FX_9, + FX_10, + FX_11, + FX_12, + FX_13, + FX_14, + FX_15, + FX_16, + FX_17, + FX_18, + FX_19, + FX_20, + FX_21, + FX_22, + FX_23, + FX_24, + FX_25, + FX_26, + FX_27, + FX_28, + FX_29, + FX_30, + FX_31, + FX_32, + FX_33, + FX_34, + FX_35, + FX_36, + FX_37, + FX_38, + FX_39, + FX_40, + FX_41, + FX_42, + FX_43, + FX_44, + FX_45, + FX_46, + FX_47, + FX_48, + FX_49, + FX_50, + FX_51, + FX_52, + FX_53, + FX_54, + FX_55, + FX_56, + kFXMax }; class CFX { public: - void destroy(DBloodActor*); - void remove(DBloodActor*); - DBloodActor* fxSpawnActor(FX_ID a, sectortype* b, int c, int d, int e, unsigned int f); - void fxProcess(void); + void destroy(DBloodActor*); + void remove(DBloodActor*); + DBloodActor* fxSpawnActor(FX_ID a, sectortype* b, int c, int d, int e, unsigned int f); + void fxProcess(void); }; void fxSpawnBlood(DBloodActor* pSprite, int a2); -void fxSpawnPodStuff(DBloodActor *pSprite, int a2); -void fxSpawnEjectingBrass(DBloodActor*pSprite, int z, int a3, int a4); -void fxSpawnEjectingShell(DBloodActor*pSprite, int z, int a3, int a4); +void fxSpawnPodStuff(DBloodActor* pSprite, int a2); +void fxSpawnEjectingBrass(DBloodActor* pSprite, int z, int a3, int a4); +void fxSpawnEjectingShell(DBloodActor* pSprite, int z, int a3, int a4); extern CFX gFX; diff --git a/source/games/blood/src/gameutil.cpp b/source/games/blood/src/gameutil.cpp index 60f2a5710..2c50b2338 100644 --- a/source/games/blood/src/gameutil.cpp +++ b/source/games/blood/src/gameutil.cpp @@ -35,704 +35,794 @@ BEGIN_BLD_NS HitInfo gHitInfo; +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + bool FindSector(int nX, int nY, int nZ, sectortype** pSector) { - int32_t nZFloor, nZCeil; + int32_t nZFloor, nZCeil; assert(pSector); - if (inside(nX, nY, *pSector)) - { - getzsofslopeptr(*pSector, nX, nY, &nZCeil, &nZFloor); - if (nZ >= nZCeil && nZ <= nZFloor) - { - return 1; - } - } - for (auto& wal : wallsofsector(*pSector)) - { - auto pOSector = wal.nextSector(); - if (pOSector != nullptr && inside(nX, nY, pOSector)) - { - getzsofslopeptr(pOSector, nX, nY, &nZCeil, &nZFloor); - if (nZ >= nZCeil && nZ <= nZFloor) - { - *pSector = pOSector; - return 1; - } - } - } - for(auto& sec: sector) - { - if (inside(nX, nY, &sec)) - { - getzsofslopeptr(&sec, nX, nY, &nZCeil, &nZFloor); - if (nZ >= nZCeil && nZ <= nZFloor) - { - *pSector = &sec; - return 1; - } - } - } - return 0; + if (inside(nX, nY, *pSector)) + { + getzsofslopeptr(*pSector, nX, nY, &nZCeil, &nZFloor); + if (nZ >= nZCeil && nZ <= nZFloor) + { + return 1; + } + } + for (auto& wal : wallsofsector(*pSector)) + { + auto pOSector = wal.nextSector(); + if (pOSector != nullptr && inside(nX, nY, pOSector)) + { + getzsofslopeptr(pOSector, nX, nY, &nZCeil, &nZFloor); + if (nZ >= nZCeil && nZ <= nZFloor) + { + *pSector = pOSector; + return 1; + } + } + } + for (auto& sec : sector) + { + if (inside(nX, nY, &sec)) + { + getzsofslopeptr(&sec, nX, nY, &nZCeil, &nZFloor); + if (nZ >= nZCeil && nZ <= nZFloor) + { + *pSector = &sec; + return 1; + } + } + } + return 0; } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + bool FindSector(int nX, int nY, sectortype** pSector) { assert(*pSector); - if (inside(nX, nY, *pSector)) - { - return 1; - } - for (auto& wal : wallsofsector(*pSector)) - { - auto pOSector = wal.nextSector(); - if (pOSector != nullptr && inside(nX, nY, pOSector)) - { - *pSector = pOSector; - return 1; - } - } - for (auto& sec: sector) - { - if (inside(nX, nY, &sec)) - { - *pSector = &sec; - return 1; - } - } - return 0; + if (inside(nX, nY, *pSector)) + { + return 1; + } + for (auto& wal : wallsofsector(*pSector)) + { + auto pOSector = wal.nextSector(); + if (pOSector != nullptr && inside(nX, nY, pOSector)) + { + *pSector = pOSector; + return 1; + } + } + for (auto& sec : sector) + { + if (inside(nX, nY, &sec)) + { + *pSector = &sec; + return 1; + } + } + return 0; } -bool CheckProximity(DBloodActor *actor, int nX, int nY, int nZ, sectortype* pSector, int nDist) +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +bool CheckProximity(DBloodActor* actor, int nX, int nY, int nZ, sectortype* pSector, int nDist) { - assert(actor != nullptr); - int oX = abs(nX-actor->spr.pos.X)>>4; - if (oX >= nDist) return 0; + assert(actor != nullptr); + int oX = abs(nX - actor->spr.pos.X) >> 4; + if (oX >= nDist) return 0; - int oY = abs(nY-actor->spr.pos.Y)>>4; - if (oY >= nDist) return 0; + int oY = abs(nY - actor->spr.pos.Y) >> 4; + if (oY >= nDist) return 0; - int oZ = abs(nZ-actor->spr.pos.Z)>>8; - if (oZ >= nDist) return 0; + int oZ = abs(nZ - actor->spr.pos.Z) >> 8; + if (oZ >= nDist) return 0; - if (approxDist(oX, oY) >= nDist) return 0; + if (approxDist(oX, oY) >= nDist) return 0; - int bottom, top; - GetActorExtents(actor, &top, &bottom); - if (cansee(actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, actor->spr.sector(), nX, nY, nZ, pSector)) - return 1; - if (cansee(actor->spr.pos.X, actor->spr.pos.Y, bottom, actor->spr.sector(), nX, nY, nZ, pSector)) - return 1; - if (cansee(actor->spr.pos.X, actor->spr.pos.Y, top, actor->spr.sector(), nX, nY, nZ, pSector)) - return 1; - return 0; + int bottom, top; + GetActorExtents(actor, &top, &bottom); + if (cansee(actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, actor->spr.sector(), nX, nY, nZ, pSector)) + return 1; + if (cansee(actor->spr.pos.X, actor->spr.pos.Y, bottom, actor->spr.sector(), nX, nY, nZ, pSector)) + return 1; + if (cansee(actor->spr.pos.X, actor->spr.pos.Y, top, actor->spr.sector(), nX, nY, nZ, pSector)) + return 1; + return 0; } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + bool CheckProximityPoint(int nX1, int nY1, int nZ1, int nX2, int nY2, int nZ2, int nDist) { - int oX = abs(nX2-nX1)>>4; - if (oX >= nDist) - return 0; - int oY = abs(nY2-nY1)>>4; - if (oY >= nDist) - return 0; - if (nZ2 != nZ1) - { - int oZ = abs(nZ2-nZ1)>>8; - if (oZ >= nDist) - return 0; - } - if (approxDist(oX, oY) >= nDist) return 0; - return 1; + int oX = abs(nX2 - nX1) >> 4; + if (oX >= nDist) + return 0; + int oY = abs(nY2 - nY1) >> 4; + if (oY >= nDist) + return 0; + if (nZ2 != nZ1) + { + int oZ = abs(nZ2 - nZ1) >> 8; + if (oZ >= nDist) + return 0; + } + if (approxDist(oX, oY) >= nDist) return 0; + return 1; } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + bool CheckProximityWall(walltype* pWall, int x, int y, int nDist) { - int x1 = pWall->pos.X; - int y1 = pWall->pos.Y; - int x2 = pWall->point2Wall()->pos.X; - int y2 = pWall->point2Wall()->pos.Y; - nDist <<= 4; - if (x1 < x2) - { - if (x <= x1 - nDist || x >= x2 + nDist) - { - return 0; - } - } - else - { - if (x <= x2 - nDist || x >= x1 + nDist) - { - return 0; - } - if (x1 == x2) - { - int px1 = x - x1; - int py1 = y - y1; - int px2 = x - x2; - int py2 = y - y2; - int dist1 = px1 * px1 + py1 * py1; - int dist2 = px2 * px2 + py2 * py2; - if (y1 < y2) - { - if (y <= y1 - nDist || y >= y2 + nDist) - { - return 0; - } - if (y < y1) - { - return dist1 < nDist * nDist; - } - if (y > y2) - { - return dist2 < nDist * nDist; - } - } - else - { - if (y <= y2 - nDist || y >= y1 + nDist) - { - return 0; - } - if (y < y2) - { - return dist2 < nDist * nDist; - } - if (y > y1) - { - return dist1 < nDist * nDist; - } - } - return 1; - } - } - if (y1 < y2) - { - if (y <= y1 - nDist || y >= y2 + nDist) - { - return 0; - } - } - else - { - if (y <= y2 - nDist || y >= y1 + nDist) - { - return 0; - } - if (y1 == y2) - { - int px1 = x - x1; - int py1 = y - y1; - int px2 = x - x2; - int py2 = y - y2; - int check1 = px1 * px1 + py1 * py1; - int check2 = px2 * px2 + py2 * py2; - if (x1 < x2) - { - if (x <= x1 - nDist || x >= x2 + nDist) - { - return 0; - } - if (x < x1) - { - return check1 < nDist * nDist; - } - if (x > x2) - { - return check2 < nDist * nDist; - } - } - else - { - if (x <= x2 - nDist || x >= x1 + nDist) - { - return 0; - } - if (x < x2) - { - return check2 < nDist * nDist; - } - if (x > x1) - { - return check1 < nDist * nDist; - } - } - } - } + int x1 = pWall->pos.X; + int y1 = pWall->pos.Y; + int x2 = pWall->point2Wall()->pos.X; + int y2 = pWall->point2Wall()->pos.Y; + nDist <<= 4; + if (x1 < x2) + { + if (x <= x1 - nDist || x >= x2 + nDist) + { + return 0; + } + } + else + { + if (x <= x2 - nDist || x >= x1 + nDist) + { + return 0; + } + if (x1 == x2) + { + int px1 = x - x1; + int py1 = y - y1; + int px2 = x - x2; + int py2 = y - y2; + int dist1 = px1 * px1 + py1 * py1; + int dist2 = px2 * px2 + py2 * py2; + if (y1 < y2) + { + if (y <= y1 - nDist || y >= y2 + nDist) + { + return 0; + } + if (y < y1) + { + return dist1 < nDist* nDist; + } + if (y > y2) + { + return dist2 < nDist* nDist; + } + } + else + { + if (y <= y2 - nDist || y >= y1 + nDist) + { + return 0; + } + if (y < y2) + { + return dist2 < nDist* nDist; + } + if (y > y1) + { + return dist1 < nDist* nDist; + } + } + return 1; + } + } + if (y1 < y2) + { + if (y <= y1 - nDist || y >= y2 + nDist) + { + return 0; + } + } + else + { + if (y <= y2 - nDist || y >= y1 + nDist) + { + return 0; + } + if (y1 == y2) + { + int px1 = x - x1; + int py1 = y - y1; + int px2 = x - x2; + int py2 = y - y2; + int check1 = px1 * px1 + py1 * py1; + int check2 = px2 * px2 + py2 * py2; + if (x1 < x2) + { + if (x <= x1 - nDist || x >= x2 + nDist) + { + return 0; + } + if (x < x1) + { + return check1 < nDist* nDist; + } + if (x > x2) + { + return check2 < nDist* nDist; + } + } + else + { + if (x <= x2 - nDist || x >= x1 + nDist) + { + return 0; + } + if (x < x2) + { + return check2 < nDist* nDist; + } + if (x > x1) + { + return check1 < nDist* nDist; + } + } + } + } - int dx = x2 - x1; - int dy = y2 - y1; - int px = x - x2; - int py = y - y2; - int side = px * dx + dy * py; - if (side >= 0) - { - return px * px + py * py < nDist * nDist; - } - px = x - x1; - py = y - y1; - side = px * dx + dy * py; - if (side <= 0) - { - return px * px + py * py < nDist * nDist; - } - int check1 = px * dy - dx * py; - int check2 = dy * dy + dx * dx; - return check1 * check1 < check2 * nDist * nDist; + int dx = x2 - x1; + int dy = y2 - y1; + int px = x - x2; + int py = y - y2; + int side = px * dx + dy * py; + if (side >= 0) + { + return px * px + py * py < nDist* nDist; + } + px = x - x1; + py = y - y1; + side = px * dx + dy * py; + if (side <= 0) + { + return px * px + py * py < nDist* nDist; + } + int check1 = px * dy - dx * py; + int check2 = dy * dy + dx * dx; + return check1 * check1 < check2* nDist* nDist; } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + int GetWallAngle(walltype* pWall) { - auto delta = pWall->delta(); - return getangle(delta.X, delta.Y); + auto delta = pWall->delta(); + return getangle(delta.X, delta.Y); } -void GetWallNormal(walltype* pWall, int *pX, int *pY) +void GetWallNormal(walltype* pWall, int* pX, int* pY) { - auto delta = pWall->delta(); - int dX = -delta.Y >> 4; - int dY = delta.X >> 4; + auto delta = pWall->delta(); + int dX = -delta.Y >> 4; + int dY = delta.X >> 4; - int nLength = ksqrt(dX*dX+dY*dY); - if (nLength <= 0) - nLength = 1; - *pX = DivScale(dX, nLength, 16); - *pY = DivScale(dY, nLength, 16); + int nLength = ksqrt(dX * dX + dY * dY); + if (nLength <= 0) + nLength = 1; + *pX = DivScale(dX, nLength, 16); + *pY = DivScale(dY, nLength, 16); } -bool IntersectRay(int wx, int wy, int wdx, int wdy, int x1, int y1, int z1, int x2, int y2, int z2, int *ix, int *iy, int *iz) +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +bool IntersectRay(int wx, int wy, int wdx, int wdy, int x1, int y1, int z1, int x2, int y2, int z2, int* ix, int* iy, int* iz) { - int dX = x1 - x2; - int dY = y1 - y2; - int dZ = z1 - z2; - int side = wdx * dY - wdy * dX; - int dX2 = x1 - wx; - int dY2 = y1 - wy; - int check1 = dX2 * dY - dY2 * dX; - int check2 = wdx * dY2 - wdy * dX2; - if (side >= 0) - { - if (!side) - return 0; - if (check1 < 0) - return 0; - if (check2 < 0 || check2 >= side) - return 0; - } - else - { - if (check1 > 0) - return 0; - if (check2 > 0 || check2 <= side) - return 0; - } - int nScale = DivScale(check2, side, 16); - *ix = x1 + MulScale(dX, nScale, 16); - *iy = y1 + MulScale(dY, nScale, 16); - *iz = z1 + MulScale(dZ, nScale, 16); - return 1; + int dX = x1 - x2; + int dY = y1 - y2; + int dZ = z1 - z2; + int side = wdx * dY - wdy * dX; + int dX2 = x1 - wx; + int dY2 = y1 - wy; + int check1 = dX2 * dY - dY2 * dX; + int check2 = wdx * dY2 - wdy * dX2; + if (side >= 0) + { + if (!side) + return 0; + if (check1 < 0) + return 0; + if (check2 < 0 || check2 >= side) + return 0; + } + else + { + if (check1 > 0) + return 0; + if (check2 > 0 || check2 <= side) + return 0; + } + int nScale = DivScale(check2, side, 16); + *ix = x1 + MulScale(dX, nScale, 16); + *iy = y1 + MulScale(dY, nScale, 16); + *iz = z1 + MulScale(dZ, nScale, 16); + return 1; } -int HitScan(DBloodActor *actor, int z, int dx, int dy, int dz, unsigned int nMask, int nRange) +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +int HitScan(DBloodActor* actor, int z, int dx, int dy, int dz, unsigned int nMask, int nRange) { - assert(actor != nullptr); - assert(dx != 0 || dy != 0); - gHitInfo.clearObj(); - int x = actor->spr.pos.X; - int y = actor->spr.pos.Y; - auto bakCstat = actor->spr.cstat; - actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_HITSCAN; - if (nRange) - { - hitscangoal.X = x + MulScale(nRange << 4, Cos(actor->spr.ang), 30); - hitscangoal.Y = y + MulScale(nRange << 4, Sin(actor->spr.ang), 30); - } - else - { - hitscangoal.X = hitscangoal.Y = 0x1ffffff; - } - hitscan({ x, y, z }, actor->spr.sector(), { dx, dy, dz << 4 }, gHitInfo, nMask); + assert(actor != nullptr); + assert(dx != 0 || dy != 0); + gHitInfo.clearObj(); + int x = actor->spr.pos.X; + int y = actor->spr.pos.Y; + auto bakCstat = actor->spr.cstat; + actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_HITSCAN; + if (nRange) + { + hitscangoal.X = x + MulScale(nRange << 4, Cos(actor->spr.ang), 30); + hitscangoal.Y = y + MulScale(nRange << 4, Sin(actor->spr.ang), 30); + } + else + { + hitscangoal.X = hitscangoal.Y = 0x1ffffff; + } + hitscan({ x, y, z }, actor->spr.sector(), { dx, dy, dz << 4 }, gHitInfo, nMask); - hitscangoal.X = hitscangoal.Y = 0x1ffffff; - actor->spr.cstat = bakCstat; - if (gHitInfo.actor() != nullptr) - return 3; - if (gHitInfo.hitWall != nullptr) - { - auto pWall = gHitInfo.hitWall; + hitscangoal.X = hitscangoal.Y = 0x1ffffff; + actor->spr.cstat = bakCstat; + if (gHitInfo.actor() != nullptr) + return 3; + if (gHitInfo.hitWall != nullptr) + { + auto pWall = gHitInfo.hitWall; - if (!pWall->twoSided()) - return 0; - int nZCeil, nZFloor; - getzsofslopeptr(pWall->nextSector(), gHitInfo.hitpos.X, gHitInfo.hitpos.Y, &nZCeil, &nZFloor); - if (gHitInfo.hitpos.Z <= nZCeil || gHitInfo.hitpos.Z >= nZFloor) - return 0; - return 4; - } - if (gHitInfo.hitSector != nullptr) - return 1 + (z < gHitInfo.hitpos.Z); - return -1; + if (!pWall->twoSided()) + return 0; + int nZCeil, nZFloor; + getzsofslopeptr(pWall->nextSector(), gHitInfo.hitpos.X, gHitInfo.hitpos.Y, &nZCeil, &nZFloor); + if (gHitInfo.hitpos.Z <= nZCeil || gHitInfo.hitpos.Z >= nZFloor) + return 0; + return 4; + } + if (gHitInfo.hitSector != nullptr) + return 1 + (z < gHitInfo.hitpos.Z); + return -1; } -int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, int dz, int nRange, int ac) +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +int VectorScan(DBloodActor* actor, int nOffset, int nZOffset, int dx, int dy, int dz, int nRange, int ac) { - assert(actor != nullptr); + assert(actor != nullptr); - int nNum = 256; - gHitInfo.clearObj(); - int x1 = actor->spr.pos.X+MulScale(nOffset, Cos(actor->spr.ang+512), 30); - int y1 = actor->spr.pos.Y+MulScale(nOffset, Sin(actor->spr.ang+512), 30); - int z1 = actor->spr.pos.Z+nZOffset; - auto bakCstat = actor->spr.cstat; - actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_HITSCAN; - if (nRange) - { - hitscangoal.X = x1+MulScale(nRange<<4, Cos(actor->spr.ang), 30); - hitscangoal.Y = y1+MulScale(nRange<<4, Sin(actor->spr.ang), 30); - } - else - { - hitscangoal.X = hitscangoal.Y = 0x1fffffff; - } - vec3_t pos = { x1, y1, z1 }; - hitscan(pos, actor->spr.sector(), { dx, dy, dz << 4 }, gHitInfo, CLIPMASK1); + int nNum = 256; + gHitInfo.clearObj(); + int x1 = actor->spr.pos.X + MulScale(nOffset, Cos(actor->spr.ang + 512), 30); + int y1 = actor->spr.pos.Y + MulScale(nOffset, Sin(actor->spr.ang + 512), 30); + int z1 = actor->spr.pos.Z + nZOffset; + auto bakCstat = actor->spr.cstat; + actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_HITSCAN; + if (nRange) + { + hitscangoal.X = x1 + MulScale(nRange << 4, Cos(actor->spr.ang), 30); + hitscangoal.Y = y1 + MulScale(nRange << 4, Sin(actor->spr.ang), 30); + } + else + { + hitscangoal.X = hitscangoal.Y = 0x1fffffff; + } + vec3_t pos = { x1, y1, z1 }; + hitscan(pos, actor->spr.sector(), { dx, dy, dz << 4 }, gHitInfo, CLIPMASK1); - hitscangoal.X = hitscangoal.Y = 0x1ffffff; - actor->spr.cstat = bakCstat; - while (nNum--) - { - if (nRange && approxDist(gHitInfo.hitpos.X - actor->spr.pos.X, gHitInfo.hitpos.Y - actor->spr.pos.Y) > nRange) - return -1; - auto other = gHitInfo.actor(); - if (other != nullptr) - { - if ((other->spr.flags & 8) && !(ac & 1)) - return 3; - if ((other->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) != 0) - return 3; - int nPicnum = other->spr.picnum; - if (tileWidth(nPicnum) == 0 || tileHeight(nPicnum) == 0) - return 3; - int height = (tileHeight(nPicnum)*other->spr.yrepeat)<<2; - int otherZ = other->spr.pos.Z; - if (other->spr.cstat & CSTAT_SPRITE_YCENTER) - otherZ += height / 2; - int nTopOfs = tileTopOffset(nPicnum); - if (nTopOfs) - otherZ -= (nTopOfs*other->spr.yrepeat)<<2; - assert(height > 0); - int height2 = scale(otherZ-gHitInfo.hitpos.Z, tileHeight(nPicnum), height); - if (!(other->spr.cstat & CSTAT_SPRITE_YFLIP)) - height2 = tileHeight(nPicnum)-height2; - if (height2 >= 0 && height2 < tileHeight(nPicnum)) - { - int width = (tileWidth(nPicnum)*other->spr.xrepeat)>>2; - width = (width*3)/4; - int check1 = ((y1 - other->spr.pos.Y)*dx - (x1 - other->spr.pos.X)*dy) / ksqrt(dx*dx+dy*dy); - assert(width > 0); - int width2 = scale(check1, tileWidth(nPicnum), width); - int nLeftOfs = tileLeftOffset(nPicnum); - width2 += nLeftOfs + tileWidth(nPicnum) / 2; - if (width2 >= 0 && width2 < tileWidth(nPicnum)) - { - auto pData = tilePtr(nPicnum); - if (pData[width2*tileHeight(nPicnum)+height2] != TRANSPARENT_INDEX) - return 3; - } - } - bakCstat = other->spr.cstat; - other->spr.cstat &= ~CSTAT_SPRITE_BLOCK_HITSCAN; - gHitInfo.clearObj(); - pos = gHitInfo.hitpos; // must make a copy! - hitscan(pos, other->spr.sector(), { dx, dy, dz << 4 }, gHitInfo, CLIPMASK1); - other->spr.cstat = bakCstat; - continue; - } - if (gHitInfo.hitWall != nullptr) - { - walltype *pWall = gHitInfo.hitWall; - if (!pWall->twoSided()) - return 0; - sectortype *pSector = gHitInfo.hitSector; - sectortype *pSectorNext = pWall->nextSector(); - int nZCeil, nZFloor; - getzsofslopeptr(pWall->nextSector(), gHitInfo.hitpos.X, gHitInfo.hitpos.Y, &nZCeil, &nZFloor); - if (gHitInfo.hitpos.Z <= nZCeil) - return 0; - if (gHitInfo.hitpos.Z >= nZFloor) - { - if (!(pSector->floorstat & CSTAT_SECTOR_SKY) || !(pSectorNext->floorstat & CSTAT_SECTOR_SKY)) - return 0; - return 2; - } - if (!(pWall->cstat & (CSTAT_WALL_MASKED | CSTAT_WALL_1WAY))) - return 0; - int nOfs; - if (pWall->cstat & CSTAT_WALL_ALIGN_BOTTOM) - nOfs = ClipHigh(pSector->floorz, pSectorNext->floorz); - else - nOfs = ClipLow(pSector->ceilingz, pSectorNext->ceilingz); - nOfs = (gHitInfo.hitpos.Z - nOfs) >> 8; - if (pWall->cstat & CSTAT_WALL_YFLIP) - nOfs = -nOfs; + hitscangoal.X = hitscangoal.Y = 0x1ffffff; + actor->spr.cstat = bakCstat; + while (nNum--) + { + if (nRange && approxDist(gHitInfo.hitpos.X - actor->spr.pos.X, gHitInfo.hitpos.Y - actor->spr.pos.Y) > nRange) + return -1; + auto other = gHitInfo.actor(); + if (other != nullptr) + { + if ((other->spr.flags & 8) && !(ac & 1)) + return 3; + if ((other->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) != 0) + return 3; + int nPicnum = other->spr.picnum; + if (tileWidth(nPicnum) == 0 || tileHeight(nPicnum) == 0) + return 3; + int height = (tileHeight(nPicnum) * other->spr.yrepeat) << 2; + int otherZ = other->spr.pos.Z; + if (other->spr.cstat & CSTAT_SPRITE_YCENTER) + otherZ += height / 2; + int nTopOfs = tileTopOffset(nPicnum); + if (nTopOfs) + otherZ -= (nTopOfs * other->spr.yrepeat) << 2; + assert(height > 0); + int height2 = scale(otherZ - gHitInfo.hitpos.Z, tileHeight(nPicnum), height); + if (!(other->spr.cstat & CSTAT_SPRITE_YFLIP)) + height2 = tileHeight(nPicnum) - height2; + if (height2 >= 0 && height2 < tileHeight(nPicnum)) + { + int width = (tileWidth(nPicnum) * other->spr.xrepeat) >> 2; + width = (width * 3) / 4; + int check1 = ((y1 - other->spr.pos.Y) * dx - (x1 - other->spr.pos.X) * dy) / ksqrt(dx * dx + dy * dy); + assert(width > 0); + int width2 = scale(check1, tileWidth(nPicnum), width); + int nLeftOfs = tileLeftOffset(nPicnum); + width2 += nLeftOfs + tileWidth(nPicnum) / 2; + if (width2 >= 0 && width2 < tileWidth(nPicnum)) + { + auto pData = tilePtr(nPicnum); + if (pData[width2 * tileHeight(nPicnum) + height2] != TRANSPARENT_INDEX) + return 3; + } + } + bakCstat = other->spr.cstat; + other->spr.cstat &= ~CSTAT_SPRITE_BLOCK_HITSCAN; + gHitInfo.clearObj(); + pos = gHitInfo.hitpos; // must make a copy! + hitscan(pos, other->spr.sector(), { dx, dy, dz << 4 }, gHitInfo, CLIPMASK1); + other->spr.cstat = bakCstat; + continue; + } + if (gHitInfo.hitWall != nullptr) + { + walltype* pWall = gHitInfo.hitWall; + if (!pWall->twoSided()) + return 0; + sectortype* pSector = gHitInfo.hitSector; + sectortype* pSectorNext = pWall->nextSector(); + int nZCeil, nZFloor; + getzsofslopeptr(pWall->nextSector(), gHitInfo.hitpos.X, gHitInfo.hitpos.Y, &nZCeil, &nZFloor); + if (gHitInfo.hitpos.Z <= nZCeil) + return 0; + if (gHitInfo.hitpos.Z >= nZFloor) + { + if (!(pSector->floorstat & CSTAT_SECTOR_SKY) || !(pSectorNext->floorstat & CSTAT_SECTOR_SKY)) + return 0; + return 2; + } + if (!(pWall->cstat & (CSTAT_WALL_MASKED | CSTAT_WALL_1WAY))) + return 0; + int nOfs; + if (pWall->cstat & CSTAT_WALL_ALIGN_BOTTOM) + nOfs = ClipHigh(pSector->floorz, pSectorNext->floorz); + else + nOfs = ClipLow(pSector->ceilingz, pSectorNext->ceilingz); + nOfs = (gHitInfo.hitpos.Z - nOfs) >> 8; + if (pWall->cstat & CSTAT_WALL_YFLIP) + nOfs = -nOfs; - int nPicnum = pWall->overpicnum; - int nSizX = tileWidth(nPicnum); - int nSizY = tileHeight(nPicnum); - if (!nSizX || !nSizY) - return 0; + int nPicnum = pWall->overpicnum; + int nSizX = tileWidth(nPicnum); + int nSizY = tileHeight(nPicnum); + if (!nSizX || !nSizY) + return 0; - nOfs = (nOfs*pWall->yrepeat) / 8; - nOfs += int((nSizY*pWall->ypan_) / 256); - int nLength = approxDist(pWall->pos.X - pWall->point2Wall()->pos.X, pWall->pos.Y - pWall->point2Wall()->pos.Y); - int nHOffset; - if (pWall->cstat & CSTAT_WALL_XFLIP) - nHOffset = approxDist(gHitInfo.hitpos.X - pWall->point2Wall()->pos.X, gHitInfo.hitpos.Y - pWall->point2Wall()->pos.Y); - else - nHOffset = approxDist(gHitInfo.hitpos.X - pWall->pos.X, gHitInfo.hitpos.Y - pWall->pos.Y); + nOfs = (nOfs * pWall->yrepeat) / 8; + nOfs += int((nSizY * pWall->ypan_) / 256); + int nLength = approxDist(pWall->pos.X - pWall->point2Wall()->pos.X, pWall->pos.Y - pWall->point2Wall()->pos.Y); + int nHOffset; + if (pWall->cstat & CSTAT_WALL_XFLIP) + nHOffset = approxDist(gHitInfo.hitpos.X - pWall->point2Wall()->pos.X, gHitInfo.hitpos.Y - pWall->point2Wall()->pos.Y); + else + nHOffset = approxDist(gHitInfo.hitpos.X - pWall->pos.X, gHitInfo.hitpos.Y - pWall->pos.Y); - nHOffset = pWall->xpan() + ((nHOffset*pWall->xrepeat) << 3) / nLength; - nHOffset %= nSizX; - nOfs %= nSizY; - auto pData = tilePtr(nPicnum); - int nPixel; - nPixel = nHOffset*nSizY + nOfs; + nHOffset = pWall->xpan() + ((nHOffset * pWall->xrepeat) << 3) / nLength; + nHOffset %= nSizX; + nOfs %= nSizY; + auto pData = tilePtr(nPicnum); + int nPixel; + nPixel = nHOffset * nSizY + nOfs; - if (pData[nPixel] == TRANSPARENT_INDEX) - { - auto bakCstat1 = pWall->cstat; - pWall->cstat &= ~CSTAT_WALL_BLOCK_HITSCAN; - auto bakCstat2 = pWall->nextWall()->cstat; - pWall->nextWall()->cstat &= ~CSTAT_WALL_BLOCK_HITSCAN; - gHitInfo.clearObj(); - pos = gHitInfo.hitpos; - hitscan(pos, pWall->nextSector(), { dx, dy, dz << 4 }, gHitInfo, CLIPMASK1); + if (pData[nPixel] == TRANSPARENT_INDEX) + { + auto bakCstat1 = pWall->cstat; + pWall->cstat &= ~CSTAT_WALL_BLOCK_HITSCAN; + auto bakCstat2 = pWall->nextWall()->cstat; + pWall->nextWall()->cstat &= ~CSTAT_WALL_BLOCK_HITSCAN; + gHitInfo.clearObj(); + pos = gHitInfo.hitpos; + hitscan(pos, pWall->nextSector(), { dx, dy, dz << 4 }, gHitInfo, CLIPMASK1); - pWall->cstat = bakCstat1; - pWall->nextWall()->cstat = bakCstat2; - continue; - } - return 4; - } - if (gHitInfo.hitSector != nullptr) - { - if (dz > 0) - { - auto upper = barrier_cast(gHitInfo.hitSector->upperLink); - if (!upper) return 2; - auto link = upper->GetOwner(); - gHitInfo.clearObj(); - x1 = gHitInfo.hitpos.X + link->spr.pos.X - upper->spr.pos.X; - y1 = gHitInfo.hitpos.Y + link->spr.pos.Y - upper->spr.pos.Y; - z1 = gHitInfo.hitpos.Z + link->spr.pos.Z - upper->spr.pos.Z; - pos = { x1, y1, z1 }; - hitscan(pos, link->spr.sector(), { dx, dy, dz << 4 }, gHitInfo, CLIPMASK1); + pWall->cstat = bakCstat1; + pWall->nextWall()->cstat = bakCstat2; + continue; + } + return 4; + } + if (gHitInfo.hitSector != nullptr) + { + if (dz > 0) + { + auto upper = barrier_cast(gHitInfo.hitSector->upperLink); + if (!upper) return 2; + auto link = upper->GetOwner(); + gHitInfo.clearObj(); + x1 = gHitInfo.hitpos.X + link->spr.pos.X - upper->spr.pos.X; + y1 = gHitInfo.hitpos.Y + link->spr.pos.Y - upper->spr.pos.Y; + z1 = gHitInfo.hitpos.Z + link->spr.pos.Z - upper->spr.pos.Z; + pos = { x1, y1, z1 }; + hitscan(pos, link->spr.sector(), { dx, dy, dz << 4 }, gHitInfo, CLIPMASK1); - continue; - } - else - { - auto lower = barrier_cast(gHitInfo.hitSector->lowerLink); - if (!lower) return 1; - auto link = lower->GetOwner(); - gHitInfo.clearObj(); - x1 = gHitInfo.hitpos.X + link->spr.pos.X - lower->spr.pos.X; - y1 = gHitInfo.hitpos.Y + link->spr.pos.Y - lower->spr.pos.Y; - z1 = gHitInfo.hitpos.Z + link->spr.pos.Z - lower->spr.pos.Z; - pos = { x1, y1, z1 }; - hitscan(pos, link->spr.sector(), { dx, dy, dz << 4 }, gHitInfo, CLIPMASK1); - continue; - } - } - return -1; - } - return -1; + continue; + } + else + { + auto lower = barrier_cast(gHitInfo.hitSector->lowerLink); + if (!lower) return 1; + auto link = lower->GetOwner(); + gHitInfo.clearObj(); + x1 = gHitInfo.hitpos.X + link->spr.pos.X - lower->spr.pos.X; + y1 = gHitInfo.hitpos.Y + link->spr.pos.Y - lower->spr.pos.Y; + z1 = gHitInfo.hitpos.Z + link->spr.pos.Z - lower->spr.pos.Z; + pos = { x1, y1, z1 }; + hitscan(pos, link->spr.sector(), { dx, dy, dz << 4 }, gHitInfo, CLIPMASK1); + continue; + } + } + return -1; + } + return -1; } -void GetZRange(DBloodActor *actor, int *ceilZ, Collision *ceilColl, int *floorZ, Collision *floorColl, int nDist, unsigned int nMask, unsigned int nClipParallax) +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void GetZRange(DBloodActor* actor, int* ceilZ, Collision* ceilColl, int* floorZ, Collision* floorColl, int nDist, unsigned int nMask, unsigned int nClipParallax) { - assert(actor != nullptr); - Collision scratch; + assert(actor != nullptr); + Collision scratch; - auto bakCstat = actor->spr.cstat; - int32_t nTemp1; - actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; - getzrange(actor->spr.pos, actor->spr.sector(), (int32_t*)ceilZ, *ceilColl, (int32_t*)floorZ, *floorColl, nDist, nMask); - if (floorColl->type == kHitSector) - { - auto pSector = floorColl->hitSector; - if ((nClipParallax & PARALLAXCLIP_FLOOR) == 0 && (pSector->floorstat & CSTAT_SECTOR_SKY)) - *floorZ = 0x7fffffff; - if (pSector->hasX()) - { - XSECTOR *pXSector = &pSector->xs(); - *floorZ += pXSector->Depth << 10; - } - auto linkActor = barrier_cast(pSector->upperLink); - if (linkActor) - { - auto linkOwner = linkActor->GetOwner(); - vec3_t lpos = actor->spr.pos + linkOwner->spr.pos - linkActor->spr.pos; - getzrange(lpos, linkOwner->spr.sector(), &nTemp1, scratch, (int32_t*)floorZ, *floorColl, nDist, nMask); - *floorZ -= linkOwner->spr.pos.Z - linkActor->spr.pos.Z; - } - } - if (ceilColl->type == kHitSector) - { - auto pSector = ceilColl->hitSector; - if ((nClipParallax & PARALLAXCLIP_CEILING) == 0 && (pSector->ceilingstat & CSTAT_SECTOR_SKY)) - *ceilZ = 0x80000000; - auto linkActor = barrier_cast(pSector->lowerLink); - if (linkActor) - { - auto linkOwner = linkActor->GetOwner(); - vec3_t lpos = actor->spr.pos + linkOwner->spr.pos - linkActor->spr.pos; - getzrange(lpos, linkOwner->spr.sector(), (int32_t*)ceilZ, *ceilColl, &nTemp1, scratch, nDist, nMask); - *ceilZ -= linkOwner->spr.pos.Z - linkActor->spr.pos.Z; - } - } - actor->spr.cstat = bakCstat; + auto bakCstat = actor->spr.cstat; + int32_t nTemp1; + actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; + getzrange(actor->spr.pos, actor->spr.sector(), (int32_t*)ceilZ, *ceilColl, (int32_t*)floorZ, *floorColl, nDist, nMask); + if (floorColl->type == kHitSector) + { + auto pSector = floorColl->hitSector; + if ((nClipParallax & PARALLAXCLIP_FLOOR) == 0 && (pSector->floorstat & CSTAT_SECTOR_SKY)) + *floorZ = 0x7fffffff; + if (pSector->hasX()) + { + XSECTOR* pXSector = &pSector->xs(); + *floorZ += pXSector->Depth << 10; + } + auto linkActor = barrier_cast(pSector->upperLink); + if (linkActor) + { + auto linkOwner = linkActor->GetOwner(); + vec3_t lpos = actor->spr.pos + linkOwner->spr.pos - linkActor->spr.pos; + getzrange(lpos, linkOwner->spr.sector(), &nTemp1, scratch, (int32_t*)floorZ, *floorColl, nDist, nMask); + *floorZ -= linkOwner->spr.pos.Z - linkActor->spr.pos.Z; + } + } + if (ceilColl->type == kHitSector) + { + auto pSector = ceilColl->hitSector; + if ((nClipParallax & PARALLAXCLIP_CEILING) == 0 && (pSector->ceilingstat & CSTAT_SECTOR_SKY)) + *ceilZ = 0x80000000; + auto linkActor = barrier_cast(pSector->lowerLink); + if (linkActor) + { + auto linkOwner = linkActor->GetOwner(); + vec3_t lpos = actor->spr.pos + linkOwner->spr.pos - linkActor->spr.pos; + getzrange(lpos, linkOwner->spr.sector(), (int32_t*)ceilZ, *ceilColl, &nTemp1, scratch, nDist, nMask); + *ceilZ -= linkOwner->spr.pos.Z - linkActor->spr.pos.Z; + } + } + actor->spr.cstat = bakCstat; } -void GetZRangeAtXYZ(int x, int y, int z, sectortype* pSector, int *ceilZ, Collision* ceilColl, int* floorZ, Collision* floorColl, int nDist, unsigned int nMask, unsigned int nClipParallax) +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void GetZRangeAtXYZ(int x, int y, int z, sectortype* pSector, int* ceilZ, Collision* ceilColl, int* floorZ, Collision* floorColl, int nDist, unsigned int nMask, unsigned int nClipParallax) { - Collision scratch; - int32_t nTemp1; - vec3_t lpos = { x, y, z }; - getzrange(lpos, pSector, (int32_t*)ceilZ, *ceilColl, (int32_t*)floorZ, *floorColl, nDist, nMask); - if (floorColl->type == kHitSector) - { - auto pHitSect = floorColl->hitSector; - if ((nClipParallax & PARALLAXCLIP_FLOOR) == 0 && (pHitSect->floorstat & CSTAT_SECTOR_SKY)) - *floorZ = 0x7fffffff; - if (pHitSect->hasX()) - { - XSECTOR* pXSector = &pHitSect->xs(); - *floorZ += pXSector->Depth << 10; - } - auto actor = barrier_cast(pHitSect->upperLink); - if (actor) - { - auto link = actor->GetOwner(); - vec3_t newpos = lpos + link->spr.pos - actor->spr.pos; - getzrange(newpos, link->spr.sector(), &nTemp1, scratch, (int32_t*)floorZ, *floorColl, nDist, nMask); - *floorZ -= link->spr.pos.Z - actor->spr.pos.Z; - } - } - if (ceilColl->type == kHitSector) - { - auto pHitSect = ceilColl->hitSector; - if ((nClipParallax & PARALLAXCLIP_CEILING) == 0 && (pHitSect->ceilingstat & CSTAT_SECTOR_SKY)) - *ceilZ = 0x80000000; - auto actor = barrier_cast(pHitSect->lowerLink); - if (actor) - { - auto link = actor->GetOwner(); - vec3_t newpos = lpos + link->spr.pos - actor->spr.pos; - getzrange(newpos, link->spr.sector(), (int32_t*)ceilZ, *ceilColl, &nTemp1, scratch, nDist, nMask); - *ceilZ -= link->spr.pos.Z - actor->spr.pos.Z; - } - } + Collision scratch; + int32_t nTemp1; + vec3_t lpos = { x, y, z }; + getzrange(lpos, pSector, (int32_t*)ceilZ, *ceilColl, (int32_t*)floorZ, *floorColl, nDist, nMask); + if (floorColl->type == kHitSector) + { + auto pHitSect = floorColl->hitSector; + if ((nClipParallax & PARALLAXCLIP_FLOOR) == 0 && (pHitSect->floorstat & CSTAT_SECTOR_SKY)) + *floorZ = 0x7fffffff; + if (pHitSect->hasX()) + { + XSECTOR* pXSector = &pHitSect->xs(); + *floorZ += pXSector->Depth << 10; + } + auto actor = barrier_cast(pHitSect->upperLink); + if (actor) + { + auto link = actor->GetOwner(); + vec3_t newpos = lpos + link->spr.pos - actor->spr.pos; + getzrange(newpos, link->spr.sector(), &nTemp1, scratch, (int32_t*)floorZ, *floorColl, nDist, nMask); + *floorZ -= link->spr.pos.Z - actor->spr.pos.Z; + } + } + if (ceilColl->type == kHitSector) + { + auto pHitSect = ceilColl->hitSector; + if ((nClipParallax & PARALLAXCLIP_CEILING) == 0 && (pHitSect->ceilingstat & CSTAT_SECTOR_SKY)) + *ceilZ = 0x80000000; + auto actor = barrier_cast(pHitSect->lowerLink); + if (actor) + { + auto link = actor->GetOwner(); + vec3_t newpos = lpos + link->spr.pos - actor->spr.pos; + getzrange(newpos, link->spr.sector(), (int32_t*)ceilZ, *ceilColl, &nTemp1, scratch, nDist, nMask); + *ceilZ -= link->spr.pos.Z - actor->spr.pos.Z; + } + } } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + int GetDistToLine(int x1, int y1, int x2, int y2, int x3, int y3) { - int check = (y1-y3)*(x3-x2); - int check2 = (x1-x2)*(y3-y2); - if (check2 > check) - return -1; - int v8 = DMulScale(x1-x2,x3-x2,y1-y3,y3-y2,4); - int vv = DMulScale(x3-x2,x3-x2,y3-y2,y3-y2,4); - int t1, t2; - if (v8 <= 0) - { - t1 = x2; - t2 = y2; - } - else if (vv > v8) - { - t1 = x2+scale(x3-x2,v8,vv); - t2 = y2+scale(y3-y2,v8,vv); - } - else - { - t1 = x3; - t2 = y3; - } - return approxDist(t1-x1, t2-y1); + int check = (y1 - y3) * (x3 - x2); + int check2 = (x1 - x2) * (y3 - y2); + if (check2 > check) + return -1; + int v8 = DMulScale(x1 - x2, x3 - x2, y1 - y3, y3 - y2, 4); + int vv = DMulScale(x3 - x2, x3 - x2, y3 - y2, y3 - y2, 4); + int t1, t2; + if (v8 <= 0) + { + t1 = x2; + t2 = y2; + } + else if (vv > v8) + { + t1 = x2 + scale(x3 - x2, v8, vv); + t2 = y2 + scale(y3 - y2, v8, vv); + } + else + { + t1 = x3; + t2 = y3; + } + return approxDist(t1 - x1, t2 - y1); } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + void ClipMove(vec3_t& pos, sectortype** pSector, int xv, int yv, int wd, int cd, int fd, unsigned int nMask, CollisionBase& hit, int tracecount) { - auto opos = pos; - sectortype* bakSect = *pSector; - clipmove(pos, &bakSect, xv << 14, yv << 14, wd, cd, fd, nMask, hit, tracecount); - if (bakSect == nullptr) - { - pos = opos; - } - else - { - *pSector = bakSect; - } + auto opos = pos; + sectortype* bakSect = *pSector; + clipmove(pos, &bakSect, xv << 14, yv << 14, wd, cd, fd, nMask, hit, tracecount); + if (bakSect == nullptr) + { + pos = opos; + } + else + { + *pSector = bakSect; + } } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + BitArray GetClosestSpriteSectors(sectortype* pSector, int x, int y, int nDist, TArray* pWalls, bool newSectCheckMethod) { - // by default this function fails with sectors that linked with wide spans, or there was more than one link to the same sector. for example... - // E6M1: throwing TNT on the stone footpath while standing on the brown road will fail due to the start/end points of the span being too far away. it'll only do damage at one end of the road - // E1M2: throwing TNT at the double doors while standing on the train platform - // by setting newSectCheckMethod to true these issues will be resolved + // by default this function fails with sectors that linked with wide spans, or there was more than one link to the same sector. for example... + // E6M1: throwing TNT on the stone footpath while standing on the brown road will fail due to the start/end points of the span being too far away. it'll only do damage at one end of the road + // E1M2: throwing TNT at the double doors while standing on the train platform + // by setting newSectCheckMethod to true these issues will be resolved - BitArray sectorMap(sector.Size()); // this gets returned to the caller. - sectorMap.Zero(); - sectorMap.Set(sectnum(pSector)); - double nDist4sq = 256. * nDist * nDist; // (nDist * 16)^2 - * 16 to account for Build's 28.4 fixed point format. + BitArray sectorMap(sector.Size()); // this gets returned to the caller. + sectorMap.Zero(); + sectorMap.Set(sectnum(pSector)); + double nDist4sq = 256. * nDist * nDist; // (nDist * 16)^2 - * 16 to account for Build's 28.4 fixed point format. - BFSSectorSearch search(pSector); + BFSSectorSearch search(pSector); - while (auto pCurSector = search.GetNext()) - { - for (auto& wal : wallsofsector(pCurSector)) - { - if (!wal.twoSided()) continue; - const auto pNextSector = wal.nextSector(); + while (auto pCurSector = search.GetNext()) + { + for (auto& wal : wallsofsector(pCurSector)) + { + if (!wal.twoSided()) continue; + const auto pNextSector = wal.nextSector(); - bool withinRange = false; - if (!newSectCheckMethod) // original method - { - if (search.Check(pNextSector)) // if we've already checked this sector, skip. This is bad, therefore only in compat mode. - continue; - withinRange = CheckProximityWall(wal.point2Wall(), x, y, nDist); - } - else // new method using proper math and no bad shortcut. - { - double dist1 = SquareDistToWall(x, y, &wal); - withinRange = dist1 <= nDist4sq; - } - if (withinRange) // if new sector is within range, add it to the processing queue - { - sectorMap.Set(sectnum(pNextSector)); - search.Add(pNextSector); - if (pWalls && wal.hasX()) - { - XWALL* pXWall = &wal.xw(); - if (pXWall->triggerVector && !pXWall->isTriggered && !pXWall->state) - pWalls->Push(&wal); - } - } - } - } - return sectorMap; + bool withinRange = false; + if (!newSectCheckMethod) // original method + { + if (search.Check(pNextSector)) // if we've already checked this sector, skip. This is bad, therefore only in compat mode. + continue; + withinRange = CheckProximityWall(wal.point2Wall(), x, y, nDist); + } + else // new method using proper math and no bad shortcut. + { + double dist1 = SquareDistToWall(x, y, &wal); + withinRange = dist1 <= nDist4sq; + } + if (withinRange) // if new sector is within range, add it to the processing queue + { + sectorMap.Set(sectnum(pNextSector)); + search.Add(pNextSector); + if (pWalls && wal.hasX()) + { + XWALL* pXWall = &wal.xw(); + if (pXWall->triggerVector && !pXWall->isTriggered && !pXWall->state) + pWalls->Push(&wal); + } + } + } + } + return sectorMap; } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + int picWidth(int nPic, int repeat) { - return ClipLow((tileWidth(nPic) * repeat) << 2, 0); + return ClipLow((tileWidth(nPic) * repeat) << 2, 0); } int picHeight(int nPic, int repeat) { - return ClipLow((tileHeight(nPic) * repeat) << 2, 0); + return ClipLow((tileHeight(nPic) * repeat) << 2, 0); } diff --git a/source/games/blood/src/gameutil.h b/source/games/blood/src/gameutil.h index 5e509febb..5b63e289c 100644 --- a/source/games/blood/src/gameutil.h +++ b/source/games/blood/src/gameutil.h @@ -27,24 +27,24 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS enum { - PARALLAXCLIP_CEILING = 1, - PARALLAXCLIP_FLOOR = 2, + PARALLAXCLIP_CEILING = 1, + PARALLAXCLIP_FLOOR = 2, }; bool FindSector(int nX, int nY, int nZ, sectortype** ppSector); bool FindSector(int nX, int nY, sectortype** ppSector); -bool CheckProximity(DBloodActor *pSprite, int nX, int nY, int nZ, sectortype* pSector, int nDist); +bool CheckProximity(DBloodActor* pSprite, int nX, int nY, int nZ, sectortype* pSector, int nDist); bool CheckProximityPoint(int nX1, int nY1, int nZ1, int nX2, int nY2, int nZ2, int nDist); bool CheckProximityWall(walltype* pWall, int x, int y, int nDist); int GetWallAngle(walltype* pWall); -void GetWallNormal(walltype* pWall, int *pX, int *pY); -bool IntersectRay(int wx, int wy, int wdx, int wdy, int x1, int y1, int z1, int x2, int y2, int z2, int *ix, int *iy, int *iz); -int HitScan(DBloodActor *pSprite, int z, int dx, int dy, int dz, unsigned int nMask, int a8); -int VectorScan(DBloodActor *pSprite, int nOffset, int nZOffset, int dx, int dy, int dz, int nRange, int ac); -void GetZRange(DBloodActor *pSprite, int *ceilZ, Collision *ceilHit, int *floorZ, Collision *floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax = 0); -void GetZRangeAtXYZ(int x, int y, int z, sectortype* pSector, int *ceilZ, Collision *ceilHit, int *floorZ, Collision *floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax = 0); +void GetWallNormal(walltype* pWall, int* pX, int* pY); +bool IntersectRay(int wx, int wy, int wdx, int wdy, int x1, int y1, int z1, int x2, int y2, int z2, int* ix, int* iy, int* iz); +int HitScan(DBloodActor* pSprite, int z, int dx, int dy, int dz, unsigned int nMask, int a8); +int VectorScan(DBloodActor* pSprite, int nOffset, int nZOffset, int dx, int dy, int dz, int nRange, int ac); +void GetZRange(DBloodActor* pSprite, int* ceilZ, Collision* ceilHit, int* floorZ, Collision* floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax = 0); +void GetZRangeAtXYZ(int x, int y, int z, sectortype* pSector, int* ceilZ, Collision* ceilHit, int* floorZ, Collision* floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax = 0); int GetDistToLine(int x1, int y1, int x2, int y2, int x3, int y3); void ClipMove(vec3_t& pos, sectortype** pSector, int xv, int yv, int wd, int cd, int fd, unsigned int nMask, CollisionBase& hit, int tracecount = 3); BitArray GetClosestSpriteSectors(sectortype* pSector, int x, int y, int nDist, TArray* pWalls, bool newSectCheckMethod = false); diff --git a/source/games/blood/src/gib.cpp b/source/games/blood/src/gib.cpp index 291401968..503f72be1 100644 --- a/source/games/blood/src/gib.cpp +++ b/source/games/blood/src/gib.cpp @@ -32,472 +32,508 @@ BEGIN_BLD_NS struct GIBFX { - FX_ID fxId; - int at1; - int chance; - int at9; - int atd; - int at11; + FX_ID fxId; + int at1; + int chance; + int at9; + int atd; + int at11; }; struct GIBTHING { - int type; - int Kills; - int chance; - int atc; - int at10; + int type; + int Kills; + int chance; + int atc; + int at10; }; struct GIBLIST { - GIBFX *gibFX; - int Kills; - GIBTHING *at8; - int atc; - int at10; + GIBFX* gibFX; + int Kills; + GIBTHING* at8; + int atc; + int at10; }; GIBFX gibFxGlassT[] = { - { FX_18, 0, 65536, 3, 200, 400 }, - { FX_31, 0, 32768, 5, 200, 400 } + { FX_18, 0, 65536, 3, 200, 400 }, + { FX_31, 0, 32768, 5, 200, 400 } }; GIBFX gibFxGlassS[] = { - { FX_18, 0, 65536, 8, 200, 400 } + { FX_18, 0, 65536, 8, 200, 400 } }; GIBFX gibFxBurnShard[] = { - { FX_16, 0, 65536, 12, 500, 1000 } + { FX_16, 0, 65536, 12, 500, 1000 } }; GIBFX gibFxWoodShard[] = { - { FX_17, 0, 65536, 12, 500, 1000 } + { FX_17, 0, 65536, 12, 500, 1000 } }; GIBFX gibFxMetalShard[] = { - { FX_30, 0, 65536, 12, 500, 1000 } + { FX_30, 0, 65536, 12, 500, 1000 } }; GIBFX gibFxFireSpark[] = { - { FX_14, 0, 65536, 8, 500, 1000 } + { FX_14, 0, 65536, 8, 500, 1000 } }; GIBFX gibFxShockSpark[] = { - { FX_15, 0, 65536, 8, 500, 1000 } + { FX_15, 0, 65536, 8, 500, 1000 } }; GIBFX gibFxBloodChunks[] = { - { FX_13, 0, 65536, 8, 90, 600 } + { FX_13, 0, 65536, 8, 90, 600 } }; GIBFX gibFxBubblesS[] = { - { FX_25, 0, 65536, 8, 200, 400 } + { FX_25, 0, 65536, 8, 200, 400 } }; GIBFX gibFxBubblesM[] = { - { FX_24, 0, 65536, 8, 200, 400 } + { FX_24, 0, 65536, 8, 200, 400 } }; GIBFX gibFxBubblesL[] = { - { FX_23, 0, 65536, 8, 200, 400 } + { FX_23, 0, 65536, 8, 200, 400 } }; GIBFX gibFxIcicles[] = { - { FX_31, 0, 65536, 15, 200, 400 } + { FX_31, 0, 65536, 15, 200, 400 } }; GIBFX gibFxGlassCombo1[] = { - { FX_18, 0, 65536, 15, 200, 400 }, - { FX_31, 0, 65536, 10, 200, 400 } + { FX_18, 0, 65536, 15, 200, 400 }, + { FX_31, 0, 65536, 10, 200, 400 } }; GIBFX gibFxGlassCombo2[] = { - { FX_18, 0, 65536, 5, 200, 400 }, - { FX_20, 0, 53248, 5, 200, 400 }, - { FX_21, 0, 53248, 5, 200, 400 }, - { FX_19, 0, 53248, 5, 200, 400 }, - { FX_22, 0, 53248, 5, 200, 400 } + { FX_18, 0, 65536, 5, 200, 400 }, + { FX_20, 0, 53248, 5, 200, 400 }, + { FX_21, 0, 53248, 5, 200, 400 }, + { FX_19, 0, 53248, 5, 200, 400 }, + { FX_22, 0, 53248, 5, 200, 400 } }; GIBFX gibFxWoodCombo[] = { - { FX_16, 0, 65536, 8, 500, 1000 }, - { FX_17, 0, 65536, 8, 500, 1000 }, - { FX_14, 0, 65536, 8, 500, 1000 } + { FX_16, 0, 65536, 8, 500, 1000 }, + { FX_17, 0, 65536, 8, 500, 1000 }, + { FX_14, 0, 65536, 8, 500, 1000 } }; GIBFX gibFxMedicCombo[] = { - { FX_18, 0, 32768, 7, 200, 400 }, - { FX_30, 0, 65536, 7, 500, 1000 }, - { FX_13, 0, 65536, 10, 90, 600 }, - { FX_14, 0, 32768, 7, 500, 1000 } + { FX_18, 0, 32768, 7, 200, 400 }, + { FX_30, 0, 65536, 7, 500, 1000 }, + { FX_13, 0, 65536, 10, 90, 600 }, + { FX_14, 0, 32768, 7, 500, 1000 } }; GIBFX gibFxFlareSpark[] = { - { FX_28, 0, 32768, 15, 128, -128 } + { FX_28, 0, 32768, 15, 128, -128 } }; GIBFX gibFxBloodBits[] = { - { FX_13, 0, 45056, 8, 90, 600 } + { FX_13, 0, 45056, 8, 90, 600 } }; GIBFX gibFxRockShards[] = { - { FX_46, 0, 65536, 10, 300, 800 }, - { FX_31, 0, 32768, 10, 200, 1000 } + { FX_46, 0, 65536, 10, 300, 800 }, + { FX_31, 0, 32768, 10, 200, 1000 } }; GIBFX gibFxPaperCombo1[] = { - { FX_47, 0, 65536, 12, 300, 600 }, - { FX_14, 0, 65536, 8, 500, 1000 } + { FX_47, 0, 65536, 12, 300, 600 }, + { FX_14, 0, 65536, 8, 500, 1000 } }; GIBFX gibFxPlantCombo1[] = { - { FX_44, 0, 45056, 8, 400, 800 }, - { FX_45, 0, 45056, 8, 300, 800 }, - { FX_14, 0, 45056, 6, 500, 1000 } + { FX_44, 0, 45056, 8, 400, 800 }, + { FX_45, 0, 45056, 8, 300, 800 }, + { FX_14, 0, 45056, 6, 500, 1000 } }; GIBFX gibFx13BBA8[] = { - { FX_49, 0, 65536, 4, 80, 300 } + { FX_49, 0, 65536, 4, 80, 300 } }; GIBFX gibFx13BBC0[] = { - { FX_50, 0, 65536, 4, 80, 0 } + { FX_50, 0, 65536, 4, 80, 0 } }; GIBFX gibFx13BBD8[] = { - { FX_50, 0, 65536, 20, 800, -40 }, - { FX_15, 0, 65536, 15, 400, 10 } + { FX_50, 0, 65536, 20, 800, -40 }, + { FX_15, 0, 65536, 15, 400, 10 } }; GIBFX gibFx13BC04[] = { - { FX_32, 0, 65536, 8, 100, 0 } + { FX_32, 0, 65536, 8, 100, 0 } }; GIBFX gibFx13BC1C[] = { - { FX_56, 0, 65536, 8, 100, 0 } + { FX_56, 0, 65536, 8, 100, 0 } }; GIBTHING gibHuman[] = { - { 425, 1454, 917504, 300, 900 }, - { 425, 1454, 917504, 300, 900 }, - { 425, 1267, 917504, 300, 900 }, - { 425, 1267, 917504, 300, 900 }, - { 425, 1268, 917504, 300, 900 }, - { 425, 1269, 917504, 300, 900 }, - { 425, 1456, 917504, 300, 900 } + { 425, 1454, 917504, 300, 900 }, + { 425, 1454, 917504, 300, 900 }, + { 425, 1267, 917504, 300, 900 }, + { 425, 1267, 917504, 300, 900 }, + { 425, 1268, 917504, 300, 900 }, + { 425, 1269, 917504, 300, 900 }, + { 425, 1456, 917504, 300, 900 } }; GIBTHING gibMime[] = { - { 425, 2405, 917504, 300, 900 }, - { 425, 2405, 917504, 300, 900 }, - { 425, 2404, 917504, 300, 900 }, - { 425, 1268, 32768, 300, 900 }, - { 425, 1269, 32768, 300, 900 }, - { 425, 1456, 32768, 300, 900 }, + { 425, 2405, 917504, 300, 900 }, + { 425, 2405, 917504, 300, 900 }, + { 425, 2404, 917504, 300, 900 }, + { 425, 1268, 32768, 300, 900 }, + { 425, 1269, 32768, 300, 900 }, + { 425, 1456, 32768, 300, 900 }, }; GIBTHING gibHound[] = { - { 425, 1326, 917504, 300, 900 }, - { 425, 1268, 32768, 300, 900 }, - { 425, 1269, 32768, 300, 900 }, - { 425, 1456, 32768, 300, 900 } + { 425, 1326, 917504, 300, 900 }, + { 425, 1268, 32768, 300, 900 }, + { 425, 1269, 32768, 300, 900 }, + { 425, 1456, 32768, 300, 900 } }; GIBTHING gibFleshGargoyle[] = { - { 425, 1369, 917504, 300, 900 }, - { 425, 1361, 917504, 300, 900 }, - { 425, 1268, 32768, 300, 900 }, - { 425, 1269, 32768, 300, 900 }, - { 425, 1456, 32768, 300, 900 } + { 425, 1369, 917504, 300, 900 }, + { 425, 1361, 917504, 300, 900 }, + { 425, 1268, 32768, 300, 900 }, + { 425, 1269, 32768, 300, 900 }, + { 425, 1456, 32768, 300, 900 } }; GIBTHING gibAxeZombieHead[] = { - { 427, 3405, 917504, 0, 0 } + { 427, 3405, 917504, 0, 0 } }; GIBLIST gibList[] = { - { gibFxGlassT, 2, NULL, 0, 300 }, - { gibFxGlassS, 1, NULL, 0, 300 }, - { gibFxBurnShard, 1, NULL, 0, 0 }, - { gibFxWoodShard, 1, NULL, 0, 0 }, - { gibFxMetalShard, 1, NULL, 0, 0 }, - { gibFxFireSpark, 1, NULL, 0, 0 }, - { gibFxShockSpark, 1, NULL, 0, 0 }, - { gibFxBloodChunks, 1, NULL, 0, 0 }, - { gibFxBubblesS, 1, NULL, 0, 0 }, - { gibFxBubblesM, 1, NULL, 0, 0 }, - { gibFxBubblesL, 1, NULL, 0, 0 }, - { gibFxIcicles, 1, NULL, 0, 0 }, - { gibFxGlassCombo1, 2, NULL, 0, 300 }, - { gibFxGlassCombo2, 5, NULL, 0, 300 }, - { gibFxWoodCombo, 3, NULL, 0, 0 }, - { NULL, 0, gibHuman, 7, 0 }, - { gibFxMedicCombo, 4, NULL, 0, 0 }, - { gibFxFlareSpark, 1, NULL, 0, 0 }, - { gibFxBloodBits, 1, NULL, 0, 0 }, - { gibFxRockShards, 2, NULL, 0, 0 }, - { gibFxPaperCombo1, 2, NULL, 0, 0 }, - { gibFxPlantCombo1, 3, NULL, 0, 0 }, - { gibFx13BBA8, 1, NULL, 0, 0 }, - { gibFx13BBC0, 1, NULL, 0, 0 }, - { gibFx13BBD8, 2, NULL, 0, 0 }, - { gibFx13BC04, 1, NULL, 0, 0 }, - { gibFx13BC1C, 1, NULL, 0, 0 }, - { NULL, 0, gibAxeZombieHead, 1, 0 }, - { NULL, 0, gibMime, 6, 0 }, - { NULL, 0, gibHound, 4, 0 }, - { NULL, 0, gibFleshGargoyle, 5, 0 }, + { gibFxGlassT, 2, NULL, 0, 300 }, + { gibFxGlassS, 1, NULL, 0, 300 }, + { gibFxBurnShard, 1, NULL, 0, 0 }, + { gibFxWoodShard, 1, NULL, 0, 0 }, + { gibFxMetalShard, 1, NULL, 0, 0 }, + { gibFxFireSpark, 1, NULL, 0, 0 }, + { gibFxShockSpark, 1, NULL, 0, 0 }, + { gibFxBloodChunks, 1, NULL, 0, 0 }, + { gibFxBubblesS, 1, NULL, 0, 0 }, + { gibFxBubblesM, 1, NULL, 0, 0 }, + { gibFxBubblesL, 1, NULL, 0, 0 }, + { gibFxIcicles, 1, NULL, 0, 0 }, + { gibFxGlassCombo1, 2, NULL, 0, 300 }, + { gibFxGlassCombo2, 5, NULL, 0, 300 }, + { gibFxWoodCombo, 3, NULL, 0, 0 }, + { NULL, 0, gibHuman, 7, 0 }, + { gibFxMedicCombo, 4, NULL, 0, 0 }, + { gibFxFlareSpark, 1, NULL, 0, 0 }, + { gibFxBloodBits, 1, NULL, 0, 0 }, + { gibFxRockShards, 2, NULL, 0, 0 }, + { gibFxPaperCombo1, 2, NULL, 0, 0 }, + { gibFxPlantCombo1, 3, NULL, 0, 0 }, + { gibFx13BBA8, 1, NULL, 0, 0 }, + { gibFx13BBC0, 1, NULL, 0, 0 }, + { gibFx13BBD8, 2, NULL, 0, 0 }, + { gibFx13BC04, 1, NULL, 0, 0 }, + { gibFx13BC1C, 1, NULL, 0, 0 }, + { NULL, 0, gibAxeZombieHead, 1, 0 }, + { NULL, 0, gibMime, 6, 0 }, + { NULL, 0, gibHound, 4, 0 }, + { NULL, 0, gibFleshGargoyle, 5, 0 }, }; int ChanceToCount(int a1, int a2) { - int vb = a2; - if (a1 < 0x10000) - { - for (int i = 0; i < a2; i++) - if (!Chance(a1)) - vb--; - } - return vb; + int vb = a2; + if (a1 < 0x10000) + { + for (int i = 0; i < a2; i++) + if (!Chance(a1)) + vb--; + } + return vb; } -void GibFX(DBloodActor* actor, GIBFX *pGFX, CGibPosition *pPos, CGibVelocity *pVel) +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void GibFX(DBloodActor* actor, GIBFX* pGFX, CGibPosition* pPos, CGibVelocity* pVel) { - auto pSector = actor->spr.sector(); - if (adult_lockout && gGameOptions.nGameType == 0 && pGFX->fxId == FX_13) - return; - CGibPosition gPos(actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z); - if (pPos) - gPos = *pPos; - int32_t ceilZ, floorZ; - getzsofslopeptr(pSector, gPos.x, gPos.y, &ceilZ, &floorZ); - int nCount = ChanceToCount(pGFX->chance, pGFX->at9); - int dz1 = floorZ-gPos.z; - int dz2 = gPos.z-ceilZ; - int top, bottom; - GetActorExtents(actor, &top, &bottom); - for (int i = 0; i < nCount; i++) - { - if (!pPos && (actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == 0) - { - int nAngle = Random(2048); - gPos.x = actor->spr.pos.X+MulScale(actor->spr.clipdist<<2, Cos(nAngle), 30); - gPos.y = actor->spr.pos.Y+MulScale(actor->spr.clipdist<<2, Sin(nAngle), 30); - gPos.z = bottom-Random(bottom-top); - } - auto pFX = gFX.fxSpawnActor(pGFX->fxId, pSector, gPos.x, gPos.y, gPos.z, 0); - if (pFX) - { - if (pGFX->at1 < 0) - pFX->spr.pal = actor->spr.pal; - if (pVel) - { - pFX->xvel = pVel->vx+Random2(pGFX->atd); - pFX->yvel = pVel->vy+Random2(pGFX->atd); - pFX->zvel = pVel->vz-Random(pGFX->at11); - } - else - { - pFX->xvel = Random2((pGFX->atd<<18)/120); - pFX->yvel = Random2((pGFX->atd<<18)/120); - switch(actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) - { - case 16: - pFX->zvel = Random2((pGFX->at11<<18)/120); - break; - default: - if (dz2 < dz1 && dz2 < 0x4000) - { - pFX->zvel = 0; - } - else if (dz2 > dz1 && dz1 < 0x4000) - { - pFX->zvel = -(int)Random((abs(pGFX->at11)<<18)/120); - } - else - { - if ((pGFX->at11<<18)/120 < 0) - pFX->zvel = -(int)Random((abs(pGFX->at11)<<18)/120); - else - pFX->zvel = Random2((pGFX->at11<<18)/120); - } - break; - } - } - } - } + auto pSector = actor->spr.sector(); + if (adult_lockout && gGameOptions.nGameType == 0 && pGFX->fxId == FX_13) + return; + CGibPosition gPos(actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z); + if (pPos) + gPos = *pPos; + int32_t ceilZ, floorZ; + getzsofslopeptr(pSector, gPos.x, gPos.y, &ceilZ, &floorZ); + int nCount = ChanceToCount(pGFX->chance, pGFX->at9); + int dz1 = floorZ - gPos.z; + int dz2 = gPos.z - ceilZ; + int top, bottom; + GetActorExtents(actor, &top, &bottom); + for (int i = 0; i < nCount; i++) + { + if (!pPos && (actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == 0) + { + int nAngle = Random(2048); + gPos.x = actor->spr.pos.X + MulScale(actor->spr.clipdist << 2, Cos(nAngle), 30); + gPos.y = actor->spr.pos.Y + MulScale(actor->spr.clipdist << 2, Sin(nAngle), 30); + gPos.z = bottom - Random(bottom - top); + } + auto pFX = gFX.fxSpawnActor(pGFX->fxId, pSector, gPos.x, gPos.y, gPos.z, 0); + if (pFX) + { + if (pGFX->at1 < 0) + pFX->spr.pal = actor->spr.pal; + if (pVel) + { + pFX->xvel = pVel->vx + Random2(pGFX->atd); + pFX->yvel = pVel->vy + Random2(pGFX->atd); + pFX->zvel = pVel->vz - Random(pGFX->at11); + } + else + { + pFX->xvel = Random2((pGFX->atd << 18) / 120); + pFX->yvel = Random2((pGFX->atd << 18) / 120); + switch (actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) + { + case 16: + pFX->zvel = Random2((pGFX->at11 << 18) / 120); + break; + default: + if (dz2 < dz1 && dz2 < 0x4000) + { + pFX->zvel = 0; + } + else if (dz2 > dz1 && dz1 < 0x4000) + { + pFX->zvel = -(int)Random((abs(pGFX->at11) << 18) / 120); + } + else + { + if ((pGFX->at11 << 18) / 120 < 0) + pFX->zvel = -(int)Random((abs(pGFX->at11) << 18) / 120); + else + pFX->zvel = Random2((pGFX->at11 << 18) / 120); + } + break; + } + } + } + } } -void GibThing(DBloodActor* actor, GIBTHING *pGThing, CGibPosition *pPos, CGibVelocity *pVel) +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void GibThing(DBloodActor* actor, GIBTHING* pGThing, CGibPosition* pPos, CGibVelocity* pVel) { - if (adult_lockout && gGameOptions.nGameType <= 0) - switch (pGThing->type) { - case kThingBloodBits: - case kThingZombieHead: - return; - } + if (adult_lockout && gGameOptions.nGameType <= 0) + switch (pGThing->type) { + case kThingBloodBits: + case kThingZombieHead: + return; + } - if (pGThing->chance == 65536 || Chance(pGThing->chance)) - { - auto pSector = actor->spr.sector(); - int top, bottom; - GetActorExtents(actor, &top, &bottom); - int x, y, z; - if (!pPos) - { - int nAngle = Random(2048); - x = actor->spr.pos.X+MulScale(actor->spr.clipdist<<2, Cos(nAngle), 30); - y = actor->spr.pos.Y+MulScale(actor->spr.clipdist<<2, Sin(nAngle), 30); - z = bottom-Random(bottom-top); - } - else - { - x = pPos->x; - y = pPos->y; - z = pPos->z; - } - int32_t ceilZ, floorZ; - getzsofslopeptr(pSector, x, y, &ceilZ, &floorZ); - int dz1 = floorZ-z; - int dz2 = z-ceilZ; - auto gibactor = actSpawnThing(pSector, x, y, z, pGThing->type); - if (!gibactor) return; + if (pGThing->chance == 65536 || Chance(pGThing->chance)) + { + auto pSector = actor->spr.sector(); + int top, bottom; + GetActorExtents(actor, &top, &bottom); + int x, y, z; + if (!pPos) + { + int nAngle = Random(2048); + x = actor->spr.pos.X + MulScale(actor->spr.clipdist << 2, Cos(nAngle), 30); + y = actor->spr.pos.Y + MulScale(actor->spr.clipdist << 2, Sin(nAngle), 30); + z = bottom - Random(bottom - top); + } + else + { + x = pPos->x; + y = pPos->y; + z = pPos->z; + } + int32_t ceilZ, floorZ; + getzsofslopeptr(pSector, x, y, &ceilZ, &floorZ); + int dz1 = floorZ - z; + int dz2 = z - ceilZ; + auto gibactor = actSpawnThing(pSector, x, y, z, pGThing->type); + if (!gibactor) return; - if (pGThing->Kills > -1) - gibactor->spr.picnum = pGThing->Kills; - if (pVel) - { - gibactor->xvel = pVel->vx+Random2(pGThing->atc); - gibactor->yvel = pVel->vy+Random2(pGThing->atc); - gibactor->zvel = pVel->vz-Random(pGThing->at10); - } - else - { - gibactor->xvel = Random2((pGThing->atc<<18)/120); - gibactor->yvel = Random2((pGThing->atc<<18)/120); - switch (actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) - { - case 16: - gibactor->zvel = Random2((pGThing->at10<<18)/120); - break; - default: - if (dz2 < dz1 && dz2 < 0x4000) - { - gibactor->zvel = 0; - } - else if (dz2 > dz1 && dz1 < 0x4000) - { - gibactor->zvel = -(int)Random((pGThing->at10<<18)/120); - } - else - { - gibactor->zvel = Random2((pGThing->at10<<18)/120); - } - break; - } - } - } + if (pGThing->Kills > -1) + gibactor->spr.picnum = pGThing->Kills; + if (pVel) + { + gibactor->xvel = pVel->vx + Random2(pGThing->atc); + gibactor->yvel = pVel->vy + Random2(pGThing->atc); + gibactor->zvel = pVel->vz - Random(pGThing->at10); + } + else + { + gibactor->xvel = Random2((pGThing->atc << 18) / 120); + gibactor->yvel = Random2((pGThing->atc << 18) / 120); + switch (actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) + { + case 16: + gibactor->zvel = Random2((pGThing->at10 << 18) / 120); + break; + default: + if (dz2 < dz1 && dz2 < 0x4000) + { + gibactor->zvel = 0; + } + else if (dz2 > dz1 && dz1 < 0x4000) + { + gibactor->zvel = -(int)Random((pGThing->at10 << 18) / 120); + } + else + { + gibactor->zvel = Random2((pGThing->at10 << 18) / 120); + } + break; + } + } + } } -void GibSprite(DBloodActor* actor, GIBTYPE nGibType, CGibPosition *pPos, CGibVelocity *pVel) +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void GibSprite(DBloodActor* actor, GIBTYPE nGibType, CGibPosition* pPos, CGibVelocity* pVel) { - assert(actor != NULL); - assert(nGibType >= 0 && nGibType < kGibMax); + assert(actor != NULL); + assert(nGibType >= 0 && nGibType < kGibMax); - if (!actor->spr.insector()) - return; - GIBLIST *pGib = &gibList[nGibType]; - for (int i = 0; i < pGib->Kills; i++) - { - GIBFX *pGibFX = &pGib->gibFX[i]; - assert(pGibFX->chance > 0); - GibFX(actor, pGibFX, pPos, pVel); - } - for (int i = 0; i < pGib->atc; i++) - { - GIBTHING *pGibThing = &pGib->at8[i]; - assert(pGibThing->chance > 0); - GibThing(actor, pGibThing, pPos, pVel); - } + if (!actor->spr.insector()) + return; + GIBLIST* pGib = &gibList[nGibType]; + for (int i = 0; i < pGib->Kills; i++) + { + GIBFX* pGibFX = &pGib->gibFX[i]; + assert(pGibFX->chance > 0); + GibFX(actor, pGibFX, pPos, pVel); + } + for (int i = 0; i < pGib->atc; i++) + { + GIBTHING* pGibThing = &pGib->at8[i]; + assert(pGibThing->chance > 0); + GibThing(actor, pGibThing, pPos, pVel); + } } -void GibFX(walltype* pWall, GIBFX * pGFX, int a3, int a4, int a5, int a6, CGibVelocity * pVel) +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void GibFX(walltype* pWall, GIBFX* pGFX, int a3, int a4, int a5, int a6, CGibVelocity* pVel) { - assert(pWall); - int nCount = ChanceToCount(pGFX->chance, pGFX->at9); - auto pSector = pWall->sectorp(); - for (int i = 0; i < nCount; i++) - { - int r1 = Random(a6); - int r2 = Random(a5); - int r3 = Random(a4); - auto pGib = gFX.fxSpawnActor(pGFX->fxId, pSector, pWall->pos.X+r3, pWall->pos.Y+r2, a3+r1, 0); - if (pGib) - { - if (pGFX->at1 < 0) - pGib->spr.pal = pWall->pal; - if (!pVel) - { - pGib->xvel = Random2((pGFX->atd<<18)/120); - pGib->yvel = Random2((pGFX->atd<<18)/120); - pGib->zvel = -(int)Random((pGFX->at11<<18)/120); - } - else - { - pGib->xvel = Random2((pVel->vx << 18) / 120); - pGib->yvel = Random2((pVel->vy << 18) / 120); - pGib->zvel = -(int)Random((pVel->vz<<18)/120); - } - } - } + assert(pWall); + int nCount = ChanceToCount(pGFX->chance, pGFX->at9); + auto pSector = pWall->sectorp(); + for (int i = 0; i < nCount; i++) + { + int r1 = Random(a6); + int r2 = Random(a5); + int r3 = Random(a4); + auto pGib = gFX.fxSpawnActor(pGFX->fxId, pSector, pWall->pos.X + r3, pWall->pos.Y + r2, a3 + r1, 0); + if (pGib) + { + if (pGFX->at1 < 0) + pGib->spr.pal = pWall->pal; + if (!pVel) + { + pGib->xvel = Random2((pGFX->atd << 18) / 120); + pGib->yvel = Random2((pGFX->atd << 18) / 120); + pGib->zvel = -(int)Random((pGFX->at11 << 18) / 120); + } + else + { + pGib->xvel = Random2((pVel->vx << 18) / 120); + pGib->yvel = Random2((pVel->vy << 18) / 120); + pGib->zvel = -(int)Random((pVel->vz << 18) / 120); + } + } + } } -void GibWall(walltype* pWall, GIBTYPE nGibType, CGibVelocity *pVel) +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void GibWall(walltype* pWall, GIBTYPE nGibType, CGibVelocity* pVel) { - assert(pWall); - assert(nGibType >= 0 && nGibType < kGibMax); - int cx, cy, cz, wx, wy, wz; + assert(pWall); + assert(nGibType >= 0 && nGibType < kGibMax); + int cx, cy, cz, wx, wy, wz; - cx = (pWall->pos.X+pWall->point2Wall()->pos.X)>>1; - cy = (pWall->pos.Y+pWall->point2Wall()->pos.Y)>>1; - auto pSector = pWall->sectorp(); - int32_t ceilZ, floorZ; - getzsofslopeptr(pSector, cx, cy, &ceilZ, &floorZ); - int32_t ceilZ2, floorZ2; - getzsofslopeptr(pWall->nextSector(), cx, cy, &ceilZ2, &floorZ2); + cx = (pWall->pos.X + pWall->point2Wall()->pos.X) >> 1; + cy = (pWall->pos.Y + pWall->point2Wall()->pos.Y) >> 1; + auto pSector = pWall->sectorp(); + int32_t ceilZ, floorZ; + getzsofslopeptr(pSector, cx, cy, &ceilZ, &floorZ); + int32_t ceilZ2, floorZ2; + getzsofslopeptr(pWall->nextSector(), cx, cy, &ceilZ2, &floorZ2); - ceilZ = ClipLow(ceilZ, ceilZ2); - floorZ = ClipHigh(floorZ, floorZ2); - wz = floorZ-ceilZ; - wx = pWall->point2Wall()->pos.X-pWall->pos.X; - wy = pWall->point2Wall()->pos.Y-pWall->pos.Y; - cz = (ceilZ+floorZ)>>1; + ceilZ = ClipLow(ceilZ, ceilZ2); + floorZ = ClipHigh(floorZ, floorZ2); + wz = floorZ - ceilZ; + wx = pWall->point2Wall()->pos.X - pWall->pos.X; + wy = pWall->point2Wall()->pos.Y - pWall->pos.Y; + cz = (ceilZ + floorZ) >> 1; - GIBLIST *pGib = &gibList[nGibType]; - sfxPlay3DSound(cx, cy, cz, pGib->at10, pSector); - for (int i = 0; i < pGib->Kills; i++) - { - GIBFX *pGibFX = &pGib->gibFX[i]; - assert(pGibFX->chance > 0); - GibFX(pWall, pGibFX, ceilZ, wx, wy, wz, pVel); - } + GIBLIST* pGib = &gibList[nGibType]; + sfxPlay3DSound(cx, cy, cz, pGib->at10, pSector); + for (int i = 0; i < pGib->Kills; i++) + { + GIBFX* pGibFX = &pGib->gibFX[i]; + assert(pGibFX->chance > 0); + GibFX(pWall, pGibFX, ceilZ, wx, wy, wz, pVel); + } } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + void gibPrecache() { - for (int i = 0; i < kGibMax; i++) - { - auto const pThing = gibList[i].at8; - if (pThing) - { - for (int j = 0; j < gibList[i].atc; j++) - { - if (pThing[j].Kills >= 0) - tilePrecacheTile(pThing[j].Kills, -1, 0); - } - } - } + for (int i = 0; i < kGibMax; i++) + { + auto const pThing = gibList[i].at8; + if (pThing) + { + for (int j = 0; j < gibList[i].atc; j++) + { + if (pThing[j].Kills >= 0) + tilePrecacheTile(pThing[j].Kills, -1, 0); + } + } + } } END_BLD_NS diff --git a/source/games/blood/src/gib.h b/source/games/blood/src/gib.h index f3d7ba0e7..cd6e4b2c7 100644 --- a/source/games/blood/src/gib.h +++ b/source/games/blood/src/gib.h @@ -25,52 +25,52 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS enum GIBTYPE { - GIBTYPE_0 = 0, - GIBTYPE_1, - GIBTYPE_2, - GIBTYPE_3, - GIBTYPE_4, - GIBTYPE_5, - GIBTYPE_6, - GIBTYPE_7, - GIBTYPE_8, - GIBTYPE_9, - GIBTYPE_10, - GIBTYPE_11, - GIBTYPE_12, - GIBTYPE_13, - GIBTYPE_14, - GIBTYPE_15, - GIBTYPE_16, - GIBTYPE_17, - GIBTYPE_18, - GIBTYPE_19, - GIBTYPE_20, - GIBTYPE_21, - GIBTYPE_22, - GIBTYPE_23, - GIBTYPE_24, - GIBTYPE_25, - GIBTYPE_26, - GIBTYPE_27, - GIBTYPE_28, - GIBTYPE_29, - GIBTYPE_30, - kGibMax + GIBTYPE_0 = 0, + GIBTYPE_1, + GIBTYPE_2, + GIBTYPE_3, + GIBTYPE_4, + GIBTYPE_5, + GIBTYPE_6, + GIBTYPE_7, + GIBTYPE_8, + GIBTYPE_9, + GIBTYPE_10, + GIBTYPE_11, + GIBTYPE_12, + GIBTYPE_13, + GIBTYPE_14, + GIBTYPE_15, + GIBTYPE_16, + GIBTYPE_17, + GIBTYPE_18, + GIBTYPE_19, + GIBTYPE_20, + GIBTYPE_21, + GIBTYPE_22, + GIBTYPE_23, + GIBTYPE_24, + GIBTYPE_25, + GIBTYPE_26, + GIBTYPE_27, + GIBTYPE_28, + GIBTYPE_29, + GIBTYPE_30, + kGibMax }; class CGibPosition { public: - int x, y, z; - CGibPosition(int _x, int _y, int _z) : x(_x), y(_y), z(_z) {} + int x, y, z; + CGibPosition(int _x, int _y, int _z) : x(_x), y(_y), z(_z) {} }; class CGibVelocity { public: - int vx, vy, vz; - CGibVelocity(int _vx, int _vy, int _vz) : vx(_vx), vy(_vy), vz(_vz) {} + int vx, vy, vz; + CGibVelocity(int _vx, int _vy, int _vz) : vx(_vx), vy(_vy), vz(_vz) {} }; -void GibSprite(DBloodActor *pSprite, GIBTYPE nGibType, CGibPosition *pPos, CGibVelocity *pVel); -void GibWall(walltype* pWall, GIBTYPE nGibType, CGibVelocity *pVel); +void GibSprite(DBloodActor* pSprite, GIBTYPE nGibType, CGibPosition* pPos, CGibVelocity* pVel); +void GibWall(walltype* pWall, GIBTYPE nGibType, CGibVelocity* pVel); END_BLD_NS diff --git a/source/games/blood/src/hudsprites.cpp b/source/games/blood/src/hudsprites.cpp index 208a33be4..b7385931c 100644 --- a/source/games/blood/src/hudsprites.cpp +++ b/source/games/blood/src/hudsprites.cpp @@ -59,6 +59,12 @@ static struct { }; +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + static void drawElement(int x, int y, int tile, double scale = 1, int flipx = 0, int flipy = 0, int pin = 0, int basepal = 0, double alpha = 1) { int flags = RS_TOPLEFT; @@ -66,10 +72,16 @@ static void drawElement(int x, int y, int tile, double scale = 1, int flipx = 0, if (flipy) flags |= RS_YFLIPHUD; if (pin == -1) flags |= RS_ALIGN_L; else if (pin == 1) flags |= RS_ALIGN_R; - hud_drawsprite(x, y, int(scale*65536), 0, tile, 0, basepal, flags, alpha); + hud_drawsprite(x, y, int(scale * 65536), 0, tile, 0, basepal, flags, alpha); } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + static void viewBurnTime(int gScale) { if (!gScale) return; @@ -86,8 +98,13 @@ static void viewBurnTime(int gScale) } } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- -void hudDraw(PLAYER *gView, sectortype* pSector, double bobx, double boby, double zDelta, int basepal, double smoothratio) +void hudDraw(PLAYER* gView, sectortype* pSector, double bobx, double boby, double zDelta, int basepal, double smoothratio) { double look_anghalf = gView->angle.look_anghalf(smoothratio); @@ -116,7 +133,7 @@ void hudDraw(PLAYER *gView, sectortype* pSector, double bobx, double boby, doubl { cY += (-2048. / 128.); } - int nShade = pSector->floorshade; + int nShade = pSector->floorshade; int nPalette = 0; if (gView->actor->spr.sector()->hasX()) { sectortype* pViewSect = gView->actor->spr.sector();