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 $";
4
4
Crossfire client, a client program for the crossfire program.
253
253
draw_info("Server does not support other image sets, will use default", NDI_RED);
254
254
face_info.faceset=0;
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");
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");
306
else if (!strcmp(cmd,"extendedMapInfos")) {
307
if (!strcmp(param,"FALSE")) {
308
use_config[CONFIG_SMOOTH]=0;
310
/* Request all extended infos we want
311
* Should regroup everything for easyness
313
if (use_config[CONFIG_SMOOTH]){
314
cs_print_string(csocket.fd,"toggleextendedinfos smooth");
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
323
char exttext[MAX_BUF];
324
TextManager* manager = firstTextManager;
326
snprintf(exttext,sizeof(exttext),"toggleextendedtext %d",manager->type);
327
cs_print_string(csocket.fd,exttext);
328
manager=manager->next;
311
else if (!strcmp(cmd,"extendedMapInfos")) {
312
if (!strcmp(param,"FALSE")) {
313
use_config[CONFIG_SMOOTH]=0;
315
/* Request all extended infos we want
316
* Should regroup everything for easyness
318
if (use_config[CONFIG_SMOOTH]){
319
cs_print_string(csocket.fd,"toggleextendedinfos smooth");
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
328
char exttext[MAX_BUF];
329
TextManager* manager = firstTextManager;
332
snprintf(exttext,sizeof(exttext),"toggleextendedtext %d",manager->type);
333
cs_print_string(csocket.fd,exttext);
334
manager=manager->next;
333
339
LOG (LOG_INFO,"common::SetupCmd","Got setup for a command we don't understand: %s %s",
407
413
"Calculated animations does not equal stored animations? (%d!=%d)",
408
414
j, animations[anum].num_animations);
416
animations[anum].speed=0;
417
animations[anum].speed_left=0;
418
animations[anum].phase=0;
410
420
LOG(LOG_DEBUG,"common::AnimCmd","Received animation %d, %d faces", anum, animations[anum].num_animations);
1015
1025
* 1 for map1a. It conceivable that there could be future
1018
#define NUM_LAYERS (MAXLAYERS-1)
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.
1033
#define NUM_LAYERS (MAP1_LAYERS-1)
1019
1034
static void map1_common(unsigned char *data, int len, int rev)
1021
1036
int mask, x, y, pos = 0, layer;
1084
1099
map1_common(data, len, 1);
1102
void Map2Cmd(unsigned char *data, int len)
1104
int mask, x, y, pos = 0, space_len, value;
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.
1113
mask = GetShort_String(data+pos); pos+=2;
1114
x = ((mask >>10) & 0x3f) - MAP2_COORD_OFFSET;
1115
y = ((mask >>4) & 0x3f) - MAP2_COORD_OFFSET;
1117
/* This is a scroll then. Go back and fetch another coordinate */
1119
mapdata_scroll(x, y);
1123
/* Inner loop is for the data on the space itself */
1127
/* type == 255 means nothing more for this space */
1129
mapdata_set_check_space(x, y);
1132
space_len = type >> 5;
1134
/* Clear the space */
1136
mapdata_clear_space(x, y);
1139
else if (type == 1) {
1140
value = data[pos++];
1141
mapdata_set_darkness(x, y, value);
1143
} else if (type >= 0x10 && type <= 0x1a) {
1146
/* This is face information for a layer. */
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);
1154
if (space_len > 2) {
1156
if (value & FACE_IS_ANIM) {
1157
/* Animation speed */
1158
mapdata_set_anim_layer(x, y, value, opt, layer);
1161
mapdata_set_smooth(x, y, opt, layer);
1164
/* Currently, if 4 bytes, must be a smooth byte */
1165
if (space_len > 3) {
1167
mapdata_set_smooth(x, y, opt, layer);
1170
} /* if image layer */
1171
} /* while pos<len inner loop for space */
1173
} /* While pos<len outer loop */
1175
display_map_doneupdate(FALSE, FALSE);
1088
1179
void map_scrollCmd(char *data, int len)
1113
1204
static int dy[8]={-1,-1,0,1,1,1,0,-1};
1120
1213
newsm=GetChar_String(data);
1121
if (the_map.cells[x][y].smooth[layer]!=newsm)
1125
if ( (rx<0) || (ry<0) || (the_map.x<=rx) || (the_map.y<=ry))
1127
the_map.cells[x][y].need_resmooth=1;
1215
if (the_map.cells[x][y].smooth[layer]!=newsm) {
1219
if ( (rx<0) || (ry<0) || (the_map.x<=rx) || (the_map.y<=ry))
1221
the_map.cells[x][y].need_resmooth=1;
1129
1224
the_map.cells[x][y].smooth[layer]=newsm;
1130
1225
return 1;/*Cause smooth infos only use 1 byte*/
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
1233
1329
void SinkCmd(unsigned char *data, int len){
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.
1336
void TickCmd(char *data, int len)
1339
tick = GetInt_String(data);
1341
/* Up to the specific client to decide what to do */