diff --git a/.gitignore b/.gitignore
index e8fc45b..edf91f6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
ipsettings.h
+.vs/
+x64/
*.exe
*.obj
*.pdb
diff --git a/CppProperties.json b/CppProperties.json
new file mode 100644
index 0000000..659bf4e
--- /dev/null
+++ b/CppProperties.json
@@ -0,0 +1,21 @@
+{
+ "configurations": [
+ {
+ "inheritEnvironments": [
+ "msvc_x86"
+ ],
+ "name": "x86-Debug",
+ "includePath": [
+ "${env.INCLUDE}",
+ "${workspaceRoot}\\**"
+ ],
+ "defines": [
+ "WIN32",
+ "_DEBUG",
+ "UNICODE",
+ "_UNICODE"
+ ],
+ "intelliSenseMode": "windows-msvc-x86"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/Flight.sln b/Flight.sln
new file mode 100644
index 0000000..fc6e60f
--- /dev/null
+++ b/Flight.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.3.32901.215
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Flight", "Flight.vcxproj", "{5A0EDC10-F875-4CD0-AF1D-CC7E13336AF6}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ 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|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
+ {5A0EDC10-F875-4CD0-AF1D-CC7E13336AF6}.Debug|x86.Build.0 = Debug|Win32
+ {5A0EDC10-F875-4CD0-AF1D-CC7E13336AF6}.Release|x64.ActiveCfg = Release|x64
+ {5A0EDC10-F875-4CD0-AF1D-CC7E13336AF6}.Release|x64.Build.0 = Release|x64
+ {5A0EDC10-F875-4CD0-AF1D-CC7E13336AF6}.Release|x86.ActiveCfg = Release|Win32
+ {5A0EDC10-F875-4CD0-AF1D-CC7E13336AF6}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {31496860-491F-46FA-9219-598559F5A1E7}
+ EndGlobalSection
+EndGlobal
diff --git a/Flight.vcxproj b/Flight.vcxproj
new file mode 100644
index 0000000..91cd780
--- /dev/null
+++ b/Flight.vcxproj
@@ -0,0 +1,195 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 16.0
+ Win32Proj
+ {5a0edc10-f875-4cd0-af1d-cc7e13336af6}
+ Flight
+ 10.0
+
+
+
+ Application
+ true
+ v143
+ Unicode
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+
+
+ Application
+ true
+ v143
+ Unicode
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Level3
+ true
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ Level3
+ true
+ _DEBUG;_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
+
+
+ Console
+ true
+ $(CoreLibraryDependencies);%(AdditionalDependencies);Ws2_32.lib;winmm.lib
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Flight.vcxproj.filters b/Flight.vcxproj.filters
new file mode 100644
index 0000000..1820211
--- /dev/null
+++ b/Flight.vcxproj.filters
@@ -0,0 +1,188 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+
+
+ Source Files
+
+
+
\ No newline at end of file
diff --git a/Flight.vcxproj.user b/Flight.vcxproj.user
new file mode 100644
index 0000000..67771c9
--- /dev/null
+++ b/Flight.vcxproj.user
@@ -0,0 +1,10 @@
+
+
+
+ true
+
+
+ --serve
+ WindowsLocalDebugger
+
+
\ No newline at end of file
diff --git a/build_debug.bat b/build_debug.bat
index 4abda12..128a37a 100644
--- a/build_debug.bat
+++ b/build_debug.bat
@@ -14,7 +14,7 @@ pushd thirdparty\Chipmunk2D\src
popd
@REM /DENET_DEBUG=1^
-cl /MP /Zi /Fd"flight.pdb" /Fe"flight"^
+cl /MP /Zi /FS /Fd"flight.pdb" /Fe"flight"^
/I"thirdparty" /I"thirdparty\enet\include" /I"thirdparty\Chipmunk2D\include\chipmunk" /I"thirdparty\Chipmunk2D\include"^
main.c gamestate.c server.c debugdraw.c^
thirdparty\enet\callbacks.c thirdparty\enet\compress.c thirdparty\enet\host.c thirdparty\enet\list.c thirdparty\enet\packet.c thirdparty\enet\peer.c thirdparty\enet\protocol.c thirdparty\enet\win32.c Ws2_32.lib winmm.lib^
diff --git a/gamestate.c b/gamestate.c
index bbe111a..f9cb371 100644
--- a/gamestate.c
+++ b/gamestate.c
@@ -121,6 +121,7 @@ void box_remove_from_boxes(GameState *gs, Entity *box)
box->prev_box = (EntityID){0};
}
+void on_entity_child_shape(cpBody* body, cpShape* shape, void* data);
void entity_destroy(GameState *gs, Entity *e)
{
assert(e->exists);
@@ -135,15 +136,18 @@ void entity_destroy(GameState *gs, Entity *e)
box_remove_from_boxes(gs, e);
}
- if (e->body != NULL)
- {
- cpSpaceRemoveBody(gs->space, e->body);
- cpBodyFree(e->body);
- }
if (e->shape != NULL)
{
cpSpaceRemoveShape(gs->space, e->shape);
cpShapeFree(e->shape);
+ e->shape = NULL;
+ }
+ if (e->body != NULL)
+ {
+ cpBodyEachShape(e->body, on_entity_child_shape, (void*)gs);
+ cpSpaceRemoveBody(gs->space, e->body);
+ cpBodyFree(e->body);
+ e->body = NULL;
}
e->body = NULL;
e->shape = NULL;
@@ -158,6 +162,11 @@ void entity_destroy(GameState *gs, Entity *e)
gs->free_list = get_id(gs, e);
}
+void on_entity_child_shape(cpBody* body, cpShape* shape, void* data)
+{
+ entity_destroy((GameState*)data, cp_shape_entity(shape));
+}
+
Entity *new_entity(struct GameState *gs)
{
Entity *to_return = NULL;
@@ -1081,7 +1090,7 @@ void process(struct GameState *gs, float dt)
{
Entity *new_grid = new_entity(gs);
grid_create(gs, new_grid);
- p->spice_taken_away += 0.2f;
+ p->spice_taken_away += 0.1f;
entity_set_pos(new_grid, world_build);
Entity *new_box = new_entity(gs);
@@ -1096,6 +1105,7 @@ void process(struct GameState *gs, float dt)
box_create(gs, new_box, target_grid, grid_world_to_local(target_grid, world_build));
new_box->box_type = player->input.build_type;
new_box->compass_rotation = player->input.build_rotation;
+ p->spice_taken_away += 0.1f;
}
}
#endif
diff --git a/main.c b/main.c
index 409fad6..adacecd 100644
--- a/main.c
+++ b/main.c
@@ -699,8 +699,8 @@ static void frame(void)
void cleanup(void)
{
- free(gs.entities);
destroy(&gs);
+ free(gs.entities);
sgp_shutdown();
sg_shutdown();
enet_deinitialize();
diff --git a/thirdparty/enet b/thirdparty/enet
index b06d154..eabda75 160000
--- a/thirdparty/enet
+++ b/thirdparty/enet
@@ -1 +1 @@
-Subproject commit b06d15457909d54cd4fc0ba58c3b257d7e913f7f
+Subproject commit eabda75009b6cb662185b041948bd54ccddb01ad