diff --git a/.gitignore b/.gitignore index edf91f6..3c0bed3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +flight.zip ipsettings.h .vs/ diff --git a/Flight.sln b/Flight.sln index fc6e60f..ce69ac4 100644 --- a/Flight.sln +++ b/Flight.sln @@ -7,12 +7,18 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Flight", "Flight.vcxproj", EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug No Host|x64 = Debug No Host|x64 + Debug No Host|x86 = Debug No Host|x86 Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5A0EDC10-F875-4CD0-AF1D-CC7E13336AF6}.Debug No Host|x64.ActiveCfg = Debug No Host|x64 + {5A0EDC10-F875-4CD0-AF1D-CC7E13336AF6}.Debug No Host|x64.Build.0 = Debug No Host|x64 + {5A0EDC10-F875-4CD0-AF1D-CC7E13336AF6}.Debug No Host|x86.ActiveCfg = Debug No Host|Win32 + {5A0EDC10-F875-4CD0-AF1D-CC7E13336AF6}.Debug No Host|x86.Build.0 = Debug No Host|Win32 {5A0EDC10-F875-4CD0-AF1D-CC7E13336AF6}.Debug|x64.ActiveCfg = Debug|x64 {5A0EDC10-F875-4CD0-AF1D-CC7E13336AF6}.Debug|x64.Build.0 = Debug|x64 {5A0EDC10-F875-4CD0-AF1D-CC7E13336AF6}.Debug|x86.ActiveCfg = Debug|Win32 diff --git a/Flight.vcxproj b/Flight.vcxproj index ef66c2c..710df76 100644 --- a/Flight.vcxproj +++ b/Flight.vcxproj @@ -1,6 +1,14 @@ + + Debug No Host + Win32 + + + Debug No Host + x64 + Debug Win32 @@ -32,6 +40,12 @@ v143 Unicode + + Application + true + v143 + Unicode + Application false @@ -45,6 +59,12 @@ v143 Unicode + + Application + true + v143 + Unicode + Application false @@ -60,12 +80,18 @@ + + + + + + @@ -82,6 +108,18 @@ true + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + Level3 @@ -102,7 +140,22 @@ Level3 true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + _DEBUG;_CONSOLE;%(PreprocessorDefinitions);DEBUG_RENDERING; + true + C:\Users\Cameron\Documents\flight\thirdparty\enet\include;C:\Users\Cameron\Documents\flight\thirdparty\Chipmunk2D\include\chipmunk;C:\Users\Cameron\Documents\flight\thirdparty;C:\Users\Cameron\Documents\flight\thirdparty\Chipmunk2D\include;C:\Users\Cameron\Documents\flight\thirdparty\minilzo + true + + + Console + true + $(CoreLibraryDependencies);%(AdditionalDependencies);Ws2_32.lib;winmm.lib + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions);DEBUG_RENDERING; true C:\Users\Cameron\Documents\flight\thirdparty\enet\include;C:\Users\Cameron\Documents\flight\thirdparty\Chipmunk2D\include\chipmunk;C:\Users\Cameron\Documents\flight\thirdparty;C:\Users\Cameron\Documents\flight\thirdparty\Chipmunk2D\include;C:\Users\Cameron\Documents\flight\thirdparty\minilzo true @@ -121,12 +174,14 @@ true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true + C:\Users\Cameron\Documents\flight\thirdparty\enet\include;C:\Users\Cameron\Documents\flight\thirdparty\Chipmunk2D\include\chipmunk;C:\Users\Cameron\Documents\flight\thirdparty;C:\Users\Cameron\Documents\flight\thirdparty\Chipmunk2D\include;C:\Users\Cameron\Documents\flight\thirdparty\minilzo Console true true true + $(CoreLibraryDependencies);%(AdditionalDependencies);Ws2_32.lib;winmm.lib diff --git a/Flight.vcxproj.user b/Flight.vcxproj.user index 553aa2a..e0f96ca 100644 --- a/Flight.vcxproj.user +++ b/Flight.vcxproj.user @@ -7,4 +7,9 @@ --serve WindowsLocalDebugger + + + + WindowsLocalDebugger + \ No newline at end of file diff --git a/main.c b/main.c index 936f569..478b6e7 100644 --- a/main.c +++ b/main.c @@ -456,13 +456,13 @@ frame(void) }; // @Robust @BeforeShip maximum acceptable message size? char decompressed[MAX_BYTES_SIZE] = { 0 }; - size_t decompressed_len = MAX_BYTES_SIZE; + size_t decompressed_max_len = MAX_BYTES_SIZE; assert(LZO1X_MEM_DECOMPRESS == 0); - int return_value = lzo1x_decompress_safe(event.packet->data, event.packet->dataLength, decompressed, &decompressed_len, NULL); + int return_value = lzo1x_decompress_safe(event.packet->data, event.packet->dataLength, decompressed, &decompressed_max_len, NULL); // @Robust not sure what return_value is, error test on it somehow if (return_value == LZO_E_OK) { - from_bytes(&msg, decompressed, decompressed_len); + from_bytes(&msg, decompressed, decompressed_max_len); myplayer = msg.your_player; } else { diff --git a/server.c b/server.c index af7d8ae..5ac5a3b 100644 --- a/server.c +++ b/server.c @@ -193,6 +193,11 @@ void server(void* data) { int player_index = (int)(int64_t)event.peer->data; Log("%" PRId64 " disconnected player index %d.\n", (int64_t)event.peer->data, player_index); + Entity* player_body = get_entity(&gs, gs.players[player_index].entity); + if(player_body != NULL) + { + entity_destroy(&gs, player_body); + } gs.players[player_index].connected = false; // box_destroy(&gs.players[player_index].box); event.peer->data = NULL; diff --git a/types.h b/types.h index 9401952..8db83da 100644 --- a/types.h +++ b/types.h @@ -1,7 +1,7 @@ #pragma once -#define MAX_PLAYERS 4 -#define MAX_ENTITIES 1024 +#define MAX_PLAYERS 8 +#define MAX_ENTITIES 1024*2 #define BOX_SIZE 0.25f #define PLAYER_SIZE ((V2){.x = BOX_SIZE, .y = BOX_SIZE}) #define PLAYER_MASS 0.5f @@ -16,7 +16,7 @@ #define THRUSTER_FORCE 4.0f #define THRUSTER_ENERGY_USED_PER_SECOND 0.05f #define VISION_RADIUS 16.0f -#define MAX_BYTES_SIZE 1024 * 8 // maximum size of gamestate buffer +#define MAX_BYTES_SIZE 1024 * 12 // maximum size of serialized gamestate buffer #define SUN_RADIUS 10.0f #define INSTANT_DEATH_DISTANCE_FROM_SUN 300.0f #define SUN_POS ((V2){50.0f,0.0f}) @@ -274,6 +274,7 @@ void entity_set_rotation(Entity* e, float rot); void entity_set_pos(Entity* e, V2 pos); float entity_rotation(Entity* e); void entity_ensure_in_orbit(Entity* e); +void entity_destroy(GameState* gs, Entity* e); #define BOX_CHAIN_ITER(gs, cur, starting_box) for (Entity *cur = get_entity(gs, starting_box); cur != NULL; cur = get_entity(gs, cur->next_box)) #define BOXES_ITER(gs, cur, grid_entity_ptr) BOX_CHAIN_ITER(gs, cur, (grid_entity_ptr)->boxes)