~ubuntu-branches/ubuntu/precise/crossfire-client/precise

« back to all changes in this revision

Viewing changes to common/commands.c

  • Committer: Bazaar Package Importer
  • Author(s): Kari Pahula
  • Date: 2006-07-06 05:28:42 UTC
  • mfrom: (1.2.4 upstream) (3.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20060706052842-gyjncpvl56luk1nd
Tags: 1.9.1-1
* New upstream release
* asound [!kfreebsd-i386 !kfreebsd-amd64 !hurd-i386] (Closes: #375398)
* Patched gcfclient2 to make Configure menu option not segfault when no
  existing configuration file is present

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
const char *rcsid_common_commands_c =
2
 
    "$Id: commands.c,v 1.38 2006/02/23 20:18:28 akirschbaum Exp $";
 
2
    "$Id: commands.c,v 1.39 2006/05/15 05:57:43 mwedel Exp $";
3
3
/*
4
4
    Crossfire client, a client program for the crossfire program.
5
5
 
253
253
                draw_info("Server does not support other image sets, will use default", NDI_RED);
254
254
                face_info.faceset=0;
255
255
            }
 
256
        } else if (!strcmp(cmd,"map2cmd")) {
 
257
            if (!strcmp(param,"FALSE")) {
 
258
                draw_info("Server does not support map2cmd, will try map1acmd", NDI_RED);
 
259
                cs_print_string(csocket.fd,"setup map1acmd 1");
 
260
            }
256
261
        } else if (!strcmp(cmd,"map1acmd")) {
257
262
            if (!strcmp(param,"FALSE")) {
258
263
                draw_info("Server does not support map1acmd, will try map1cmd", NDI_RED);
303
308
                cs_print_string(csocket.fd,"requestinfo skill_info");
304
309
            }
305
310
        }
306
 
    else if (!strcmp(cmd,"extendedMapInfos")) {
307
 
        if (!strcmp(param,"FALSE")) {
308
 
            use_config[CONFIG_SMOOTH]=0;
309
 
        }else{
310
 
            /* Request all extended infos we want
311
 
             * Should regroup everything for easyness
312
 
             */
313
 
            if (use_config[CONFIG_SMOOTH]){
314
 
                cs_print_string(csocket.fd,"toggleextendedinfos smooth");
315
 
            }    
316
 
        }
317
 
    }
318
 
    else if (!strcmp(cmd,"extendedTextInfos")){
319
 
        if (strcmp(param,"FALSE")){ /* server didn't send FALSE*/
320
 
            /* Server seems to accept extended text infos. Let's tell
321
 
             * it what extended text info we want
322
 
             */
323
 
            char exttext[MAX_BUF];
324
 
            TextManager* manager = firstTextManager;
325
 
            while (manager){
326
 
                snprintf(exttext,sizeof(exttext),"toggleextendedtext %d",manager->type);
327
 
                cs_print_string(csocket.fd,exttext);
328
 
                manager=manager->next;
329
 
            }
330
 
        }
331
 
    }
 
311
        else if (!strcmp(cmd,"extendedMapInfos")) {
 
312
            if (!strcmp(param,"FALSE")) {
 
313
                use_config[CONFIG_SMOOTH]=0;
 
314
            } else {
 
315
                /* Request all extended infos we want
 
316
                 * Should regroup everything for easyness
 
317
                 */
 
318
                if (use_config[CONFIG_SMOOTH]){
 
319
                    cs_print_string(csocket.fd,"toggleextendedinfos smooth");
 
320
                }
 
321
            }
 
322
        }
 
323
        else if (!strcmp(cmd,"extendedTextInfos")){
 
324
            if (strcmp(param,"FALSE")){ /* server didn't send FALSE*/
 
325
                /* Server seems to accept extended text infos. Let's tell
 
326
                 * it what extended text info we want
 
327
                 */
 
328
                char exttext[MAX_BUF];
 
329
                TextManager* manager = firstTextManager;
 
330
 
 
331
                while (manager){
 
332
                    snprintf(exttext,sizeof(exttext),"toggleextendedtext %d",manager->type);
 
333
                    cs_print_string(csocket.fd,exttext);
 
334
                    manager=manager->next;
 
335
                }
 
336
            }
 
337
        }
332
338
        else {
333
339
                LOG (LOG_INFO,"common::SetupCmd","Got setup for a command we don't understand: %s %s",
334
340
                    cmd, param);
407
413
        "Calculated animations does not equal stored animations? (%d!=%d)",
408
414
                j, animations[anum].num_animations);
409
415
 
 
416
    animations[anum].speed=0;
 
417
    animations[anum].speed_left=0;
 
418
    animations[anum].phase=0;
 
419
 
410
420
    LOG(LOG_DEBUG,"common::AnimCmd","Received animation %d, %d faces", anum, animations[anum].num_animations);
411
421
}
412
422
 
1015
1025
 * 1 for map1a.  It conceivable that there could be future
1016
1026
 * revisions.
1017
1027
 */
1018
 
#define NUM_LAYERS (MAXLAYERS-1)
 
1028
 
 
1029
/* NUM_LAYERS should only be used for the map1{a} which only
 
1030
 * has a few layers.  Map2 has 10 layers.  However, some of the
 
1031
 * map1 logic requires this to be set right.
 
1032
 */
 
1033
#define NUM_LAYERS (MAP1_LAYERS-1)
1019
1034
static void map1_common(unsigned char *data, int len, int rev)
1020
1035
{
1021
1036
    int mask, x, y, pos = 0, layer;
1084
1099
    map1_common(data, len, 1);
1085
1100
}
1086
1101
 
 
1102
void Map2Cmd(unsigned char *data, int len)
 
