Project

General

Profile

Revision 327

progress

View differences:

proj/include/proj_structures.h
17 17

  
18 18
typedef struct {
19 19
    // host
20
    double  host_x;
21
    double  host_y;
22
    double  host_angle;
23
    double  host_health;
24
    double  host_current_health;
20
    float    host_x;
21
    float    host_y;
22
    float    host_angle;
23
    float    host_health;
24
    float    host_current_health;
25 25

  
26 26
    // remote
27
    double  remote_x;
28
    double  remote_y;
29
    double  remote_angle;
30
    double  remote_health;
31
    double  remote_current_health;
27
    float    remote_x;
28
    float    remote_y;
29
    float    remote_angle;
30
    float    remote_health;
31
    float    remote_current_health;
32 32

  
33 33
    // bullets
34
    size_t  no_bullets;
35
    double *bullets_x;
36
    double *bullets_y;
37
    double *bullets_vx;
38
    double *bullets_vy;
39
    bool   *bullets_shooter; // false for host, true for remote
34
    uint8_t  no_bullets;
35
    float   *bullets_x;
36
    float   *bullets_y;
37
    float   *bullets_vx;
38
    float   *bullets_vy;
39
    bool    *bullets_shooter; // false for host, true for remote
40 40
} host_info_t;
41 41

  
42 42
typedef struct {
proj/libs/uart/src/hltp.c
21 21
    host_info_t *ret = (host_info_t*)malloc(sizeof(host_info_t));
22 22
    size_t pos = 0;
23 23
    // players information
24
    memcpy(ret, p + pos, sizeof(double)*10);
25
    pos += sizeof(double)*10;
24
    memcpy(ret, p + pos, sizeof(float)*10);
25
    pos += sizeof(float)*10;
26 26
    // size of arrays
27
    memcpy(&(ret->no_bullets), p + pos, sizeof(size_t));
28
    pos += sizeof(size_t);
27
    memcpy(&(ret->no_bullets), p + pos, sizeof(uint8_t));
28
    pos += sizeof(uint8_t);
29 29
    size_t sz = ret->no_bullets;
30 30
    // array containing the X positions of the bullets
31
    (ret->bullets_x) = (double*)malloc(sizeof(double)*sz);
32
    memcpy((ret->bullets_x), p + pos, sizeof(double)*sz);
33
    pos += sizeof(double)*sz;
31
    (ret->bullets_x) = (float*)malloc(sizeof(float)*sz);
32
    memcpy((ret->bullets_x), p + pos, sizeof(float)*sz);
33
    pos += sizeof(float)*sz;
34 34
    // array containing the Y positions of the bullets
35
    (ret->bullets_y) = (double*)malloc(sizeof(double)*(ret->no_bullets));
36
    memcpy((ret->bullets_y), p + pos, sizeof(double)*sz);
37
    pos += sizeof(double)*sz;
35
    (ret->bullets_y) = (float*)malloc(sizeof(float)*(ret->no_bullets));
36
    memcpy((ret->bullets_y), p + pos, sizeof(float)*sz);
37
    pos += sizeof(float)*sz;
38 38
    // array containing the X velocity of the bullets
39
    (ret->bullets_vx) = (double*)malloc(sizeof(double)*(ret->no_bullets));
40
    memcpy((ret->bullets_vx), p + pos, sizeof(double)*sz);
41
    pos += sizeof(double)*sz;
39
    (ret->bullets_vx) = (float*)malloc(sizeof(float)*(ret->no_bullets));
40
    memcpy((ret->bullets_vx), p + pos, sizeof(float)*sz);
41
    pos += sizeof(float)*sz;
42 42
    // array containing the Y velocity of the bullets
43
    (ret->bullets_vy) = (double*)malloc(sizeof(double)*(ret->no_bullets));
44
    memcpy((ret->bullets_vy), p + pos, sizeof(double)*sz);
45
    pos += sizeof(double)*sz;
43
    (ret->bullets_vy) = (float*)malloc(sizeof(float)*(ret->no_bullets));
44
    memcpy((ret->bullets_vy), p + pos, sizeof(float)*sz);
45
    pos += sizeof(float)*sz;
46 46
    // array containing the shooter id of the bullets
47 47
    (ret->bullets_shooter) = (bool*)malloc(sizeof(bool)*(ret->no_bullets));
48 48
    memcpy((ret->bullets_shooter), p + pos, sizeof(bool)*sz);
......
54 54
    uint8_t type = hltp_type_host;
55 55
    const uint8_t* ptr[17]; size_t sz[17];
56 56
    ptr[0]  = (uint8_t*)&   type                  ;     sz[0]   = 1;
57
    ptr[1]  = (uint8_t*)&p->host_x                ;     sz[1]   = sizeof(double);
58
    ptr[2]  = (uint8_t*)&p->host_y                ;     sz[2]   = sizeof(double);
59
    ptr[3]  = (uint8_t*)&p->host_angle            ;     sz[3]   = sizeof(double);
60
    ptr[4]  = (uint8_t*)&p->host_health           ;     sz[4]   = sizeof(double);
61
    ptr[5]  = (uint8_t*)&p->host_current_health   ;     sz[5]   = sizeof(double);
62
    ptr[6]  = (uint8_t*)&p->remote_x              ;     sz[6]   = sizeof(double);
63
    ptr[7]  = (uint8_t*)&p->remote_y              ;     sz[7]   = sizeof(double);
64
    ptr[8]  = (uint8_t*)&p->remote_angle          ;     sz[8]   = sizeof(double);
65
    ptr[9]  = (uint8_t*)&p->remote_health         ;     sz[9]   = sizeof(double);
66
    ptr[10] = (uint8_t*)&p->remote_current_health ;     sz[10]  = sizeof(double);
67
    ptr[11] = (uint8_t*)&p->no_bullets            ;     sz[11]  = sizeof(size_t);
68
    ptr[12] = (uint8_t*) p->bullets_x             ;     sz[12]  = sizeof(double) * p->no_bullets;
69
    ptr[13] = (uint8_t*) p->bullets_y             ;     sz[13]  = sizeof(double) * p->no_bullets;
70
    ptr[14] = (uint8_t*) p->bullets_vx            ;     sz[14]  = sizeof(double) * p->no_bullets;
71
    ptr[15] = (uint8_t*) p->bullets_vy            ;     sz[15]  = sizeof(double) * p->no_bullets;
72
    ptr[16] = (uint8_t*) p->bullets_shooter       ;     sz[16]  = sizeof(double) * p->no_bullets;
57
    ptr[1]  = (uint8_t*)&p->host_x                ;     sz[1]   = sizeof(float);
58
    ptr[2]  = (uint8_t*)&p->host_y                ;     sz[2]   = sizeof(float);
59
    ptr[3]  = (uint8_t*)&p->host_angle            ;     sz[3]   = sizeof(float);
60
    ptr[4]  = (uint8_t*)&p->host_health           ;     sz[4]   = sizeof(float);
61
    ptr[5]  = (uint8_t*)&p->host_current_health   ;     sz[5]   = sizeof(float);
62
    ptr[6]  = (uint8_t*)&p->remote_x              ;     sz[6]   = sizeof(float);
63
    ptr[7]  = (uint8_t*)&p->remote_y              ;     sz[7]   = sizeof(float);
64
    ptr[8]  = (uint8_t*)&p->remote_angle          ;     sz[8]   = sizeof(float);
65
    ptr[9]  = (uint8_t*)&p->remote_health         ;     sz[9]   = sizeof(float);
66
    ptr[10] = (uint8_t*)&p->remote_current_health ;     sz[10]  = sizeof(float);
67
    ptr[11] = (uint8_t*)&p->no_bullets            ;     sz[11]  = sizeof(uint8_t);
68
    ptr[12] = (uint8_t*) p->bullets_x             ;     sz[12]  = sizeof(float) * p->no_bullets;
69
    ptr[13] = (uint8_t*) p->bullets_y             ;     sz[13]  = sizeof(float) * p->no_bullets;
70
    ptr[14] = (uint8_t*) p->bullets_vx            ;     sz[14]  = sizeof(float) * p->no_bullets;
71
    ptr[15] = (uint8_t*) p->bullets_vy            ;     sz[15]  = sizeof(float) * p->no_bullets;
72
    ptr[16] = (uint8_t*) p->bullets_shooter       ;     sz[16]  = sizeof(float) * p->no_bullets;
73 73
    return nctp_send(17, ptr, sz);
74 74
}
75 75

  
proj/src/proj.c
349 349

  
350 350
                    build_host_structure(host_info, shooter1, shooter2, bullet_list);
351 351

  
352
                    //hltp_send_host_info(host_info);
353 352

  
353

  
354
                    hltp_send_host_info(host_info);
355

  
354 356
                    graph_clear_screen();
355 357
                    map_draw   (map1);
356 358
                    bullet_draw_list(bullet_list);
......
462 464

  
463 465
                    build_remote_structure(remote_info, keys, angle);
464 466

  
465
                    hltp_send_remote_info(remote_info);
467
                    //hltp_send_remote_info(remote_info);
466 468

  
467 469
                    gunner_set_pos(shooter1, host_info->remote_x, host_info->remote_y);
468 470
                    gunner_set_angle(shooter1, host_info->remote_angle);
......
515 517
                        update_mouse(&pp);
516 518
                        if (last_lb ^ keys->lb_pressed && keys->lb_pressed) {
517 519
                            bullet_info->new_bullet = true;
518
                            hltp_send_bullet_info(bullet_info);
520
                            //hltp_send_bullet_info(bullet_info);
519 521
                        }
520 522
                        last_lb = keys->lb_pressed;
521 523
                        mouse_set_counter_mouse_ih(0);
proj/src/proj_func.c
336 336
    // bullets
337 337
    size_t sz = list_size(bullet_list);
338 338
    p->no_bullets = sz;
339
    p->bullets_x        = (double*)realloc(p->bullets_x         , sz * sizeof(double));
340
    p->bullets_y        = (double*)realloc(p->bullets_y         , sz * sizeof(double));
341
    p->bullets_vx       = (double*)realloc(p->bullets_vx        , sz * sizeof(double));
342
    p->bullets_vy       = (double*)realloc(p->bullets_vy        , sz * sizeof(double));
343
    p->bullets_shooter  = (bool*)  realloc(p->bullets_shooter   , sz * sizeof(bool  ));
339
    p->bullets_x        = (float*)realloc(p->bullets_x         , sz * sizeof(float));
340
    p->bullets_y        = (float*)realloc(p->bullets_y         , sz * sizeof(float));
341
    p->bullets_vx       = (float*)realloc(p->bullets_vx        , sz * sizeof(float));
342
    p->bullets_vy       = (float*)realloc(p->bullets_vy        , sz * sizeof(float));
343
    p->bullets_shooter  = (bool*) realloc(p->bullets_shooter   , sz * sizeof(bool ));
344 344

  
345 345
    list_node_t *it = list_begin(bullet_list);
346 346
    size_t i = 0;

Also available in: Unified diff