More progress. Host can now see the client that has joined. Host reacts to networked messages.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
#define INPUT_QUEUE_CAPACITY 8
|
||||
|
||||
void game_instance_init(Game_Instance *instance) {
|
||||
instance->local_player_index = 0xFFFF;
|
||||
instance->local_player_id = 0xFFFF;
|
||||
// TODO: SS - Init input-queue.
|
||||
instance->simulation_accumulator = 0.0f; // TODO: SS - Should probably be moved to the Ingame context.
|
||||
instance->game_session = NULL;
|
||||
@@ -38,19 +38,25 @@ bool game_instance_host_session(Game_Instance *instance, const Game_Session_Sett
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!networking_try_host(&instance->game_networking, instance->game_session, settings)) {
|
||||
uint16_t host_player_id = 0xFFFF;
|
||||
if(!networking_try_host(&instance->game_networking, instance->game_session, settings, &host_player_id)) {
|
||||
printf("Failed to host session.\n");
|
||||
free(instance->game_session);
|
||||
instance->game_session = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
instance->local_player_id = host_player_id;
|
||||
}
|
||||
else {
|
||||
game_session_init(instance->game_session, settings);
|
||||
|
||||
for(uint32_t i = 0; i < settings.max_players; i++) {
|
||||
// When playing locally, create the player(s) here.
|
||||
assert(game_session_create_player(instance->game_session, &instance->local_player_id)); // TODO: SS - Fix me! Always assigning the newest player to be the active 'local_player_id' which isn't correct.
|
||||
}
|
||||
}
|
||||
|
||||
assert(game_session_create_player(instance->game_session, &instance->local_player_index)); // Create the host (you!).
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user