1103
{
 
1104
    int mask, x, y, pos = 0, space_len, value;
 
1105
    uint8 type;
 
1106
 
 
1107
    display_map_startupdate();
 
1108
    /* Not really using map1 protocol, but some draw logic differs from
 
1109
     * the original draw logic, and map2 is closest.
 
1110
     */
 
1111
    map1cmd = 1;
 
1112
    while (pos <len) {
 
1113
        mask = GetShort_String(data+pos); pos+=2;
 
1114
        x = ((mask >>10) & 0x3f) - MAP2_COORD_OFFSET;
 
1115
        y = ((mask >>4) & 0x3f) - MAP2_COORD_OFFSET;
 
1116
 
 
1117
        /* This is a scroll then.  Go back and fetch another coordinate */
 
1118
        if (mask & 0x1) {
 
1119
            mapdata_scroll(x, y);
 
1120
            continue;
 
1121
        }
 
1122
 
 
1123
        /* Inner loop is for the data on the space itself */
 
1124
        while (pos < len) {
 
1125
 
 
1126
            type = data[pos++];
 
1127
            /* type == 255 means nothing more for this space */
 
1128
            if (type == 255) {
 
1129
                mapdata_set_check_space(x, y);
 
1130
                break;
 
1131
            }
 
1132
            space_len = type >> 5;
 
1133
            type &= 0x1f;
 
1134
            /* Clear the space */
 
1135
            if (type == 0) {
 
1136
                mapdata_clear_space(x, y);
 
1137
                continue;
 
1138
            }
 
1139
            else if (type == 1) {
 
1140
                value = data[pos++];
 
1141
                mapdata_set_darkness(x, y, value);
 
1142
                continue;
 
1143
            } else if (type >= 0x10 && type <= 0x1a) {
 
1144
                int layer, opt;
 
1145
 
 
1146
                /* This is face information for a layer. */
 
1147
                layer = type & 0xf;
 
1148
 
 
1149
                /* This is the face */
 
1150
                value = GetShort_String(data+pos); pos+=2;
 
1151
                if (!(value & FACE_IS_ANIM))
 
1152
                    mapdata_set_face_layer(x, y, value, layer);
 
1153
 
 
1154
                if (space_len > 2) {
 
1155
                    opt = data[pos++];
 
1156
                    if (value & FACE_IS_ANIM) {
 
1157
                        /* Animation speed */
 
1158
                        mapdata_set_anim_layer(x, y, value, opt, layer);
 
1159
                    } else {
 
1160
                        /* Smooth info */
 
1161
                        mapdata_set_smooth(x, y, opt, layer);
 
1162
                    }
 
1163
                }
 
1164
                /* Currently, if 4 bytes, must be a smooth byte */
 
1165
                if (space_len > 3) {
 
1166
                    opt = data[pos++];
 
1167
                    mapdata_set_smooth(x, y, opt, layer);
 
1168
                }
 
1169
                continue;
 
1170
            } /* if image layer */
 
1171
        } /* while pos<len inner loop for space */
 
1172
 
 
1173
    } /* While pos<len outer loop */
 
1174
    mapupdatesent=0;
 
1175
    display_map_doneupdate(FALSE, FALSE);
 
1176
}
 
1177
 
1087
1178
 
1088
1179
void map_scrollCmd(char *data, int len)
1089
1180
{
1113
1204
    static int dy[8]={-1,-1,0,1,1,1,0,-1};
1114
1205
    int i,rx,ry;
1115
1206
    int newsm;
 
1207
 
1116
1208
    if (len<1)
1117
1209
        return 0;
 
1210
 
1118
1211
    x+= pl_pos.x;
1119
 
        y+= pl_pos.y;
 
1212
    y+= pl_pos.y;
1120
1213
    newsm=GetChar_String(data);
1121
 
    if (the_map.cells[x][y].smooth[layer]!=newsm)
1122
 
    for (i=0;i<8;i++){
1123
 
        rx=x+dx[i];
1124
 
        ry=y+dy[i];
1125
 
        if ( (rx<0) || (ry<0) || (the_map.x<=rx) || (the_map.y<=ry))
1126
 
            continue;
1127
 
        the_map.cells[x][y].need_resmooth=1;            
 
1214
 
 
1215
    if (the_map.cells[x][y].smooth[layer]!=newsm) {
 
1216
        for (i=0;i<8;i++){
 
1217
            rx=x+dx[i];
 
1218
            ry=y+dy[i];
 
1219
            if ( (rx<0) || (ry<0) || (the_map.x<=rx) || (the_map.y<=ry))
 
1220
                continue;
 
1221
            the_map.cells[x][y].need_resmooth=1;
 
1222
        }
1128
1223
    }
1129
1224
    the_map.cells[x][y].smooth[layer]=newsm;
1130
1225
    return 1;/*Cause smooth infos only use 1 byte*/
1131
1226
}
 
1227
 
1132
1228
/* Handle MapExtended command
1133
1229
 * Warning! if you add commands to extended, take
1134
1230
 * care that the 'layer' argument of main loop is
1232
1328
 
1233
1329
void SinkCmd(unsigned char *data, int len){
1234
1330
}
 
1331
 
 
1332
/* got a tick from the server.  We currently
 
1333
 * don't care what tick number it is, but
 
1334
 * just have the code in case at some time we do.
 
1335
 */
 
1336
void TickCmd(char *data, int len)
 
1337
{
 
1338
 
 
1339
    tick = GetInt_String(data);
 
1340
 
 
1341
    /* Up to the specific client to decide what to do */
 
1342
    client_tick(tick);
 
1343
}