Project

General

Profile

Revision 368

multiplayer work

View differences:

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;

Also available in: Unified diff