… | |
… | |
132 | static void |
132 | static void |
133 | clear_map (player *pl) |
133 | clear_map (player *pl) |
134 | { |
134 | { |
135 | memset (&pl->ns->lastmap, 0, sizeof (pl->ns->lastmap)); |
135 | memset (&pl->ns->lastmap, 0, sizeof (pl->ns->lastmap)); |
136 | |
136 | |
|
|
137 | pl->ns->force_newmap = false; |
|
|
138 | |
137 | if (pl->ns->newmapcmd == 1) |
139 | if (pl->ns->newmapcmd == 1) |
138 | pl->ns->send_packet ("newmap"); |
140 | pl->ns->send_packet ("newmap"); |
139 | |
141 | |
140 | pl->ns->floorbox_reset (); |
142 | pl->ns->floorbox_reset (); |
141 | } |
143 | } |
… | |
… | |
146 | { |
148 | { |
147 | client &socket = *pl->ns; |
149 | client &socket = *pl->ns; |
148 | object *ob = pl->ob; |
150 | object *ob = pl->ob; |
149 | char buf[MAX_BUF]; /* eauugggh */ |
151 | char buf[MAX_BUF]; /* eauugggh */ |
150 | |
152 | |
151 | if (socket.current_map != ob->map) |
153 | if (socket.force_newmap && 0) |
152 | { |
154 | { |
|
|
155 | // force newmap is used for clients that do not redraw their map |
|
|
156 | // after image uploads. |
153 | socket.current_map = ob->map; |
157 | socket.current_map = ob->map; |
154 | |
158 | clear_map (pl); |
|
|
159 | } |
|
|
160 | else if (socket.current_map != ob->map) |
|
|
161 | { |
155 | clear_map (pl); |
162 | clear_map (pl); |
156 | |
163 | |
157 | if (socket.mapinfocmd) |
164 | if (socket.mapinfocmd) |
158 | { |
165 | { |
159 | if (ob->map && ob->map->path[0]) |
166 | if (ob->map && ob->map->path[0]) |
… | |
… | |
459 | char tmpbuf[20]; |
466 | char tmpbuf[20]; |
460 | int q = atoi (param); |
467 | int q = atoi (param); |
461 | |
468 | |
462 | if (is_valid_faceset (q)) |
469 | if (is_valid_faceset (q)) |
463 | ns->faceset = q; |
470 | ns->faceset = q; |
|
|
471 | |
464 | sprintf (tmpbuf, "%d", ns->faceset); |
472 | sprintf (tmpbuf, "%d", ns->faceset); |
465 | safe_strcat (cmdback, tmpbuf, &slen, HUGE_BUF); |
473 | safe_strcat (cmdback, tmpbuf, &slen, HUGE_BUF); |
466 | /* if the client is using faceset, it knows about image2 command */ |
474 | /* if the client is using faceset, it knows about image2 command */ |
467 | ns->image2 = 1; |
475 | ns->image2 = 1; |
468 | } |
476 | } |
… | |
… | |
561 | * This is what takes care of it. We tell the client how things worked out. |
569 | * This is what takes care of it. We tell the client how things worked out. |
562 | * I am not sure if this file is the best place for this function. however, |
570 | * I am not sure if this file is the best place for this function. however, |
563 | * it either has to be here or init_sockets needs to be exported. |
571 | * it either has to be here or init_sockets needs to be exported. |
564 | */ |
572 | */ |
565 | void |
573 | void |
566 | AddMeCmd (char *buf, int len, client * ns) |
574 | AddMeCmd (char *buf, int len, client *ns) |
567 | { |
575 | { |
|
|
576 | // face caching is mandatory |
|
|
577 | if (!ns->facecache) |
|
|
578 | { |
|
|
579 | ns->send_drawinfo ( |
|
|
580 | "\n" |
|
|
581 | "\n" |
|
|
582 | "***\n" |
|
|
583 | "*** WARNING:\n" |
|
|
584 | "*** Your client does not support face/image caching,\n" |
|
|
585 | "*** or it has been disabled. Face caching is mandatory\n" |
|
|
586 | "*** so please enable it or use a newer client.\n" |
|
|
587 | "***\n" |
|
|
588 | "*** Look at your client preferences:\n" |
|
|
589 | "***\n" |
|
|
590 | "*** CFPlus: all known versions automatically enable the facecache.\n" |
|
|
591 | "*** cfclient: use the -cache commandline option.\n" |
|
|
592 | "*** cfclient: map will not redraw automatically (bug).\n" |
|
|
593 | "*** gcfclient: use -cache commandline option, or enable\n" |
|
|
594 | "*** gcfclient: Client=>Configure=>Map & Image=>Cache Images.\n" |
|
|
595 | "*** jcrossclient: your client is broken, use CFPlus or gcfclient.\n" |
|
|
596 | "***\n" |
|
|
597 | "***\n", |
|
|
598 | NDI_RED |
|
|
599 | ); |
|
|
600 | |
|
|
601 | if (strstr (ns->version, "jcrossclient")) |
|
|
602 | /* let them, for now*/; |
|
|
603 | else |
|
|
604 | { |
|
|
605 | ns->flush (); |
|
|
606 | //ns->destroy (); |
|
|
607 | } |
|
|
608 | //ns->facecache = true; |
|
|
609 | } |
|
|
610 | |
568 | INVOKE_CLIENT (ADDME, ns, ARG_DATA (buf, len)); |
611 | INVOKE_CLIENT (ADDME, ns, ARG_DATA (buf, len)); |
569 | } |
612 | } |
570 | |
613 | |
571 | /** Reply to ExtendedInfos command */ |
614 | /** Reply to ExtendedInfos command */ |
572 | void |
615 | void |
… | |
… | |
680 | snprintf (temp, sizeof (temp), "%d", i); |
723 | snprintf (temp, sizeof (temp), "%d", i); |
681 | strcat (cmdback, temp); |
724 | strcat (cmdback, temp); |
682 | } |
725 | } |
683 | |
726 | |
684 | ns->send_packet (cmdback); |
727 | ns->send_packet (cmdback); |
|
|
728 | } |
|
|
729 | |
|
|
730 | /** |
|
|
731 | * client requested an image. send it rate-limited |
|
|
732 | * before flushing. |
|
|
733 | */ |
|
|
734 | void |
|
|
735 | AskFaceCmd (char *buf, int len, client *ns) |
|
|
736 | { |
|
|
737 | ns->askface.push_back (atoi (buf)); |
685 | } |
738 | } |
686 | |
739 | |
687 | /** |
740 | /** |
688 | * Tells client the picture it has to use |
741 | * Tells client the picture it has to use |
689 | * to smooth a picture number given as argument. |
742 | * to smooth a picture number given as argument. |
… | |
… | |
1250 | << uint8 (extendedinfos) |
1303 | << uint8 (extendedinfos) |
1251 | << uint8 (eentrysize); |
1304 | << uint8 (eentrysize); |
1252 | |
1305 | |
1253 | estartlen = esl.length (); |
1306 | estartlen = esl.length (); |
1254 | } |
1307 | } |
1255 | else |
|
|
1256 | { |
|
|
1257 | /* suppress compiler warnings */ |
|
|
1258 | ewhatstart = 0; |
|
|
1259 | ewhatflag = 0; |
|
|
1260 | estartlen = 0; |
|
|
1261 | } |
|
|
1262 | |
1308 | |
1263 | /* x,y are the real map locations. ax, ay are viewport relative |
1309 | /* x,y are the real map locations. ax, ay are viewport relative |
1264 | * locations. |
1310 | * locations. |
1265 | */ |
1311 | */ |
1266 | ay = 0; |
1312 | ay = 0; |
… | |
… | |
1269 | * but that started to get a bit messy to look at. |
1315 | * but that started to get a bit messy to look at. |
1270 | */ |
1316 | */ |
1271 | max_x = pl->x + (socket.mapx + 1) / 2; |
1317 | max_x = pl->x + (socket.mapx + 1) / 2; |
1272 | max_y = pl->y + (socket.mapy + 1) / 2; |
1318 | max_y = pl->y + (socket.mapy + 1) / 2; |
1273 | |
1319 | |
|
|
1320 | maptile *plmap = pl->map; |
|
|
1321 | |
1274 | for (y = pl->y - socket.mapy / 2; y < max_y; y++, ay++) |
1322 | for (y = pl->y - socket.mapy / 2; y < max_y; y++, ay++) |
1275 | { |
1323 | { |
1276 | ax = 0; |
1324 | ax = 0; |
1277 | for (x = pl->x - socket.mapx / 2; x < max_x; x++, ax++) |
1325 | for (x = pl->x - socket.mapx / 2; x < max_x; x++, ax++) |
1278 | { |
1326 | { |
… | |
… | |
1284 | /* If the coordinates are not valid, or it is too dark to see, |
1332 | /* If the coordinates are not valid, or it is too dark to see, |
1285 | * we tell the client as such |
1333 | * we tell the client as such |
1286 | */ |
1334 | */ |
1287 | nx = x; |
1335 | nx = x; |
1288 | ny = y; |
1336 | ny = y; |
1289 | m = get_map_from_coord (pl->map, &nx, &ny); |
1337 | m = get_map_from_coord (plmap, &nx, &ny); |
1290 | |
1338 | |
1291 | if (!m) |
1339 | if (!m) |
1292 | { |
1340 | { |
1293 | /* space is out of map. Update space and clear values |
1341 | /* space is out of map. Update space and clear values |
1294 | * if this hasn't already been done. If the space is out |
1342 | * if this hasn't already been done. If the space is out |