113 lines
2.4 KiB
C
113 lines
2.4 KiB
C
#ifndef SIM_MSG_H
|
|
#define SIM_MSG_H
|
|
|
|
#include "host.h"
|
|
|
|
struct world;
|
|
struct sim_client;
|
|
|
|
/* ========================== *
|
|
* Sim cmd
|
|
* ========================== */
|
|
|
|
enum sim_cmd_state {
|
|
SIM_CMD_STATE_STOP = -1,
|
|
SIM_CMD_STATE_NO_CHANGE = 0,
|
|
SIM_CMD_STATE_START = 1
|
|
};
|
|
|
|
enum sim_cmd_kind {
|
|
SIM_CMD_KIND_NONE,
|
|
|
|
SIM_CMD_KIND_PLAYER_CONTROL,
|
|
SIM_CMD_KIND_PLAYER_FIRE,
|
|
|
|
SIM_CMD_KIND_SIM_CLIENT_CONNECT,
|
|
SIM_CMD_KIND_SIM_CLIENT_DISCONNECT,
|
|
|
|
/* Testing */
|
|
SIM_CMD_KIND_CLEAR_ALL,
|
|
SIM_CMD_KIND_SPAWN_TEST,
|
|
SIM_CMD_KIND_PAUSE,
|
|
SIM_CMD_KIND_STEP,
|
|
SIM_CMD_KIND_DRAG_OBJECT,
|
|
SIM_CMD_KIND_CURSOR_MOVE,
|
|
|
|
SIM_CMD_KIND_COUNT
|
|
};
|
|
|
|
struct sim_cmd {
|
|
enum sim_cmd_kind kind;
|
|
enum sim_cmd_state state;
|
|
struct host_channel_id channel_id;
|
|
|
|
/* SIM_CMD_KIND_PLAYER_CONTROL */
|
|
struct v2 move_dir;
|
|
struct v2 aim_dir;
|
|
|
|
/* SIM_CMD_KIND_CURSOR_MOVE */
|
|
struct v2 cursor_pos;
|
|
|
|
/* SIM_CMD_KIND_PLAYER_DISCONNECT */
|
|
struct string disconnect_reason;
|
|
|
|
#if RTC
|
|
u32 collider_gjk_steps;
|
|
#endif
|
|
|
|
struct sim_cmd *next;
|
|
};
|
|
|
|
struct sim_cmd_list {
|
|
struct sim_cmd *first;
|
|
struct sim_cmd *last;
|
|
};
|
|
|
|
struct string sim_string_from_cmds(struct arena *arena, struct sim_cmd_list cmds);
|
|
void sim_cmds_from_host_events(struct arena *arena, struct host_event_array host_events, struct sim_cmd_list *cmds_out);
|
|
|
|
/* ========================== *
|
|
* Sim event
|
|
* ========================== */
|
|
|
|
enum sim_event_kind {
|
|
SIM_EVENT_KIND_NONE,
|
|
|
|
SIM_EVENT_KIND_CONNECT,
|
|
SIM_EVENT_KIND_DISCONNECT,
|
|
SIM_EVENT_KIND_SNAPSHOT,
|
|
|
|
//SIM_EVENT_KIND_ENTITY_UPDATE,
|
|
//SIM_EVENT_KIND_ENTITY_CREATE,
|
|
//SIM_EVENT_KIND_ENTITY_DESTROY
|
|
};
|
|
|
|
struct sim_event {
|
|
enum sim_event_kind kind;
|
|
struct host_channel_id channel_id;
|
|
|
|
struct string disconnect_reason;
|
|
|
|
/* SIM_EVENT_KIND_SNAPSHOT */
|
|
struct string snapshot_data;
|
|
|
|
struct sim_event *next;
|
|
};
|
|
|
|
struct sim_event_list {
|
|
struct sim_event *first;
|
|
struct sim_event *last;
|
|
};
|
|
|
|
struct string sim_string_from_events(struct arena *arena, struct sim_event_list events);
|
|
void sim_events_from_host_events(struct arena *arena, struct host_event_array host_events, struct sim_event_list *events_out);
|
|
|
|
/* ========================== *
|
|
* Snapshot
|
|
* ========================== */
|
|
|
|
struct string sim_string_from_tick(struct arena *arena, struct sim_client *client, struct world *tick);
|
|
void sim_tick_from_string(struct string str, struct world *tick_out);
|
|
|
|
#endif
|