From 17cebee22ed0c6fef0f3781ca963e1c189e3d81c Mon Sep 17 00:00:00 2001 From: Cameron Reikes Date: Thu, 1 Dec 2022 21:12:09 -0800 Subject: [PATCH] Xtra profiling blocks --- Flight.vcxproj | 1 - flight.rdbg | Bin 1138 -> 1226 bytes gamestate.c | 21 ++++++++++++++------- main.c | 3 +-- server.c | 2 +- types.h | 2 +- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Flight.vcxproj b/Flight.vcxproj index 539277f..2a145c4 100644 --- a/Flight.vcxproj +++ b/Flight.vcxproj @@ -58,7 +58,6 @@ true v143 Unicode - false Application diff --git a/flight.rdbg b/flight.rdbg index add557f5b4db9c4e47e514d0c99aadfb621365a9..b9fccbd8cbd6366dd562ee2f6db6c7b24de62edf 100644 GIT binary patch delta 299 zcmeywaf)+7A*0LWL`H+j8<+&yo$^yE^^$GCd~IfaMlB#qm9sdts4TTeFWD2SPKHqz zES{d2n_66wSdu!Kk;#`)10=?to0yrWmuvxKo3SPq6zFA4PGGc#sOL#ZO)5=KDM~Dd zC@^PDtI*5P1S(Zyt1L(@*2|b!7|P4Y00AHxY)vTK8ogwBpdbqn3jlF?v94WiVnuvv zUP)$2W@@o8R4lo)C_XQ>q68vQ$qf`v&d*DUFD@y{%u5I925~2!VRmC=ne51-JUM`c ahYMsIBL|Rx2?_9lgxG-CEhjTQqXYnz08bGB delta 218 zcmX@b`H5pfA!FcVMrO5%54a}BF{?~s)@8JS@;Qt1v-5M})6*&@Ph>J?G=~avLxl_U zGGHnv`!aD){=lfi=#DUoTcEfoIVQQlu_!6CB(+E{S$FbBM%Br)7`YiekyK4iW)x)9 z0!zs=axmIJq$DR6dhjwbKmdq_Yvz>&@<1XWoI074#f_11av+QHis_grid) // grids aren't damaged (this edge case sucks!) { - sqdist = cpvlengthsq(cpvsub((entity_pos(e)), (entity_pos(i.sun)))); - if (sqdist < (i.sun->sun_radius * i.sun->sun_radius)) + PROFILE_SCOPE("Grid processing") { - e->damage += 10.0 * dt; + sqdist = cpvlengthsq(cpvsub((entity_pos(e)), (entity_pos(i.sun)))); + if (sqdist < (i.sun->sun_radius * i.sun->sun_radius)) + { + e->damage += 10.0 * dt; + } } } if (e->body != NULL) { - cpVect accel = sun_gravity_accel_for_entity(e, i.sun); - cpVect new_vel = entity_vel(gs, e); - new_vel = cpvadd(new_vel, cpvmult(accel, dt)); - cpBodySetVelocity(e->body, (new_vel)); + PROFILE_SCOPE("Body processing") + { + cpVect accel = sun_gravity_accel_for_entity(e, i.sun); + cpVect new_vel = entity_vel(gs, e); + new_vel = cpvadd(new_vel, cpvmult(accel, dt)); + cpBodySetVelocity(e->body, (new_vel)); + } } } } diff --git a/main.c b/main.c index 99080bd..372bc1d 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,5 @@ //------------------------------------------------------------------------------ + // Take flight //------------------------------------------------------------------------------ @@ -1559,8 +1560,6 @@ static void frame(void) } } - // dbg_rect(before_reprediction); - // gameplay ui(false, dt, width, height); // if ui button is pressed before game logic, set the pressed to // false so it doesn't propagate from the UI modal/button diff --git a/server.c b/server.c index da8b945..6e5f40d 100644 --- a/server.c +++ b/server.c @@ -25,6 +25,7 @@ // started in a thread from host void server(void *info_raw) { + init_profiling_mythread(1); ServerThreadInfo *info = (ServerThreadInfo *)info_raw; const char *world_save_name = info->world_save; #ifdef PROFILING @@ -38,7 +39,6 @@ void server(void *info_raw) gs.server_side_computing = true; Log("Allocated %zu bytes for entities\n", entities_size); - init_profiling_mythread(1); create_initial_world(&gs); diff --git a/types.h b/types.h index f565583..41793e4 100644 --- a/types.h +++ b/types.h @@ -52,7 +52,7 @@ #define SOLAR_ENERGY_PER_SECOND 0.09f #define DAMAGE_TO_PLAYER_PER_BLOCK 0.1f #define BATTERY_CAPACITY 1.5f -#define PLAYER_ENERGY_RECHARGE_PER_SECOND 0.2f +#define PLAYER_ENERGY_RECHARGE_PER_SECOND 0.2 #define EXPLOSION_TIME 0.5f #define EXPLOSION_DAMAGE_PER_SEC 10.0f #define EXPLOSION_DAMAGE_THRESHOLD 0.2f // how much damage until it explodes