void run_application(t_interface *env) { mlx_key_hook(env->gui.win, onkey_handler, env); mlx_expose_hook(env->gui.win, expose_handler, env); mlx_loop(env->gui.mlx); mlx_destroy_image(env->gui.mlx, env->gui.image); kill_stack(&env->objects); dispose_garbage(); }
uint8_t kill_stack(uint8_t val) { char bad_memory[10]; uint8_t i; for(i=0; i<10; i++ ) bad_memory[i]=i; if(val>1) kill_stack(val-1); return 0; }
uint8_t kill_stack(uint8_t val) { char bad_memory[10]; uint8_t i; for(i=0; i<10; i++ ) bad_memory[i]=i; for(i=0; i<10; i++ ) printf( "%d ", bad_memory[i]); printf( "Die Stack %d\r\n",val ); if(val>1) kill_stack(val-1); return 0; }
int send_stuff_to_clients() { float px, py, pz, rx, ry, rz; int i, j; char buf[MESSAGE_LENGTH]; Stack s; new_stack(&s); for(i = 0; i < PLAYER_COUNT; i++) { if(player_flag[i]) { player_flag[i] = 0; if(i == 0) { getViewPosition(&px,&py,&pz); getViewOrientation(&rx,&ry,&rz); sprintf(buf, "player %f %f %f %d %d", px, py, pz, (int)ry, 0); } else { sprintf(buf, "player %f %f %f %d %d", playerPosition[i][0], playerPosition[i][1], playerPosition[i][2], (int)playerPosition[i][3], i); } push(s, buf); } } if(sun_flag) { sun_flag = 0; getLightPosition(&px,&py,&pz); sprintf(buf, "sun %d %d %d", (int)px, (int)py, (int)pz); push(s, buf); } if(clouds_flag) { clouds_flag = 0; for(i = 0; i < WORLDX; i++) for(j = 0; j < WORLDZ; j++) if(world[i][96][j] == WHITE) { sprintf(buf, "cloud %d 90 %d %d", i, j, WHITE); push(s, buf); } } for(i = 0; i < MOB_COUNT; i++) if(mobflag[i]) { mobflag[i] = 0; sprintf(buf, "mob %f %f %f %d %d", mobPosition[i][0], mobPosition[i][1], mobPosition[i][2], (int)mobPosition[i][3], i); push(s, buf); } if(digflag[0]) { digflag[0] = 0; sprintf(buf, "dig %d %d %d", digflag[1], digflag[2], digflag[3]); push(s, buf); } while(pop(s, buf) == 0) { for(i = 0; i < num_clients; i++) { sendall(fdlist[i], buf, MESSAGE_LENGTH); } } sendall(fdlist[i], "done", MESSAGE_LENGTH); kill_stack(&s); return 0; }
BOOL quetzal_stack_restore(strid_t stream, glui32 qsize) { glui32 i = 0; int num_frames = 0; kill_stack(); init_stack(1024, 128); while(i < qsize) { unsigned n; unsigned num_locals; zword locals[16]; int num_args; int var; glui32 qframe[5]; i += fillstruct(stream, qstackframe, qframe, NULL); if(qframe[qreturnPC] > total_size) { n_show_error(E_SAVE, "function return PC past end of memory", qframe[qreturnPC]); return FALSE; } if((qframe[qflags] & b11100000) != 0) { n_show_error(E_SAVE, "expected top bits of flag to be zero", qframe[qflags]); return FALSE; } var = qframe[qvar]; if(qframe[qflags] & b00010000) /* from a call_n */ var = -1; num_locals = qframe[qflags] & b00001111; if(num_locals > 15) { n_show_error(E_SAVE, "too many locals", num_locals); return FALSE; } num_args = 0; switch(qframe[qargs]) { default: n_show_error(E_SAVE, "invalid argument count", qframe[qargs]); return FALSE; case b01111111: num_args++; case b00111111: num_args++; case b00011111: num_args++; case b00001111: num_args++; case b00000111: num_args++; case b00000011: num_args++; case b00000001: num_args++; case b00000000: ; } for(n = 0; n < num_locals; n++) { unsigned char v[ZWORD_SIZE]; glk_get_buffer_stream(stream, (char *) v, ZWORD_SIZE); locals[n] = MSBdecodeZ(v); i+=ZWORD_SIZE; } if(zversion != 6 && num_frames == 0) ; /* dummy stack frame; don't really use it */ else add_stack_frame(qframe[qreturnPC], num_locals, locals, num_args, var); for(n = 0; n < qframe[qeval]; n++) { unsigned char v[ZWORD_SIZE]; glk_get_buffer_stream(stream, (char *) v, ZWORD_SIZE); stack_push(MSBdecodeZ(v)); i += ZWORD_SIZE; } num_frames++; } if(!verify_stack()) { n_show_error(E_SAVE, "restored stack fails verification", 0); return FALSE; } return TRUE; }