Project

General

Profile

Statistics
| Revision:

root / proj / project / src / proj.c @ 364

History | View | Annotate | Download (19.8 KB)

1 144 up20180655
#include <lcom/lcf.h>
2
#include <lcom/proj.h>
3
#include <lcom/liblm.h>
4 351 up20180642
5
#include "proj.h"
6
7 185 up20180655
#include <math.h>
8 144 up20180655
9 149 up20180655
#include "proj_macros.h"
10 179 up20180642
#include "proj_func.h"
11 147 up20180655
12 153 up20180655
#include "interrupts_func.h"
13 270 up20180655
#include "makecode_map.h"
14 149 up20180655
15 192 up20180642
#include "crosshair.h"
16
#include "shooter.h"
17 303 up20180642
#include "zombie.h"
18 192 up20180642
#include "pistol.h"
19
#include "nothing.h"
20 237 up20180642
#include "bullet.h"
21 216 up20180642
#include "map1.h"
22 183 up20180642
23 351 up20180642
#include "hltp.h"
24 294 up20180642
25 226 up20180642
26 144 up20180655
int main(int argc, char* argv[]) {
27
28
    lcf_set_language("EN-US");
29
30 323 up20180642
    lcf_trace_calls("/home/lcom/labs/proj/trace.txt");
31 144 up20180655
32 323 up20180642
    lcf_log_output("/home/lcom/labs/proj/output.txt");
33 144 up20180655
34
    if (lcf_start(argc, argv)) return 1;
35
36
    lcf_cleanup();
37
38
    return 0;
39
}
40 147 up20180655
41 346 up20180642
#include "singleplayer.h"
42 311 up20180655
static int (multiplayer)(void);
43 346 up20180642
#include "chat.h"
44 149 up20180655
int(proj_main_loop)(int argc, char *argv[]) {
45 328 up20180642
    (void)argc; (void)argv;
46 170 up20180642
47
    int r;
48
49 313 up20180642
    if(font_init()){ printf("Failed to initialize fonts\n"); return 1; }
50 192 up20180642
51 261 up20180642
    /// subscribe interrupts
52
    if (subscribe_all()) { return 1; }
53 170 up20180642
54 297 up20180642
    /// initialize graphics
55
    if(graph_init(GRAPH_MODE)){
56
        printf("%s: failed to initalize graphics.\n", __func__);
57
        if (cleanup()) printf("%s: failed to cleanup.\n", __func__);
58
        return 1;
59
    }
60 152 up20180642
61 261 up20180642
    /// Load stuff
62
    {
63 297 up20180642
        graph_clear_screen();
64 314 up20180642
        text_t *txt = text_ctor(font_get_default(), "Loading...");
65 309 up20180642
        text_set_pos(txt, graph_get_XRes()/2, graph_get_YRes()/2);
66
        text_set_valign(txt, text_valign_center);
67
        text_set_halign(txt, text_halign_center);
68
        text_set_color(txt, TEXT_COLOR);
69 297 up20180642
        text_draw(txt);
70
        text_dtor(txt);
71
        graph_draw();
72 183 up20180642
73 261 up20180642
        bsp_crosshair = get_crosshair(); if(bsp_crosshair == NULL) printf("Failed to get crosshair\n");
74
        bsp_shooter   = get_shooter  (); if(bsp_shooter   == NULL) printf("Failed to get shooter\n");
75 303 up20180642
        bsp_zombie    = get_zombie   (); if(bsp_zombie    == NULL) printf("Failed to get zombie\n");
76 261 up20180642
        bsp_pistol    = get_pistol   (); if(bsp_pistol    == NULL) printf("Failed to get pistol\n");
77
        bsp_nothing   = get_nothing  (); if(bsp_nothing   == NULL) printf("Failed to get nothing\n");
78 362 up20180642
        bsp_bullet    = get_bullet   (); if(bsp_bullet    == NULL) printf("Failed to get bullet\n");
79
        map1          = get_map1     (); if(map1          == NULL) printf("Failed to get map1\n");
80 226 up20180642
81 261 up20180642
        sp_crosshair = sprite_ctor(bsp_crosshair); if(sp_crosshair == NULL) printf("Failed to get crosshair sprite\n");
82 362 up20180642
    }
83 226 up20180642
84 364 up20180642
    text_t *title     = text_ctor(font_get_default(), "LabWars");
85
    text_set_color(title, TEXT_COLOR);
86
    text_set_size(title, 70);
87
    text_set_pos(title, graph_get_XRes()/2, graph_get_YRes()*0.17);
88
    text_set_valign(title, text_valign_center);
89
    text_set_halign(title, text_halign_center);
90
91 314 up20180642
    menu_t *main_menu = menu_ctor(font_get_default());
92 299 up20180642
    menu_add_item(main_menu, "Single player");
93
    menu_add_item(main_menu, "Multiplayer");
94 297 up20180642
    menu_add_item(main_menu, "Chat");
95 362 up20180642
    menu_add_item(main_menu, "Exit");
96 234 up20180655
97 297 up20180642
    //uint32_t refresh_count_value = sys_hz() / REFRESH_RATE;
98
    uint8_t last_lb = 0;
99
    struct packet pp;
100
    keys_t *keys = get_key_presses();
101
102 261 up20180642
    /// loop stuff
103 297 up20180642
    int click = 0;
104 323 up20180642
    uint64_t int_vector = 0;
105 295 up20180642
    int good = true;
106
    while (good) {
107 261 up20180642
        /* Get a request message. */
108 307 up20180642
        if((r = get_interrupts_vector(&int_vector))) return r;
109 321 up20180642
        uint32_t n = 1;
110
        for (uint8_t i = 0; i < 32; i++, n <<= 1) {
111 307 up20180642
            if (int_vector & n) {
112
                interrupt_handler(i);
113
                switch (i) {
114
                    case TIMER0_IRQ:
115 192 up20180642
116 307 up20180642
                    graph_clear_screen();
117
                    switch(menu_update_state(main_menu, click)){
118
                        case -1: break;
119
                        case  0: singleplayer(); break; //campaign(); break;
120 311 up20180655
                        case  1: multiplayer() ; break;
121 307 up20180642
                        case  2: chat(); break;
122
                        case  3: good = false; break;
123
                    }
124
                    menu_draw(main_menu);
125 364 up20180642
                    text_draw(title);
126 192 up20180642
127 307 up20180642
                    click = 0;
128 202 up20180655
129 307 up20180642
                    sprite_set_pos(sp_crosshair, *get_mouse_X(), *get_mouse_Y());
130
                    sprite_draw(sp_crosshair);
131
                    graph_draw();
132 231 up20180655
133 307 up20180642
                    break;
134
                    case KBC_IRQ:
135 321 up20180642
                    if (keyboard_get_scancode()[0] == ESC_BREAK_CODE) good = false;
136 307 up20180642
                    case MOUSE_IRQ:
137 323 up20180642
                    if (mouse_get_counter_mouse_ih() >= 3) {
138
                        mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
139 307 up20180642
                        update_mouse(&pp);
140
                        if (!click) click = last_lb ^ keys->lb_pressed && keys->lb_pressed;
141
                        last_lb = keys->lb_pressed;
142 323 up20180642
                        mouse_set_counter_mouse_ih(0);
143 261 up20180642
                    }
144 307 up20180642
                    break;
145
                    case COM1_IRQ: nctp_ih(); break;
146 305 up20180642
                }
147 147 up20180655
            }
148
        }
149 261 up20180642
    }
150 149 up20180655
151 364 up20180642
    text_dtor(title);
152
    menu_dtor(main_menu);
153
154 261 up20180642
    basic_sprite_dtor      (bsp_crosshair); bsp_crosshair = NULL;
155
    basic_sprite_dtor      (bsp_shooter  ); bsp_shooter   = NULL;
156 307 up20180642
    basic_sprite_dtor      (bsp_zombie   ); bsp_zombie    = NULL;
157 261 up20180642
    sprite_dtor            (sp_crosshair ); sp_crosshair  = NULL;
158
    basic_sprite_dtor      (bsp_pistol   ); bsp_pistol    = NULL;
159
    basic_sprite_dtor      (bsp_nothing  ); bsp_nothing   = NULL;
160
    map_dtor               (map1         ); map1          = NULL;
161 319 up20180642
    font_free();
162 243 up20180642
163 261 up20180642
    // Unsubscribe interrupts
164
    if (unsubscribe_all()) {
165
        if (cleanup())
166 305 up20180642
        printf("%s: failed to cleanup.\n", __func__);
167 261 up20180642
        return 1;
168
    }
169 188 up20180642
170 261 up20180642
    if (cleanup()) {
171
        printf("%s: failed to cleanup.\n", __func__);
172
        return 1;
173
    }
174 155 up20180655
175 149 up20180655
    return 0;
176 147 up20180655
}
177 294 up20180642
178 321 up20180642
static host_info_t     *host_info   = NULL;
179
static remote_info_t   *remote_info = NULL;
180
static bullet_info_t   *bullet_info = NULL;
181 308 up20180655
182 311 up20180655
static void multiplayer_process(const uint8_t *p, const size_t sz) {
183
    void *dest = NULL;
184
    hltp_type tp = hltp_interpret(p, sz, &dest);
185 342 up20180655
    if (dest == NULL) return;
186 311 up20180655
    switch(tp){
187
        case hltp_type_host:
188 320 up20180655
            host_info = (host_info_t*)dest;
189 311 up20180655
            break;
190
        case hltp_type_remote:
191 320 up20180655
            remote_info = (remote_info_t*)dest;
192 311 up20180655
            break;
193 320 up20180655
        case hltp_type_bullet:
194
            bullet_info = (bullet_info_t*)dest;
195
            break;
196 321 up20180642
        case hltp_type_invalid: break;
197
        case hltp_type_string : break;
198 311 up20180655
    }
199
}
200
static int (multiplayer_host)(void);
201
static int (multiplayer_remote)(void);
202
static int (multiplayer)(void) {
203
    int r;
204 308 up20180655
205 314 up20180642
    menu_t *main_menu = menu_ctor(font_get_default());
206 311 up20180655
    menu_add_item(main_menu, "Create");
207
    menu_add_item(main_menu, "Connect");
208
    menu_add_item(main_menu, "Back");
209 308 up20180655
210 311 up20180655
    //uint32_t refresh_count_value = sys_hz() / REFRESH_RATE;
211
    uint8_t last_lb = 0;
212
    struct packet pp;
213
    keys_t *keys = get_key_presses();
214 308 up20180655
215 311 up20180655
    /// loop stuff
216
    int click = 0;
217 323 up20180642
    uint64_t int_vector = 0;
218 311 up20180655
    int good = true;
219
    while (good) {
220
        /* Get a request message. */
221
        if((r = get_interrupts_vector(&int_vector))) return r;
222 321 up20180642
        uint32_t n = 1;
223
        for (uint8_t i = 0; i < 32; i++, n <<= 1) {
224 311 up20180655
            if (int_vector & n) {
225
                interrupt_handler(i);
226
                switch (i) {
227
                    case TIMER0_IRQ:
228 308 up20180655
229 311 up20180655
                    graph_clear_screen();
230
                    switch(menu_update_state(main_menu, click)){
231
                        case -1: break;
232
                        case  0: multiplayer_host(); break;
233
                        case  1: multiplayer_remote(); break;
234
                        case  2: good = false; break;
235
                    }
236
                    menu_draw(main_menu);
237
238
                    click = 0;
239
240
                    sprite_set_pos(sp_crosshair, *get_mouse_X(), *get_mouse_Y());
241
                    sprite_draw(sp_crosshair);
242
                    graph_draw();
243
244
                    break;
245
                    case KBC_IRQ:
246 321 up20180642
                    if (keyboard_get_scancode()[0] == ESC_BREAK_CODE) good = false;
247 311 up20180655
                    case MOUSE_IRQ:
248 323 up20180642
                    if (mouse_get_counter_mouse_ih() >= 3) {
249
                        mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
250 311 up20180655
                        update_mouse(&pp);
251
                        if (!click) click = last_lb ^ keys->lb_pressed && keys->lb_pressed;
252
                        last_lb = keys->lb_pressed;
253 323 up20180642
                        mouse_set_counter_mouse_ih(0);
254 311 up20180655
                    }
255
                    break;
256
                    case COM1_IRQ: nctp_ih(); break;
257
                }
258
            }
259
        }
260
    }
261
    return 0;
262 308 up20180655
}
263
264 311 up20180655
static int (multiplayer_host)(void) {
265 320 up20180655
    int r;
266 308 up20180655
267 311 up20180655
    nctp_dump();
268 320 up20180655
    nctp_set_processor(multiplayer_process);
269 311 up20180655
270 308 up20180655
    ent_set_scale(DEFAULT_SCALE);
271 345 up20180642
    text_timer_t *in_game_timer = text_timer_ctor(font_get_default());
272 308 up20180655
273
    list_t *shooter_list = list_ctor();
274
275 321 up20180642
    gunner_t *shooter1 = gunner_ctor(bsp_shooter, bsp_pistol, GUNNER_PLAYER, 1); if(shooter1 == NULL) printf("Failed to get shooter1\n");
276 308 up20180655
    gunner_set_spawn(shooter1, 75, 75);
277
278 321 up20180642
    gunner_t *shooter2 = gunner_ctor(bsp_shooter, bsp_pistol, GUNNER_PLAYER, 2); if(shooter2 == NULL) printf("Failed to get shooter2\n");
279 308 up20180655
    gunner_set_spawn(shooter2, 975, 75);
280
281
    list_insert(shooter_list, list_end(shooter_list), shooter1);
282
    list_insert(shooter_list, list_end(shooter_list), shooter2);
283
284
    do {
285
        get_random_spawn(map1, shooter1, shooter_list);
286
        get_random_spawn(map1, shooter2, shooter_list);
287 339 up20180642
    } while (gunner_distance(shooter1, shooter2) < 500);
288 308 up20180655
289 320 up20180655
    host_info = host_info_ctor(shooter1, shooter2);
290
    remote_info = remote_info_ctor();
291
    bullet_info = bullet_info_ctor();
292
293 308 up20180655
    list_t *bullet_list  = list_ctor();
294
295
    ent_set_origin(gunner_get_x(shooter1)-ent_get_XLength()/2.0,
296
    gunner_get_y(shooter1)-ent_get_YLength()/2.0);
297
298
    //uint32_t refresh_count_value = sys_hz() / REFRESH_RATE;
299
    uint8_t last_lb = 0;
300
    struct packet pp;
301
    keys_t *keys = get_key_presses();
302
    /// loop stuff
303 323 up20180642
    uint64_t int_vector = 0;
304 308 up20180655
    int good = true;
305 311 up20180655
    int state = 0; // -1 for remote win, 0 for draw, 1 for host win
306 320 up20180655
    list_node_t *p1, *p2; // player states
307
    int state_1, state_2;
308 311 up20180655
    while (good) {
309
        if ((r = get_interrupts_vector(&int_vector))) return r;
310 321 up20180642
        uint32_t n = 1;
311
        for (uint8_t i = 0; i < 32; i++, n <<= 1) {
312 320 up20180655
            if (int_vector & n) {
313
                interrupt_handler(i);
314
                switch (i) {
315
                    case TIMER0_IRQ:
316 345 up20180642
                    if (timer_get_no_interrupts() % 60 == 0) text_timer_update(in_game_timer);
317 320 up20180655
                    update_movement(map1, shooter1, keys, shooter_list);
318
                    update_movement(map1, shooter2, &(remote_info->remote_keys_pressed), shooter_list);
319 308 up20180655
320 320 up20180655
                    update_game_state(map1, shooter_list, bullet_list);
321 311 up20180655
322 320 up20180655
                    p1 = list_find(shooter_list, shooter1);
323
                    p2 = list_find(shooter_list, shooter2);
324 311 up20180655
325 320 up20180655
                    if ((state_1 = (p1 == list_end(shooter_list))) || (state_2 = (p2 == list_end(shooter_list)))) {
326
                        state = state_1 - state_2;
327
                        good = false;
328
                        break;
329
                    }
330 311 up20180655
331 320 up20180655
                    double angle = get_mouse_angle(shooter1);
332
                    gunner_set_angle(shooter1, angle - M_PI_2);
333 311 up20180655
334 320 up20180655
                    ent_set_origin(gunner_get_x(shooter1)-ent_get_XLength()/2.0,
335
                                   gunner_get_y(shooter1)-ent_get_YLength()/2.0);
336 311 up20180655
337 320 up20180655
                    gunner_set_angle(shooter2, remote_info->remote_angle);
338 349 up20180655
                    build_host_structure(host_info, shooter1, shooter2);
339 320 up20180655
340 349 up20180655
                    hltp_send_host_info(host_info);
341 320 up20180655
342
                    graph_clear_screen();
343
                    map_draw   (map1);
344
                    bullet_draw_list(bullet_list);
345
                    gunner_draw_list(shooter_list);
346
347
                    text_draw(in_game_timer->text);
348
349
                    sprite_set_pos(sp_crosshair, *get_mouse_X(), *get_mouse_Y());
350
                    sprite_draw(sp_crosshair);
351
                    graph_draw();
352
353
                    break;
354
                    case KBC_IRQ:
355 321 up20180642
                    if (keyboard_get_scancode()[0] == ESC_BREAK_CODE) {
356 320 up20180655
                        good = false;
357
                    }
358
                    break;
359
                    case MOUSE_IRQ:
360 323 up20180642
                    if (mouse_get_counter_mouse_ih() >= 3) {
361
                        mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
362 320 up20180655
                        update_mouse(&pp);
363
                        if (last_lb ^ keys->lb_pressed && keys->lb_pressed)
364
                        shoot_bullet(shooter1, bullet_list, bsp_bullet);
365
                        last_lb = keys->lb_pressed;
366 323 up20180642
                        mouse_set_counter_mouse_ih(0);
367 320 up20180655
                    }
368
                    break;
369
370
                    case COM1_IRQ:
371
                        nctp_ih();
372
                        if (bullet_info->new_bullet) {
373
                            shoot_bullet(shooter2, bullet_list, bsp_bullet);
374
                            bullet_info->new_bullet = false;
375
                        }
376
                        break;
377
                }
378 311 up20180655
            }
379
        }
380 320 up20180655
    }
381 311 up20180655
382 320 up20180655
    while(list_size(shooter_list) > 0){
383
        gunner_t *p = list_erase(shooter_list, list_begin(shooter_list));
384
        gunner_dtor(p);
385
    }
386
    if(list_dtor(shooter_list)) printf("COULD NOT DESTRUCT SHOOTER LIST\n");
387
388
    while(list_size(bullet_list) > 0){
389
        bullet_t *p = (bullet_t*)list_erase(bullet_list, list_begin(bullet_list));
390
        bullet_dtor(p);
391
    }
392
    if(list_dtor(bullet_list)) printf("COULD NOT DESTRUCT BULLET LIST\n");
393
394
    host_info_dtor(host_info);
395
    remote_info_dtor(remote_info);
396
    bullet_info_dtor(bullet_info);
397
398 330 up20180655
    nctp_set_processor(NULL);
399
400 345 up20180642
    text_timer_dtor(in_game_timer); in_game_timer = NULL;
401 320 up20180655
402 308 up20180655
    return 0;
403 311 up20180655
}
404 320 up20180655
static int (multiplayer_remote)(void) {
405 311 up20180655
    int r;
406 308 up20180655
407 311 up20180655
    nctp_dump();
408
    nctp_set_processor(multiplayer_process);
409
410
    ent_set_scale(DEFAULT_SCALE);
411 345 up20180642
    text_timer_t *in_game_timer = text_timer_ctor(font_get_default());
412 311 up20180655
413
    list_t *shooter_list = list_ctor();
414
415 321 up20180642
    gunner_t *shooter1 = gunner_ctor(bsp_shooter, bsp_pistol, GUNNER_PLAYER, 2); if(shooter1 == NULL) printf("Failed to get shooter1\n");
416 311 up20180655
    gunner_set_spawn(shooter1, 75, 75);
417
418 321 up20180642
    gunner_t *shooter2 = gunner_ctor(bsp_shooter, bsp_pistol, GUNNER_PLAYER, 1); if(shooter2 == NULL) printf("Failed to get shooter2\n");
419 311 up20180655
    gunner_set_spawn(shooter2, 975, 75);
420
421
    list_insert(shooter_list, list_end(shooter_list), shooter1);
422
    list_insert(shooter_list, list_end(shooter_list), shooter2);
423
424 320 up20180655
    host_info = host_info_ctor(shooter2, shooter1);
425
    remote_info = remote_info_ctor();
426
    bullet_info = bullet_info_ctor();
427 311 up20180655
428
    list_t *bullet_list  = list_ctor();
429
430
    ent_set_origin(gunner_get_x(shooter1)-ent_get_XLength()/2.0,
431
    gunner_get_y(shooter1)-ent_get_YLength()/2.0);
432
433
    //uint32_t refresh_count_value = sys_hz() / REFRESH_RATE;
434
    uint8_t last_lb = 0;
435
    struct packet pp;
436
    keys_t *keys = get_key_presses();
437
438
    /// loop stuff
439 323 up20180642
    uint64_t int_vector = 0;
440 311 up20180655
    int good = true;
441
    while (good) {
442
        if ((r = get_interrupts_vector(&int_vector))) return r;
443 321 up20180642
        uint32_t n = 1;
444
        for (uint8_t i = 0; i < 32; i++, n <<= 1) {
445 320 up20180655
            if (int_vector & n) {
446
                interrupt_handler(i);
447
                switch (i) {
448
                    case TIMER0_IRQ:
449 345 up20180642
                    if (timer_get_no_interrupts() % 60 == 0) text_timer_update(in_game_timer);
450 311 up20180655
451 326 up20180655
                    double angle = get_mouse_angle(shooter1) - M_PI_2;
452 311 up20180655
453 320 up20180655
                    build_remote_structure(remote_info, keys, angle);
454 311 up20180655
455 342 up20180655
456 327 up20180655
                    //hltp_send_remote_info(remote_info);
457 330 up20180655
                    gunner_set_pos(shooter1, (double)host_info->remote_x, (double)host_info->remote_y);
458
                    gunner_set_angle(shooter1, (double)host_info->remote_angle);
459
                    gunner_set_health(shooter1, (double)host_info->remote_health);
460
                    gunner_set_curr_health(shooter1, (double)host_info->remote_current_health);
461 311 up20180655
462 330 up20180655
                    gunner_set_pos(shooter2, (double)host_info->host_x, (double)host_info->host_y);
463
                    gunner_set_angle(shooter2, (double)host_info->host_angle);
464
                    gunner_set_health(shooter2, (double)host_info->host_health);
465
                    gunner_set_curr_health(shooter2, (double)host_info->host_current_health);
466 311 up20180655
467 320 up20180655
                    ent_set_origin(gunner_get_x(shooter1)-ent_get_XLength()/2.0,
468
                                   gunner_get_y(shooter1)-ent_get_YLength()/2.0);
469 311 up20180655
470 342 up20180655
                    /*
471 321 up20180642
                    for (size_t j = 0; j < host_info->no_bullets; j++) {
472
                        if (host_info->bullets_shooter[j]) { // remote
473 330 up20180655
                            bullet_t *bullet = bullet_ctor(shooter1, bsp_bullet, (double)host_info->bullets_x[j], (double)host_info->bullets_y[j], (double)host_info->bullets_vx[j], (double)host_info->bullets_vy[j]);
474 320 up20180655
                            list_insert(bullet_list, list_end(bullet_list), bullet);
475
                        } else { // host
476 330 up20180655
                            bullet_t *bullet = bullet_ctor(shooter2, bsp_bullet, (double)host_info->bullets_x[j], (double)host_info->bullets_y[j], (double)host_info->bullets_vx[j], (double)host_info->bullets_vy[j]);
477 320 up20180655
                            list_insert(bullet_list, list_end(bullet_list), bullet);
478
                        }
479 342 up20180655
                    }*/
480 320 up20180655
481
                    graph_clear_screen();
482
                    map_draw   (map1);
483
                    bullet_draw_list(bullet_list);
484
                    gunner_draw_list(shooter_list);
485
486
                    text_draw(in_game_timer->text);
487
488
                    sprite_set_pos(sp_crosshair, *get_mouse_X(), *get_mouse_Y());
489
                    sprite_draw(sp_crosshair);
490
                    graph_draw();
491 342 up20180655
                    /*
492 320 up20180655
                    while(list_size(bullet_list) > 0){
493
                        bullet_t *p = (bullet_t*)list_erase(bullet_list, list_begin(bullet_list));
494
                        bullet_dtor(p);
495
                    }
496 342 up20180655
                    */
497 320 up20180655
498
                    break;
499
                    case KBC_IRQ:
500 321 up20180642
                    if (keyboard_get_scancode()[0] == ESC_BREAK_CODE) {
501 320 up20180655
                        good = false;
502
                    }
503
                    break;
504
                    case MOUSE_IRQ:
505 323 up20180642
                    if (mouse_get_counter_mouse_ih() >= 3) {
506
                        mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
507 320 up20180655
                        update_mouse(&pp);
508
                        if (last_lb ^ keys->lb_pressed && keys->lb_pressed) {
509
                            bullet_info->new_bullet = true;
510 327 up20180655
                            //hltp_send_bullet_info(bullet_info);
511 320 up20180655
                        }
512
                        last_lb = keys->lb_pressed;
513 323 up20180642
                        mouse_set_counter_mouse_ih(0);
514 320 up20180655
                    }
515
                    break;
516
517 342 up20180655
                    case COM1_IRQ:
518
                        nctp_ih();
519
                        break;
520 320 up20180655
                }
521 311 up20180655
            }
522
        }
523 320 up20180655
    }
524 311 up20180655
525 320 up20180655
    while(list_size(shooter_list) > 0){
526
        gunner_t *p = list_erase(shooter_list, list_begin(shooter_list));
527
        gunner_dtor(p);
528
    }
529
    if(list_dtor(shooter_list)) printf("COULD NOT DESTRUCT SHOOTER LIST\n");
530
531
    while(list_size(bullet_list) > 0){
532
        bullet_t *p = (bullet_t*)list_erase(bullet_list, list_begin(bullet_list));
533
        bullet_dtor(p);
534
    }
535
    if(list_dtor(bullet_list)) printf("COULD NOT DESTRUCT BULLET LIST\n");
536
537
    host_info_dtor(host_info);
538
    remote_info_dtor(remote_info);
539
    bullet_info_dtor(bullet_info);
540
541 330 up20180655
    nctp_set_processor(NULL);
542
543 345 up20180642
    text_timer_dtor(in_game_timer); in_game_timer = NULL;
544 320 up20180655
545 311 up20180655
    return 0;
546
}