diff --git a/.github/workflows/crabnet.yml b/.github/workflows/crabnet.yml new file mode 100644 index 000000000..417baa189 --- /dev/null +++ b/.github/workflows/crabnet.yml @@ -0,0 +1,62 @@ +name: Crab-Main + +on: + workflow_dispatch: + push: + branches: + - 'master' + pull_request: + branches: [ master ] + + +jobs: + Evolve-To-Crab: + strategy: + matrix: + build_type: [Release, RelWithDebInfo, MinSizeRel, Debug] + target_system: [ ubuntu-22.04, windows-2022, macos-11 ] + runs-on: ${{ matrix.target_system }} + env: + BUILD_EXT: ${{ matrix.target_system == 'windows-2022' && '.lib' || '.a' }} + BUILD_PREFIX: ${{ matrix.target_system != 'windows-2022' && 'lib' || ''}} + BUILD_SUFFIX: ${{ matrix.target_system == 'windows-2022' && matrix.build_type == 'Debug' && 'd' || '' }} + BUILD_DIR: D:/a/CrabNet/CrabNet/lib/${{ matrix.build_type}}/ + # LIB_NAME: + + steps: + - uses: actions/checkout@v4 + + - name: Configure + shell: bash + run: cmake . + + - name: Build + run: | + cmake --build . --config ${{ matrix.build_type }} + + - name: Make Archive + if: github.event_name != 'pull_request' + run: | + 7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on CrabNet-${{ runner.os }}-${{ matrix.build_type }}.7z LICENSE include/ ${{ runner.os == 'Windows' && env.BUILD_DIR || 'lib/' }}${{ env.BUILD_PREFIX }}RakNetLibStatic${{ env.BUILD_SUFFIX }}${{ env.BUILD_EXT }} + # env: + # LIB_NAME: $BUILD_PREFIXRakNetLibStatic$BUILD_SUFFIX$BUILD_EXT + + + - name: Upload Release + if: github.event_name != 'pull_request' + uses: softprops/action-gh-release@v1 + with: + tag_name: Stable-CI + files: CrabNet-${{ runner.os }}-${{ matrix.build_type }}.7z + body: | + CI Build for Dreamweave CrabNet Fork + + - name: Upload Artifact + if: github.event_name == 'pull_request' + uses: actions/upload-artifact@v3 + with: + path: | + ${{ runner.os == 'Windows' && env.BUILD_DIR || 'lib/' }}${{ env.BUILD_PREFIX }}RakNetLibStatic${{ env.BUILD_SUFFIX }}${{ env.BUILD_EXT }} + include/ + LICENSE + name: CrabNet-${{ runner.os }}-${{ matrix.build_type }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a231ae0a..f1d42e05b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ ENDIF (WIN32 AND NOT UNIX) # Options option(CRABNET_ENABLE_SAMPLES "Generate RakNet sample projects." FALSE) -option(CRABNET_ENABLE_DLL "Generate the DLL project." TRUE) +option(CRABNET_ENABLE_DLL "Generate the DLL project." FALSE) option(CRABNET_ENABLE_STATIC "Generate the static library project." TRUE) option(CRABNET_ENABLE_PVS "Enable PVS Studio Analyzer" FALSE) diff --git a/Source/Plugins/FileList.cpp b/Source/Plugins/FileList.cpp index 0715b42a4..a50849454 100644 --- a/Source/Plugins/FileList.cpp +++ b/Source/Plugins/FileList.cpp @@ -265,7 +265,7 @@ void FileList::AddFilesFromDirectory(const char *applicationDirectory, const cha strcat(fullPath, "*"); - intptr_t dir = _findfirst(fullPath, &fileInfo); + long dir = _findfirst(fullPath, &fileInfo); if (dir == -1) { _findclose(dir); @@ -282,11 +282,8 @@ void FileList::AddFilesFromDirectory(const char *applicationDirectory, const cha do { // no guarantee these entries are first... - if (strcmp(".", fileInfo.name) == 0 || - strcmp("..", fileInfo.name) == 0) - { + if (strcmp(".", fileInfo.name) == 0 || strcmp("..", fileInfo.name) == 0) continue; - } if ((fileInfo.attrib & (_A_HIDDEN | _A_SUBDIR | _A_SYSTEM)) == 0) { diff --git a/Source/Plugins/HTTPConnection.cpp b/Source/Plugins/HTTPConnection.cpp index e43a1f573..057837908 100644 --- a/Source/Plugins/HTTPConnection.cpp +++ b/Source/Plugins/HTTPConnection.cpp @@ -222,75 +222,47 @@ void HTTPConnection::ProcessTCPPacket(Packet *packet) { RakAssert(packet); - // read all the packets possible - if(packet->systemAddress == server) + if (packet->systemAddress != server) + return; + + if (incomingData.GetLength() == 0) { - if(incomingData.GetLength() == 0) - { - int response_code = atoi((char *)packet->data + strlen("HTTP/1.0 ")); + int response_code = atoi((char *)packet->data + strlen("HTTP/1.0 ")); - if(response_code > 299) - { - badResponses.Push(BadResponse(packet->data, response_code)); - //printf("Closed connection (Bad response 2)\n"); - CloseConnection(); - return; - } + if (response_code > 299) + { + badResponses.Push(BadResponse(packet->data, response_code)); + CloseConnection(); + return; } + } - RakNet::RakString incomingTemp = RakNet::RakString::NonVariadic((const char*) packet->data); - incomingTemp.URLDecode(); - incomingData += incomingTemp; + RakNet::RakString incomingTemp = RakNet::RakString::NonVariadic((const char *)packet->data); + incomingTemp.URLDecode(); + incomingData += incomingTemp; - // printf((const char*) packet->data); - // printf("\n"); + RakAssert(strlen((char *)packet->data) == packet->length); + const char *start_of_body = strstr(incomingData, "\r\n\r\n"); - RakAssert(strlen((char *)packet->data) == packet->length); // otherwise it contains Null bytes + if (connectionState != CS_PROCESSING) + return; - const char *start_of_body = strstr(incomingData, "\r\n\r\n"); + long length_of_headers; + if (!start_of_body) + return; + + length_of_headers = (long)(start_of_body + 4 - incomingData.C_String()); + const char *length_header = strstr(incomingData, "\r\nLength: "); - // besides having the server close the connection, they may - // provide a length header and supply that many bytes - if( - // Why was start_of_body here? Makes the GET command fail - // start_of_body && - connectionState == CS_PROCESSING) - { - /* - // The stupid programmer that wrote this originally didn't think that just because the header contains this value doesn't mean you got the whole message - if (strstr((const char*) packet->data, "\r\nConnection: close\r\n")) - { - CloseConnection(); - } - else - { - */ - long length_of_headers; - if (start_of_body) - { - length_of_headers = (long)(start_of_body + 4 - incomingData.C_String()); - const char *length_header = strstr(incomingData, "\r\nLength: "); - - if(length_header) - { - long length = atol(length_header + 10) + length_of_headers; - - if((long) incomingData.GetLength() >= length) - { - //printf("Closed connection (Got all data due to length header)\n"); - CloseConnection(); - } - } - } - else - { - // No processing needed - } + if (!length_header) + return; + long length = atol(length_header + 10) + length_of_headers; - //} - } - } + if ((long)incomingData.GetLength() < length) + return; + + CloseConnection(); } bool HTTPConnection::IsBusy(void) const diff --git a/Source/Utils/FileOperations.cpp b/Source/Utils/FileOperations.cpp index 569090744..c8b10cb91 100644 --- a/Source/Utils/FileOperations.cpp +++ b/Source/Utils/FileOperations.cpp @@ -121,7 +121,7 @@ bool DirectoryExists(const char *directory) strcpy(baseDirWithStars, directory); AddSlash(baseDirWithStars); strcat(baseDirWithStars, "*.*"); - intptr_t dir = _findfirst(baseDirWithStars, &fileInfo); + long dir = _findfirst(baseDirWithStars, &fileInfo); if (dir == -1) return false; _findclose(dir); diff --git a/Source/Utils/_FindFirst.cpp b/Source/Utils/_FindFirst.cpp index 9c9a87812..c9b5a8d3a 100644 --- a/Source/Utils/_FindFirst.cpp +++ b/Source/Utils/_FindFirst.cpp @@ -7,6 +7,8 @@ #include "_FindFirst.h" #include "DS_List.h" +#include "FileList.h" + #include #include @@ -57,11 +59,11 @@ long _findfirst(const char *name, _finddata_t *f) // being '.' if (_findnext(ret, f) == -1) return -1; - else - return ret; + + return ret; } -int _findnext(intptr_t h, _finddata_t *f) +int _findnext(long h, _finddata_t *f) { RakAssert(h >= 0 && h < (long) fileInfo.Size()); if (h < 0 || h >= (long) fileInfo.Size()) return -1; diff --git a/Source/Utils/_FindFirst.h b/Source/Utils/_FindFirst.h index a326423c2..b4cc0ffe6 100644 --- a/Source/Utils/_FindFirst.h +++ b/Source/Utils/_FindFirst.h @@ -47,7 +47,7 @@ typedef struct _findinfo_t } _findinfo; long _findfirst(const char *name, _finddata_t *f); -int _findnext(intptr_t h, _finddata_t *f); +int _findnext(long h, _finddata_t *f); int _findclose(intptr_t h); #endif