update
This commit is contained in:
parent
8e82909923
commit
8b5160375f
6 changed files with 91 additions and 3 deletions
12
client/gl.c
12
client/gl.c
|
|
@ -13,6 +13,8 @@ gl_scene_t gl_scenes[] = {
|
|||
{NULL, NULL, NULL} /**/
|
||||
};
|
||||
|
||||
static char gl_status[256];
|
||||
|
||||
void gl_resize(int width, int height) {
|
||||
glViewport(0, 0, width, height);
|
||||
}
|
||||
|
|
@ -48,6 +50,8 @@ void gl_init(void) {
|
|||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
gl_font_init();
|
||||
|
||||
gl_status[0] = 0;
|
||||
}
|
||||
|
||||
void gl_cube(double x, double y, double z, double xs, double ys, double zs, double xr, double yr, double zr) {
|
||||
|
|
@ -91,6 +95,8 @@ static void gl_common(void) {
|
|||
|
||||
sprintf(buf, "%s", AF_COPYRIGHT);
|
||||
gl_font_text(buf, MwGetInteger(opengl, MwNwidth) - gl_font_width(buf), MwGetInteger(opengl, MwNheight) - gl_font_height(buf), 1);
|
||||
|
||||
gl_font_text(gl_status, 0, 0, 1);
|
||||
}
|
||||
|
||||
void gl_render(void) {
|
||||
|
|
@ -117,6 +123,12 @@ void gl_render(void) {
|
|||
|
||||
void gl_scene_change(void) {
|
||||
if(gl_scenes[gl_scene].changed != NULL) gl_scenes[gl_scene].changed();
|
||||
|
||||
gl_status[0] = 0;
|
||||
}
|
||||
|
||||
void gl_set_status(const char* status) {
|
||||
strcpy(gl_status, status);
|
||||
}
|
||||
|
||||
static void cross(double* out, double v00, double v01, double v02, double v10, double v11, double v12) {
|
||||
|
|
|
|||
21
client/net.c
21
client/net.c
|
|
@ -4,7 +4,7 @@ static fishsoup_client_t* client = NULL;
|
|||
|
||||
enum OPAQUE_STATES {
|
||||
OPAQUE_WAITING_HELLO = 0,
|
||||
OPAQUE_SENT_JOIN
|
||||
OPAQUE_JOINING
|
||||
};
|
||||
|
||||
typedef struct opaque {
|
||||
|
|
@ -41,13 +41,28 @@ static void on_packet(fishsoup_client_t* self, fishsoup_packet_t* pkt) {
|
|||
|
||||
fishsoup_packet_send(self->fd, &p);
|
||||
|
||||
o->state = OPAQUE_SENT_JOIN;
|
||||
o->state = OPAQUE_JOINING;
|
||||
|
||||
gl_set_status("Joining");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
af_common_log_info("Server version is incompatible with this client\n");
|
||||
MwAddUserHandler(ui_message("Server version is incompatible with this client"), MwNactivateHandler, net_return, NULL);
|
||||
fishsoup_client_destroy(self);
|
||||
client = NULL;
|
||||
} else if(pkt->header.type == AF_PACKET_OK && pkt->header.length == sizeof(af_packet_ok_t) && o->state == OPAQUE_JOINING) {
|
||||
af_packet_ok_t* p_ok = pkt->data;
|
||||
|
||||
af_common_log_info("OK Packet: Joined successfully\n");
|
||||
|
||||
gl_set_status("Downloading data");
|
||||
} else if(pkt->header.type == AF_PACKET_ERROR && pkt->header.length == sizeof(af_packet_error_t) && o->state == OPAQUE_JOINING) {
|
||||
af_packet_error_t* p_error = pkt->data;
|
||||
|
||||
af_common_log_info("ERROR Packet: Failed to join\n");
|
||||
|
||||
fishsoup_client_destroy(self);
|
||||
client = NULL;
|
||||
}
|
||||
|
|
@ -74,6 +89,8 @@ void net_connect(const char* username, const char* hostname, int port) {
|
|||
|
||||
fishsoup_client_on_packet(client, on_packet);
|
||||
fishsoup_client_on_disconnect(client, on_disconnect);
|
||||
|
||||
gl_set_status("Waiting for server to be ready");
|
||||
}
|
||||
|
||||
void net_poll(void) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue