ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/player.C
(Generate patch)

Comparing deliantra/server/server/player.C (file contents):
Revision 1.37 by root, Thu Dec 14 02:37:37 2006 UTC vs.
Revision 1.45 by root, Sat Dec 16 17:16:52 2006 UTC

21 The author can be reached via e-mail to <crossfire@schmorp.de> 21 The author can be reached via e-mail to <crossfire@schmorp.de>
22*/ 22*/
23 23
24#include <global.h> 24#include <global.h>
25#include <pwd.h> 25#include <pwd.h>
26#ifndef __CEXTRACT__
27# include <sproto.h> 26#include <sproto.h>
28#endif
29#include <sounds.h> 27#include <sounds.h>
30#include <living.h> 28#include <living.h>
31#include <object.h> 29#include <object.h>
32#include <spells.h> 30#include <spells.h>
33#include <skills.h> 31#include <skills.h>
34#include <newclient.h>
35 32
36#ifdef COZY_SERVER 33#ifdef COZY_SERVER
37extern int same_party (partylist *a, partylist *b); 34extern int same_party (partylist *a, partylist *b);
38#endif 35#endif
39 36
85 int comp; 82 int comp;
86 int size; 83 int size;
87 84
88 sprintf (buf, "%s/%s", settings.confdir, settings.motd); 85 sprintf (buf, "%s/%s", settings.confdir, settings.motd);
89 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) 86 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL)
90 {
91 return; 87 return;
92 } 88
93 motd[0] = '\0'; 89 motd[0] = '\0';
94 size = 0; 90 size = 0;
91
95 while (fgets (buf, MAX_BUF, fp) != NULL) 92 while (fgets (buf, MAX_BUF, fp) != NULL)
96 { 93 {
97 if (*buf == '#') 94 if (*buf == '#')
98 continue; 95 continue;
96
99 strncat (motd + size, buf, HUGE_BUF - size); 97 strncat (motd + size, buf, HUGE_BUF - size);
100 size += strlen (buf); 98 size += strlen (buf);
101 } 99 }
100
102 draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_MOTD, MSG_SUBTYPE_NONE, motd, NULL); 101 draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_MOTD, MSG_SUBTYPE_NONE, motd, NULL);
103 close_and_delete (fp, comp); 102 close_and_delete (fp, comp);
104} 103}
105 104
106void 105void
112 int comp; 111 int comp;
113 int size; 112 int size;
114 113
115 sprintf (buf, "%s/%s", settings.confdir, settings.rules); 114 sprintf (buf, "%s/%s", settings.confdir, settings.rules);
116 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) 115 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL)
117 {
118 return; 116 return;
119 } 117
120 rules[0] = '\0'; 118 rules[0] = '\0';
121 size = 0; 119 size = 0;
120
122 while (fgets (buf, MAX_BUF, fp) != NULL) 121 while (fgets (buf, MAX_BUF, fp) != NULL)
123 { 122 {
124 if (*buf == '#') 123 if (*buf == '#')
125 continue; 124 continue;
125
126 if (size + strlen (buf) >= HUGE_BUF) 126 if (size + strlen (buf) >= HUGE_BUF)
127 { 127 {
128 LOG (llevDebug, "Warning, rules size is > %d bytes.\n", HUGE_BUF); 128 LOG (llevDebug, "Warning, rules size is > %d bytes.\n", HUGE_BUF);
129 break; 129 break;
130 } 130 }
131
131 strncat (rules + size, buf, HUGE_BUF - size); 132 strncat (rules + size, buf, HUGE_BUF - size);
132 size += strlen (buf); 133 size += strlen (buf);
133 } 134 }
135
134 draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_RULES, rules, NULL); 136 draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_RULES, rules, NULL);
135 close_and_delete (fp, comp); 137 close_and_delete (fp, comp);
136} 138}
137 139
138void 140void
146 int size; 148 int size;
147 149
148 sprintf (buf, "%s/%s", settings.confdir, settings.news); 150 sprintf (buf, "%s/%s", settings.confdir, settings.news);
149 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) 151 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL)
150 return; 152 return;
153
151 news[0] = '\0'; 154 news[0] = '\0';
152 subject[0] = '\0'; 155 subject[0] = '\0';
153 size = 0; 156 size = 0;
157
154 while (fgets (buf, MAX_BUF, fp) != NULL) 158 while (fgets (buf, MAX_BUF, fp) != NULL)
155 { 159 {
156 if (*buf == '#') 160 if (*buf == '#')
157 continue; 161 continue;
162
158 if (*buf == '%') 163 if (*buf == '%')
159 { /* send one news */ 164 { /* send one news */
160 if (size > 0) 165 if (size > 0)
161 draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s", "%s\n%s", subject, news); /*send previously read news */ 166 draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s", "%s\n%s", subject, news); /*send previously read news */
162 strcpy (subject, buf + 1); 167 strcpy (subject, buf + 1);
189 return 0; 194 return 0;
190 195
191 for (; *cp != '\0'; cp++) 196 for (; *cp != '\0'; cp++)
192 if (!((*cp >= 'a' && *cp <= 'z') || (*cp >= 'A' && *cp <= 'Z')) && *cp != '-' && *cp != '_') 197 if (!((*cp >= 'a' && *cp <= 'z') || (*cp >= 'A' && *cp <= 'Z')) && *cp != '-' && *cp != '_')
193 return 0; 198 return 0;
199
194 return 1; 200 return 1;
195} 201}
196 202
197/* This no longer sets the player map. Also, it now updates 203/* This no longer sets the player map. Also, it now updates
198 * all the pointers so the caller doesn't need to do that. 204 * all the pointers so the caller doesn't need to do that.
206 * the one that is passed. 212 * the one that is passed.
207 */ 213 */
208static player * 214static player *
209get_player (player *p) 215get_player (player *p)
210{ 216{
211 object *op = arch_to_object (get_player_archetype (NULL)); 217 object *op = arch_to_object (get_player_archetype (0));
212 int i; 218 int i;
213
214 if (!p)
215 {
216 p = new player;
217
218 /* This adds the player in the linked list. There is extra
219 * complexity here because we want to add the new player at the
220 * end of the list - there is in fact no compelling reason that
221 * that needs to be done except for things like output of
222 * 'who'.
223 */
224 player *tmp = first_player;
225
226 while (tmp != NULL && tmp->next != NULL)
227 tmp = tmp->next;
228 if (tmp != NULL)
229 tmp->next = p;
230 else
231 first_player = p;
232
233 p->next = NULL;
234 }
235 219
236 /* Clears basically the entire player structure except 220 /* Clears basically the entire player structure except
237 * for next and socket. 221 * for next and socket.
238 */ 222 */
239 p->clear (); 223 p->clear ();
258 op->speed_left = 0.5; 242 op->speed_left = 0.5;
259 op->speed = 1.0; 243 op->speed = 1.0;
260 op->direction = 5; /* So player faces south */ 244 op->direction = 5; /* So player faces south */
261 op->stats.wc = 2; 245 op->stats.wc = 2;
262 op->run_away = 25; /* Then we panick... */ 246 op->run_away = 25; /* Then we panick... */
247
248 {
249 int oldmon = p->socket->monitor_spells; // what a hack
263 p->socket.monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */ 250 p->socket->monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */
264
265 roll_stats (op); 251 roll_stats (op);
252 p->socket->monitor_spells = oldmon;
253 }
266 p->state = ST_ROLL_STAT; 254 p->state = ST_ROLL_STAT;
267 clear_los (op); 255 clear_los (op);
268 256
269 p->gen_sp_armour = 10; 257 p->gen_sp_armour = 10;
270 p->last_speed = -1; 258 p->last_speed = -1;
275 p->usekeys = containers; 263 p->usekeys = containers;
276 p->last_weapon_sp = -1; 264 p->last_weapon_sp = -1;
277 p->peaceful = 1; /* default peaceful */ 265 p->peaceful = 1; /* default peaceful */
278 p->do_los = 1; 266 p->do_los = 1;
279 p->explore = 0; 267 p->explore = 0;
280 p->no_shout = 0; /* default can shout */
281 268
282 assign (p->title, op->arch->clone.name); 269 assign (p->title, op->arch->clone.name);
283 op->race = op->arch->clone.race; 270 op->race = op->arch->clone.race;
284 271
285 CLEAR_FLAG (op, FLAG_READY_SKILL); 272 CLEAR_FLAG (op, FLAG_READY_SKILL);
292 for (i = 0; i < NUM_SKILLS; i++) 279 for (i = 0; i < NUM_SKILLS; i++)
293 { 280 {
294 p->last_skill_exp[i] = -1; 281 p->last_skill_exp[i] = -1;
295 p->last_skill_ob[i] = NULL; 282 p->last_skill_ob[i] = NULL;
296 } 283 }
284
297 for (i = 0; i < NROFATTACKS; i++) 285 for (i = 0; i < NROFATTACKS; i++)
298 {
299 p->last_resist[i] = -1; 286 p->last_resist[i] = -1;
300 } 287
301 p->last_stats.exp = -1; 288 p->last_stats.exp = -1;
302 p->last_weight = (uint32) - 1; 289 p->last_weight = (uint32) - 1;
303 290
304 p->socket.update_look = 0; 291 p->socket->update_look = 0;
305 p->socket.look_position = 0; 292 p->socket->look_position = 0;
293
306 return p; 294 return p;
307} 295}
308 296
309/* This loads the first map an puts the player on it. */ 297/* This loads the first map an puts the player on it. */
310static void 298static void
320 * All we can really get in this is some settings like host and display 308 * All we can really get in this is some settings like host and display
321 * mode. 309 * mode.
322 */ 310 */
323 311
324int 312int
325add_player (client_socket * ns) 313add_player (client *ns)
326{ 314{
327 player *p; 315 player *p = new player;
328 316
329 p = get_player (NULL);
330 p->socket = *ns; 317 p->socket = ns;
331 p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); 318 ns->pl = p;
332 319
333 if (p->socket.faces_sent == NULL) 320 p->next = first_player;
334 fatal (OUT_OF_MEMORY); 321 first_player = p;
335 322
336 memcpy (p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); 323 p = get_player (p);
337 /* Needed because the socket we just copied over needs to be cleared. 324
338 * Note that this can result in a client reset if there is partial data
339 * on the uncoming socket.
340 */
341 //TODO socket copying is EVIL, do not do this
342 p->socket.inbuf_len = 0;
343 set_first_map (p->ob); 325 set_first_map (p->ob);
344 326
345 CLEAR_FLAG (p->ob, FLAG_FRIENDLY); 327 CLEAR_FLAG (p->ob, FLAG_FRIENDLY);
346 add_friendly_object (p->ob); 328 add_friendly_object (p->ob);
347 send_rules (p->ob); 329 send_rules (p->ob);
715void 697void
716get_name (object *op) 698get_name (object *op)
717{ 699{
718 op->contr->write_buf[0] = '\0'; 700 op->contr->write_buf[0] = '\0';
719 op->contr->state = ST_GET_NAME; 701 op->contr->state = ST_GET_NAME;
720 send_query (&op->contr->socket, 0, "What is your name?\n:"); 702 send_query (op->contr->socket, 0, "What is your name?\n:");
721} 703}
722 704
723void 705void
724get_password (object *op) 706get_password (object *op)
725{ 707{
726 op->contr->write_buf[0] = '\0'; 708 op->contr->write_buf[0] = '\0';
727 op->contr->state = ST_GET_PASSWORD; 709 op->contr->state = ST_GET_PASSWORD;
728 send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:"); 710 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:");
729} 711}
730 712
731void 713void
732play_again (object *op) 714play_again (object *op)
733{ 715{
734 op->contr->state = ST_PLAY_AGAIN; 716 op->contr->state = ST_PLAY_AGAIN;
735 op->chosen_skill = NULL; 717 op->chosen_skill = NULL;
736 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?"); 718 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?");
737 /* a bit of a hack, but there are various places early in th 719 /* a bit of a hack, but there are various places early in th
738 * player creation process that a user can quit (eg, roll 720 * player creation process that a user can quit (eg, roll
739 * stats) that isn't removing the player. Taking a quick 721 * stats) that isn't removing the player. Taking a quick
740 * look, there are many places that call play_again without 722 * look, there are many places that call play_again without
741 * removing the player - it probably makes more sense 723 * removing the player - it probably makes more sense
790confirm_password (object *op) 772confirm_password (object *op)
791{ 773{
792 774
793 op->contr->write_buf[0] = '\0'; 775 op->contr->write_buf[0] = '\0';
794 op->contr->state = ST_CONFIRM_PASSWORD; 776 op->contr->state = ST_CONFIRM_PASSWORD;
795 send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:"); 777 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:");
796} 778}
797 779
798void 780void
799get_party_password (object *op, partylist *party) 781get_party_password (object *op, partylist *party)
800{ 782{
804 return; 786 return;
805 } 787 }
806 op->contr->write_buf[0] = '\0'; 788 op->contr->write_buf[0] = '\0';
807 op->contr->state = ST_GET_PARTY_PASSWORD; 789 op->contr->state = ST_GET_PARTY_PASSWORD;
808 op->contr->party_to_join = party; 790 op->contr->party_to_join = party;
809 send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:"); 791 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:");
810} 792}
811 793
812 794
813/* This rolls four 1-6 rolls and sums the best 3 of the 4. */ 795/* This rolls four 1-6 rolls and sums the best 3 of the 4. */
814int 796int
911 893
912void 894void
913Roll_Again (object *op) 895Roll_Again (object *op)
914{ 896{
915 esrv_new_player (op->contr, 0); 897 esrv_new_player (op->contr, 0);
916 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, 898 send_query (op->contr->socket, CS_QUERY_SINGLECHAR,
917 "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? "); 899 "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? ");
918} 900}
919 901
920void 902void
921Swap_Stat (object *op, int Swap_Second) 903Swap_Stat (object *op, int Swap_Second)
988 new_draw_info (NDI_UNIQUE, 0, op, buf); 970 new_draw_info (NDI_UNIQUE, 0, op, buf);
989 } 971 }
990 else 972 else
991 Swap_Stat (op, stat_trans[keynum]); 973 Swap_Stat (op, stat_trans[keynum]);
992 974
993 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); 975 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "");
994 return 1; 976 return 1;
995 } 977 }
996 switch (key) 978 switch (key)
997 { 979 {
998 case 'n': 980 case 'n':
1012 enter_exit (op, NULL); 994 enter_exit (op, NULL);
1013#endif 995#endif
1014 SET_ANIMATION (op, 2); /* So player faces south */ 996 SET_ANIMATION (op, 2); /* So player faces south */
1015 /* Enter exit adds a player otherwise */ 997 /* Enter exit adds a player otherwise */
1016 add_statbonus (op); 998 add_statbonus (op);
1017 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, 999 send_query (op->contr->socket, CS_QUERY_SINGLECHAR,
1018 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"); 1000 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n");
1019 op->contr->state = ST_CHANGE_CLASS; 1001 op->contr->state = ST_CHANGE_CLASS;
1020 if (op->msg) 1002 if (op->msg)
1021 new_draw_info (NDI_BLUE, 0, op, op->msg); 1003 new_draw_info (NDI_BLUE, 0, op, op->msg);
1022 return 0; 1004 return 0;
1023 } 1005 }
1024 case 'y': 1006 case 'y':
1025 case 'Y': 1007 case 'Y':
1026 roll_stats (op); 1008 roll_stats (op);
1027 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); 1009 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "");
1028 return 1; 1010 return 1;
1029 1011
1030 case 'q': 1012 case 'q':
1031 case 'Q': 1013 case 'Q':
1032 play_again (op); 1014 play_again (op);
1033 return 1; 1015 return 1;
1034 1016
1035 default: 1017 default:
1036 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); 1018 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?");
1037 return 0; 1019 return 0;
1038 } 1020 }
1039 return 0; 1021 return 0;
1040} 1022}
1041 1023
1151 op->stats.grace = 0; 1133 op->stats.grace = 0;
1152 1134
1153 if (op->msg) 1135 if (op->msg)
1154 new_draw_info (NDI_BLUE, 0, op, op->msg); 1136 new_draw_info (NDI_BLUE, 0, op, op->msg);
1155 1137
1156 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n"); 1138 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n");
1157 return 0; 1139 return 0;
1158} 1140}
1159 1141
1160int 1142int
1161key_confirm_quit (object *op, char key) 1143key_confirm_quit (object *op, char key)
1904 SET_ANIMATION (arrow, arrow->direction); 1886 SET_ANIMATION (arrow, arrow->direction);
1905 arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */ 1887 arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */
1906 arrow->stats.hp = arrow->stats.dam; 1888 arrow->stats.hp = arrow->stats.dam;
1907 arrow->stats.grace = arrow->attacktype; 1889 arrow->stats.grace = arrow->attacktype;
1908 if (arrow->slaying != NULL) 1890 if (arrow->slaying != NULL)
1909 arrow->spellarg = strdup_local (arrow->slaying); 1891 arrow->spellarg = strdup (arrow->slaying);
1910 1892
1911 /* Note that this was different for monsters - they got their level 1893 /* Note that this was different for monsters - they got their level
1912 * added to the damage. I think the strength bonus is more proper. 1894 * added to the damage. I think the strength bonus is more proper.
1913 */ 1895 */
1914 1896
2570 2552
2571 /* call this here - we also will call this in do_ericserver, but 2553 /* call this here - we also will call this in do_ericserver, but
2572 * the players time has been increased when doericserver has been 2554 * the players time has been increased when doericserver has been
2573 * called, so we recheck it here. 2555 * called, so we recheck it here.
2574 */ 2556 */
2575 HandleClient (&op->contr->socket, op->contr); 2557 op->contr->socket->handle_command ();
2576 if (op->speed_left < 0) 2558 if (op->speed_left < 0)
2577 return 0; 2559 return 0;
2578 2560
2579 if (op->direction && (op->contr->run_on || op->contr->fire_on)) 2561 if (op->direction && (op->contr->run_on || op->contr->fire_on))
2580 { 2562 {
2589 if (op->speed_left > 0) 2571 if (op->speed_left > 0)
2590 return 1; 2572 return 1;
2591 else 2573 else
2592 return 0; 2574 return 0;
2593 } 2575 }
2576
2594 return 0; 2577 return 0;
2595} 2578}
2596 2579
2597int 2580int
2598save_life (object *op) 2581save_life (object *op)
2599{ 2582{
2600 object *tmp;
2601
2602 if (!QUERY_FLAG (op, FLAG_LIFESAVE)) 2583 if (!QUERY_FLAG (op, FLAG_LIFESAVE))
2603 return 0; 2584 return 0;
2604 2585
2605 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 2586 for (object *tmp = op->inv; tmp; tmp = tmp->below)
2606 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) 2587 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE))
2607 { 2588 {
2608 play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE); 2589 play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE);
2609 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); 2590 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp));
2610 2591
2621 op->stats.food = 999; 2602 op->stats.food = 999;
2622 2603
2623 fix_player (op); 2604 fix_player (op);
2624 return 1; 2605 return 1;
2625 } 2606 }
2607
2626 LOG (llevError, "Error: LIFESAVE set without applied object.\n"); 2608 LOG (llevError, "Error: LIFESAVE set without applied object.\n");
2627 CLEAR_FLAG (op, FLAG_LIFESAVE); 2609 CLEAR_FLAG (op, FLAG_LIFESAVE);
2628 enter_player_savebed (op); /* bring him home. */ 2610 enter_player_savebed (op); /* bring him home. */
2629 return 0; 2611 return 0;
2630} 2612}
2653 esrv_del_item (env->contr, op->count); 2635 esrv_del_item (env->contr, op->count);
2654 insert_ob_in_map (op, env->map, NULL, 0); 2636 insert_ob_in_map (op, env->map, NULL, 0);
2655 } 2637 }
2656 else if (op->inv) 2638 else if (op->inv)
2657 remove_unpaid_objects (op->inv, env); 2639 remove_unpaid_objects (op->inv, env);
2640
2658 op = next; 2641 op = next;
2659 } 2642 }
2660} 2643}
2661 2644
2662 2645
2677 strcpy (buf2, " R.I.P.\n\n"); 2660 strcpy (buf2, " R.I.P.\n\n");
2678 if (op->type == PLAYER) 2661 if (op->type == PLAYER)
2679 sprintf (buf, "%s the %s\n", &op->name, op->contr->title); 2662 sprintf (buf, "%s the %s\n", &op->name, op->contr->title);
2680 else 2663 else
2681 sprintf (buf, "%s\n", &op->name); 2664 sprintf (buf, "%s\n", &op->name);
2665
2682 strncat (buf2, " ", 20 - strlen (buf) / 2); 2666 strncat (buf2, " ", 20 - strlen (buf) / 2);
2683 strcat (buf2, buf); 2667 strcat (buf2, buf);
2684 if (op->type == PLAYER) 2668 if (op->type == PLAYER)
2685 sprintf (buf, "who was in level %d when killed\n", op->level); 2669 sprintf (buf, "who was in level %d when killed\n", op->level);
2686 else 2670 else
2687 sprintf (buf, "who was in level %d when died.\n\n", op->level); 2671 sprintf (buf, "who was in level %d when died.\n\n", op->level);
2672
2688 strncat (buf2, " ", 20 - strlen (buf) / 2); 2673 strncat (buf2, " ", 20 - strlen (buf) / 2);
2689 strcat (buf2, buf); 2674 strcat (buf2, buf);
2690 if (op->type == PLAYER) 2675 if (op->type == PLAYER)
2691 { 2676 {
2692 sprintf (buf, "by %s.\n\n", op->contr->killer); 2677 sprintf (buf, "by %s.\n\n", op->contr->killer);
2693 strncat (buf2, " ", 21 - strlen (buf) / 2); 2678 strncat (buf2, " ", 21 - strlen (buf) / 2);
2694 strcat (buf2, buf); 2679 strcat (buf2, buf);
2695 } 2680 }
2681
2696 strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); 2682 strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now));
2697 strncat (buf2, " ", 20 - strlen (buf) / 2); 2683 strncat (buf2, " ", 20 - strlen (buf) / 2);
2698 strcat (buf2, buf); 2684 strcat (buf2, buf);
2685
2699 return buf2; 2686 return buf2;
2700} 2687}
2701 2688
2702 2689
2703 2690
3650 3637
3651 /* only the viewable area the player sees is updated by LOS 3638 /* only the viewable area the player sees is updated by LOS
3652 * code, so we need to restrict ourselves to that range of values 3639 * code, so we need to restrict ourselves to that range of values
3653 * for any meaningful values. 3640 * for any meaningful values.
3654 */ 3641 */
3655 if (FABS (dx) <= (pl->contr->socket.mapx / 2) && 3642 if (FABS (dx) <= (pl->contr->socket->mapx / 2) &&
3656 FABS (dy) <= (pl->contr->socket.mapy / 2) && 3643 FABS (dy) <= (pl->contr->socket->mapy / 2) &&
3657 !pl->contr->blocked_los[dx + (pl->contr->socket.mapx / 2)][dy + (pl->contr->socket.mapy / 2)]) 3644 !pl->contr->blocked_los[dx + (pl->contr->socket->mapx / 2)][dy + (pl->contr->socket->mapy / 2)])
3658 return 1; 3645 return 1;
3659 op = op->more; 3646 op = op->more;
3660 } 3647 }
3661 return 0; 3648 return 0;
3662} 3649}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines