Project

General

Profile

Revision 368

multiplayer work

View differences:

proj/project/src/hltp.c
18 18
}
19 19

  
20 20
static host_info_t* hltp_interpret_host_info(const uint8_t *p, const size_t sz) {
21
    printf("%s\n", __func__);
22
    printf("sizeof(host_info_t)=%d, sz=%d\n", sizeof(host_info_t), sz);
23
    if (sz != sizeof(host_info_t)) { printf("%d should equal %d\n", sz, sizeof(host_info_t)); return NULL;}
21
    if (sz != sizeof(host_info_t)) return NULL;
24 22
    host_info_t *ret = (host_info_t*)malloc(sizeof(host_info_t));
25 23
    //size_t pos = 0;
26 24
    // players information
......
53 51
    */
54 52
    return ret;
55 53
}
56
int hltp_send_host_info(const host_info_t *p) { printf("%s, %d\n",__func__, rand());
54
int hltp_send_host_info(const host_info_t *p) { //printf("%s, %d\n",__func__, rand());
57 55

  
58 56
    //printf("    sending angle: 0x%04X\n", p->host_angle);
59 57

  
......
96 94

  
97 95
    uint8_t type = hltp_type_remote;
98 96
    const uint8_t* ptr[3]; size_t sz[3];
99
    ptr[0]  = (uint8_t*)&   type                  ;     sz[0] = 1;
100
    ptr[1]  = (uint8_t*)&p->remote_keys_pressed   ;     sz[1] = sizeof(keys_t);
101
    ptr[2]  = (uint8_t*)&p->remote_angle          ;     sz[2] = sizeof(double);
97
    ptr[0]  = (uint8_t*)&   type                    ;     sz[0] = 1;
98
    ptr[1]  = (uint8_t*)&(p->remote_keys_pressed)   ;     sz[1] = sizeof(keys_t);
99
    ptr[2]  = (uint8_t*)&(p->remote_angle)          ;     sz[2] = sizeof(double);
102 100
    return nctp_send(3, ptr, sz);
103 101
}
104 102

  
......
117 115
    return nctp_send(2, ptr, sz);
118 116
}
119 117

  
120
hltp_type hltp_interpret(const uint8_t *p, const size_t sz, void **dest){ printf("%s %d\n",__func__, rand());
118
hltp_type hltp_interpret(const uint8_t *p, const size_t sz, void **dest){ //printf("%s %d\n",__func__, rand());
121 119
    uint8_t ret = p[0];
122
    printf("    ret=%d\n", ret);
120
    //printf("    ret=%d\n", ret);
123 121
    switch(ret){
124 122
        case hltp_type_string: *dest = hltp_interpret_string     (p+1, sz-1);   break;
125 123
        case hltp_type_host  : *dest = hltp_interpret_host_info  (p+1, sz-1);   break;
proj/project/src/proj.c
338 338
                    gunner_set_angle(shooter2, remote_info->remote_angle);
339 339
                    build_host_structure(host_info, shooter1, shooter2);
340 340

  
341
                    hltp_send_host_info(host_info);
341
                    //hltp_send_host_info(host_info);
342 342

  
343 343
                    graph_clear_screen();
344 344
                    map_draw   (map1);
......
452 452

  
453 453
                    double angle = get_mouse_angle(shooter1) - M_PI_2;
454 454

  
455
                    build_remote_structure(remote_info, keys, angle);
455
                    build_remote_structure(remote_info, get_key_presses(), angle);
456
                    hltp_send_remote_info(remote_info);
456 457

  
457 458

  
458
                    //hltp_send_remote_info(remote_info);
459 459
                    gunner_set_pos(shooter1, (double)host_info->remote_x, (double)host_info->remote_y);
460 460
                    gunner_set_angle(shooter1, (double)host_info->remote_angle);
461 461
                    gunner_set_health(shooter1, (double)host_info->remote_health);

Also available in: Unified diff