Two window tooling and disallow double piloting

main
Cameron Murphy Reikes 2 years ago
parent 6b6804dca8
commit 0efd1fca91

@ -16,6 +16,7 @@ popd
@REM /DENET_DEBUG=1^ @REM /DENET_DEBUG=1^
cl /MP /Zi /FS /Fd"flight.pdb" /Fe"flight"^ cl /MP /Zi /FS /Fd"flight.pdb" /Fe"flight"^
/I"thirdparty" /I"thirdparty\minilzo" /I"thirdparty\enet\include" /I"thirdparty\Chipmunk2D\include\chipmunk" /I"thirdparty\Chipmunk2D\include"^ /I"thirdparty" /I"thirdparty\minilzo" /I"thirdparty\enet\include" /I"thirdparty\Chipmunk2D\include\chipmunk" /I"thirdparty\Chipmunk2D\include"^
/DSERVER_ADDRESS="\"127.0.0.1\""^
main.c gamestate.c server.c debugdraw.c^ main.c gamestate.c server.c debugdraw.c^
thirdparty\minilzo\minilzo.c^ thirdparty\minilzo\minilzo.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^ 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^

@ -1131,8 +1131,8 @@ void process(GameState* gs, float dt)
if (player->input.seat_action) if (player->input.seat_action)
{ {
player->input.seat_action = false; // "handle" the input player->input.seat_action = false; // "handle" the input
Entity* the_seat = get_entity(gs, p->currently_inside_of_box); Entity* seat_maybe_in = get_entity(gs, p->currently_inside_of_box);
if (the_seat == NULL) // not in any seat if (seat_maybe_in == NULL) // not in any seat
{ {
cpPointQueryInfo query_info = { 0 }; cpPointQueryInfo query_info = { 0 };
cpShape* result = cpSpacePointQueryNearest(gs->space, v2_to_cp(world_hand_pos), 0.1f, cpShapeFilterNew(CP_NO_GROUP, CP_ALL_CATEGORIES, BOXES), &query_info); cpShape* result = cpSpacePointQueryNearest(gs->space, v2_to_cp(world_hand_pos), 0.1f, cpShapeFilterNew(CP_NO_GROUP, CP_ALL_CATEGORIES, BOXES), &query_info);
@ -1142,8 +1142,12 @@ void process(GameState* gs, float dt)
assert(potential_seat->is_box); assert(potential_seat->is_box);
if (potential_seat->box_type == BoxCockpit || potential_seat->box_type == BoxMedbay) // @Robust check by feature flag instead of box type if (potential_seat->box_type == BoxCockpit || potential_seat->box_type == BoxMedbay) // @Robust check by feature flag instead of box type
{ {
p->currently_inside_of_box = get_id(gs, potential_seat); // don't let players get inside of cockpits that somebody else is already inside of
potential_seat->player_who_is_inside_of_me = get_id(gs, p); if (get_entity(gs, potential_seat->player_who_is_inside_of_me) == NULL)
{
p->currently_inside_of_box = get_id(gs, potential_seat);
potential_seat->player_who_is_inside_of_me = get_id(gs, p);
}
} }
} }
else else
@ -1153,10 +1157,10 @@ void process(GameState* gs, float dt)
} }
else else
{ {
V2 pilot_seat_exit_spot = V2add(entity_pos(the_seat), V2scale(box_facing_vector(the_seat), BOX_SIZE)); V2 pilot_seat_exit_spot = V2add(entity_pos(seat_maybe_in), V2scale(box_facing_vector(seat_maybe_in), BOX_SIZE));
cpBodySetPosition(p->body, v2_to_cp(pilot_seat_exit_spot)); cpBodySetPosition(p->body, v2_to_cp(pilot_seat_exit_spot));
cpBodySetVelocity(p->body, v2_to_cp(player_vel(gs, p))); cpBodySetVelocity(p->body, v2_to_cp(player_vel(gs, p)));
the_seat->player_who_is_inside_of_me = (EntityID){ 0 }; seat_maybe_in->player_who_is_inside_of_me = (EntityID){ 0 };
p->currently_inside_of_box = (EntityID){ 0 }; p->currently_inside_of_box = (EntityID){ 0 };
} }
} }

@ -894,6 +894,10 @@ void event(const sapp_event* e)
cur_editing_rotation += 1; cur_editing_rotation += 1;
cur_editing_rotation %= RotationLast; cur_editing_rotation %= RotationLast;
} }
if (e->key_code == SAPP_KEYCODE_F11)
{
sapp_toggle_fullscreen();
}
int key_num = e->key_code - SAPP_KEYCODE_0; int key_num = e->key_code - SAPP_KEYCODE_0;
int target_box = key_num - 1; int target_box = key_num - 1;
if (target_box < BoxLast) { if (target_box < BoxLast) {
@ -953,8 +957,10 @@ void event(const sapp_event* e)
sapp_desc sapp_desc
sokol_main(int argc, char* argv[]) sokol_main(int argc, char* argv[])
{ {
bool hosting = false;
if (argc > 1) { if (argc > 1) {
_beginthread(server, 0, NULL); _beginthread(server, 0, NULL);
hosting = true;
} }
(void)argv; (void)argv;
return (sapp_desc) { return (sapp_desc) {
@ -964,7 +970,7 @@ sokol_main(int argc, char* argv[])
.width = 640, .width = 640,
.height = 480, .height = 480,
.gl_force_gles2 = true, .gl_force_gles2 = true,
.window_title = "Flight", .window_title = hosting ? "Flight Hosting" : "Flight Not Hosting",
.icon.sokol_default = true, .icon.sokol_default = true,
.event_cb = event, .event_cb = event,
.win32_console_attach = true, .win32_console_attach = true,

@ -8,15 +8,12 @@ SetWorkingDir, %A_ScriptDir%
^Esc::return ^Esc::return
^b:: ^b::
WinKill, Flight WinKill, "Flight Not Hosting"
Sleep, 20
WinKill, Flight
Sleep, 20 Sleep, 20
WinKill, Flight
WinActivate, flightbuild WinActivate, flightbuild
If WinActive("flightbuild") If WinActive("flightbuild")
{ {
Send, cd C:\Users\Cameron\Documents\flight{Enter} build_debug.bat && flight.exe --host{Enter} Send, cd C:\Users\Cameron\Documents\flight{Enter} build_debug.bat && flight.exe{Enter}
} }
return return

Loading…
Cancel
Save