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.12 by elmex, Tue Aug 29 10:51:43 2006 UTC vs.
Revision 1.15 by root, Mon Sep 4 11:08:00 2006 UTC

1/* 1/*
2 * static char *rcsid_player_c = 2 * static char *rcsid_player_c =
3 * "$Id: player.C,v 1.12 2006/08/29 10:51:43 elmex Exp $"; 3 * "$Id: player.C,v 1.15 2006/09/04 11:08:00 root Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
197 * Hopefully this will be less bugfree and simpler. 197 * Hopefully this will be less bugfree and simpler.
198 * Returns the player structure. If 'p' is null, 198 * Returns the player structure. If 'p' is null,
199 * we create a new one. Otherwise, we recycle 199 * we create a new one. Otherwise, we recycle
200 * the one that is passed. 200 * the one that is passed.
201 */ 201 */
202static player* get_player(player *p) { 202static player *
203get_player (player * p)
204{
203 object *op=arch_to_object(get_player_archetype(NULL)); 205 object *op = arch_to_object (get_player_archetype (NULL));
204 int i; 206 int i;
205 207
206 if (!p) { 208 if (!p)
207 p = (player *) malloc(sizeof(player)); 209 {
208 if(p==NULL) 210 p = new player;
209 fatal(OUT_OF_MEMORY);
210 211
211 /* This adds the player in the linked list. There is extra 212 /* This adds the player in the linked list. There is extra
212 * complexity here because we want to add the new player at the 213 * complexity here because we want to add the new player at the
213 * end of the list - there is in fact no compelling reason that 214 * end of the list - there is in fact no compelling reason that
214 * that needs to be done except for things like output of 215 * that needs to be done except for things like output of
215 * 'who'. 216 * 'who'.
216 */ 217 */
217 player *tmp = first_player; 218 player *tmp = first_player;
218 while(tmp!=NULL&&tmp->next!=NULL) 219 while (tmp != NULL && tmp->next != NULL)
219 tmp=tmp->next; 220 tmp = tmp->next;
220 if(tmp!=NULL) 221 if (tmp != NULL)
221 tmp->next=p; 222 tmp->next = p;
222 else 223 else
223 first_player=p; 224 first_player = p;
224 225
225 p->next = NULL; 226 p->next = NULL;
226 } 227 }
227 228
228 /* Clears basically the entire player structure except 229 /* Clears basically the entire player structure except
229 * for next and socket. 230 * for next and socket.
230 */ 231 */
231 memset (static_cast<player_memset *>(p), 0, sizeof (player_memset)); 232 memset (static_cast<player_pod *>(p), 0, sizeof (player_pod));
232 p->attachable_init (); //HACK 233 p->attachable_clear ();
233 234
234 /* There are some elements we want initialized to non zero value - 235 /* There are some elements we want initialized to non zero value -
235 * we deal with that below this point. 236 * we deal with that below this point.
236 */ 237 */
237 p->party=NULL; 238 p->party = NULL;
238 p->outputs_sync=16; /* Every 2 seconds */ 239 p->outputs_sync = 16; /* Every 2 seconds */
239 p->outputs_count=1; /* Keeps present behaviour */ 240 p->outputs_count = 8; /* Keeps present behaviour */
240 p->unapply = unapply_nochoice; 241 p->unapply = unapply_nochoice;
241 p->Swap_First = -1; 242 p->Swap_First = -1;
242 243
243#ifdef AUTOSAVE 244#ifdef AUTOSAVE
244 p->last_save_tick = 9999999; 245 p->last_save_tick = 9999999;
245#endif 246#endif
246 247
247 strcpy(p->savebed_map, first_map_path); /* Init. respawn position */ 248 strcpy (p->savebed_map, first_map_path); /* Init. respawn position */
248 249
249 op->contr=p; /* this aren't yet in archetype */ 250 op->contr = p; /* this aren't yet in archetype */
250 p->ob = op; 251 p->ob = op;
251 op->speed_left=0.5; 252 op->speed_left = 0.5;
252 op->speed=1.0; 253 op->speed = 1.0;
253 op->direction=5; /* So player faces south */ 254 op->direction = 5; /* So player faces south */
254 op->stats.wc=2; 255 op->stats.wc = 2;
255 op->run_away = 25; /* Then we panick... */ 256 op->run_away = 25; /* Then we panick... */
256 p->socket.monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */ 257 p->socket.monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */
257 258
258 roll_stats(op); 259 roll_stats (op);
259 p->state=ST_ROLL_STAT; 260 p->state = ST_ROLL_STAT;
260 clear_los(op); 261 clear_los (op);
261 262
262 p->gen_sp_armour=10; 263 p->gen_sp_armour = 10;
263 p->last_speed= -1; 264 p->last_speed = -1;
264 p->shoottype=range_none; 265 p->shoottype = range_none;
265 p->bowtype=bow_normal; 266 p->bowtype = bow_normal;
266 p->petmode=pet_normal; 267 p->petmode = pet_normal;
267 p->listening=10; 268 p->listening = 10;
268 p->usekeys=containers; 269 p->usekeys = containers;
269 p->last_weapon_sp= -1; 270 p->last_weapon_sp = -1;
270 p->peaceful=1; /* default peaceful */ 271 p->peaceful = 1; /* default peaceful */
271 p->do_los=1; 272 p->do_los = 1;
272 p->explore=0; 273 p->explore = 0;
273 p->no_shout=0; /* default can shout */ 274 p->no_shout = 0; /* default can shout */
274 275
275 strncpy(p->title, op->arch->clone.name, sizeof(p->title)-1); 276 strncpy (p->title, op->arch->clone.name, sizeof (p->title) - 1);
276 p->title[sizeof(p->title)-1] = '\0'; 277 p->title[sizeof (p->title) - 1] = '\0';
277 op->race = add_string (op->arch->clone.race); 278 op->race = op->arch->clone.race;
278 279
279 CLEAR_FLAG(op,FLAG_READY_SKILL); 280 CLEAR_FLAG (op, FLAG_READY_SKILL);
280 281
281 /* we need to clear these to -1 and not zero - otherwise, 282 /* we need to clear these to -1 and not zero - otherwise,
282 * if a player quits and starts a new character, we wont 283 * if a player quits and starts a new character, we wont
283 * send new values to the client, as things like exp start 284 * send new values to the client, as things like exp start
284 * at zero. 285 * at zero.
285 */ 286 */
286 for (i=0; i < NUM_SKILLS; i++) { 287 for (i = 0; i < NUM_SKILLS; i++)
288 {
287 p->last_skill_exp[i] = -1; 289 p->last_skill_exp[i] = -1;
288 p->last_skill_ob[i] = NULL; 290 p->last_skill_ob[i] = NULL;
289 } 291 }
290 for (i=0; i < NROFATTACKS; i++) { 292 for (i = 0; i < NROFATTACKS; i++)
293 {
291 p->last_resist[i] = -1; 294 p->last_resist[i] = -1;
292 } 295 }
293 p->last_stats.exp = -1; 296 p->last_stats.exp = -1;
294 p->last_weight = (uint32)-1; 297 p->last_weight = (uint32) - 1;
295 298
296 p->socket.update_look=0; 299 p->socket.update_look = 0;
297 p->socket.look_position=0; 300 p->socket.look_position = 0;
298 return p; 301 return p;
299} 302}
300
301 303
302/* This loads the first map an puts the player on it. */ 304/* This loads the first map an puts the player on it. */
303static void set_first_map(object *op) 305static void set_first_map(object *op)
304{ 306{
305 strcpy(op->contr->maplevel, first_map_path); 307 strcpy(op->contr->maplevel, first_map_path);
409 lastdist=rv.distance; 411 lastdist=rv.distance;
410 } 412 }
411 } 413 }
412 } 414 }
413#if 0 415#if 0
414 LOG(llevDebug,"get_nearest_player() finds player: %s\n",op?op->name:"(null)"); 416 LOG(llevDebug,"get_nearest_player() finds player: %s\n",op?&op->name:"(null)");
415#endif 417#endif
416 return op; 418 return op;
417} 419}
418 420
419/* I believe this can safely go to 2, 3 is questionable, 4 will likely 421/* I believe this can safely go to 2, 3 is questionable, 4 will likely
615 617
616 if (tmp) { 618 if (tmp) {
617 remove_ob(op); 619 remove_ob(op);
618 free_object(op); 620 free_object(op);
619 LOG(llevError,"give_initial_items: Removing duplicate object %s\n", 621 LOG(llevError,"give_initial_items: Removing duplicate object %s\n",
620 tmp->name); 622 &tmp->name);
621 continue; 623 continue;
622 } 624 }
623 if (op->nrof > 1) op->nrof = 1; 625 if (op->nrof > 1) op->nrof = 1;
624 } 626 }
625 627
696 leave(op->contr,0); /* ericserver will draw the message */ 698 leave(op->contr,0); /* ericserver will draw the message */
697 return 2; 699 return 2;
698 } 700 }
699 else if(key=='a'||key=='A') { 701 else if(key=='a'||key=='A') {
700 player *pl = op->contr; 702 player *pl = op->contr;
701 const char *name = op->name; 703 shstr name = op->name;
702 704
703 add_refcount(name);
704 remove_friendly_object(op); 705 remove_friendly_object(op);
705 free_object(op); 706 free_object(op);
706 pl = get_player(pl); 707 pl = get_player(pl);
707 op = pl->ob; 708 op = pl->ob;
708 add_friendly_object(op); 709 add_friendly_object(op);
709 op->contr->password[0]='~'; 710 op->contr->password[0]='~';
710 FREE_AND_CLEAR_STR(op->name); 711 op->name = op->name_pl = 0;
711 FREE_AND_CLEAR_STR(op->name_pl);
712
713 /* Lets put a space in here */ 712 /* Lets put a space in here */
714 new_draw_info(NDI_UNIQUE, 0, op, "\n"); 713 new_draw_info(NDI_UNIQUE, 0, op, "\n");
715 get_name(op); 714 get_name(op);
716 op->name = name; /* Alrady added a refcount above */ 715 op->name = op->name_pl = name;
717 op->name_pl = add_string(name);
718 set_first_map(op); 716 set_first_map(op);
719 } else { 717 } else {
720 /* user pressed something else so just ask again... */ 718 /* user pressed something else so just ask again... */
721 play_again(op); 719 play_again(op);
722 } 720 }
730 send_query(&op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:"); 728 send_query(&op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:");
731} 729}
732 730
733void get_party_password(object *op, partylist *party) { 731void get_party_password(object *op, partylist *party) {
734 if (party == NULL) { 732 if (party == NULL) {
735 LOG(llevError, "get_party_password(): tried to make player %s join a NULL party", op->name); 733 LOG(llevError, "get_party_password(): tried to make player %s join a NULL party", &op->name);
736 return; 734 return;
737 } 735 }
738 op->contr->write_buf[0]='\0'; 736 op->contr->write_buf[0]='\0';
739 op->contr->state=ST_GET_PARTY_PASSWORD; 737 op->contr->state=ST_GET_PARTY_PASSWORD;
740 op->contr->party_to_join = party; 738 op->contr->party_to_join = party;
977 INVOKE_PLAYER (BIRTH, op->contr); 975 INVOKE_PLAYER (BIRTH, op->contr);
978 INVOKE_PLAYER (LOGIN, op->contr); 976 INVOKE_PLAYER (LOGIN, op->contr);
979 977
980 op->contr->state=ST_PLAYING; 978 op->contr->state=ST_PLAYING;
981 979
982 if (op->msg) { 980 if (op->msg)
983 free_string(op->msg);
984 op->msg=NULL; 981 op->msg=NULL;
985 }
986 982
987 /* We create this now because some of the unique maps will need it 983 /* We create this now because some of the unique maps will need it
988 * to save here. 984 * to save here.
989 */ 985 */
990 sprintf(buf,"%s/%s/%s",settings.localdir,settings.playerdir,op->name); 986 sprintf(buf,"%s/%s/%s",settings.localdir,settings.playerdir,&op->name);
991 make_path_to_file(buf); 987 make_path_to_file(buf);
992 988
993#ifdef AUTOSAVE 989#ifdef AUTOSAVE
994 op->contr->last_save_tick = pticks; 990 op->contr->last_save_tick = pticks;
995#endif 991#endif
1006 if(*first_map_ext_path) { 1002 if(*first_map_ext_path) {
1007 object *tmp; 1003 object *tmp;
1008 mapstruct *oldmap = op->map; 1004 mapstruct *oldmap = op->map;
1009 char mapname[MAX_BUF]; 1005 char mapname[MAX_BUF];
1010 snprintf(mapname, MAX_BUF-1, "%s/%s", 1006 snprintf(mapname, MAX_BUF-1, "%s/%s",
1011 first_map_ext_path, op->arch->name); 1007 first_map_ext_path, &op->arch->name);
1012 tmp=get_object(); 1008 tmp=get_object();
1013 EXIT_PATH(tmp) = add_string(mapname); 1009 EXIT_PATH(tmp) = mapname;
1014 EXIT_X(tmp) = op->x; 1010 EXIT_X(tmp) = op->x;
1015 EXIT_Y(tmp) = op->y; 1011 EXIT_Y(tmp) = op->y;
1016 enter_exit(op,tmp); /* we don't really care if it succeeded; 1012 enter_exit(op,tmp); /* we don't really care if it succeeded;
1017 * if the map isn't there, then stay on the 1013 * if the map isn't there, then stay on the
1018 * default initial map */ 1014 * default initial map */
1027 * if we don't match with one of the options above. 1023 * if we don't match with one of the options above.
1028 */ 1024 */
1029 1025
1030 tmp_loop = 0; 1026 tmp_loop = 0;
1031 while(!tmp_loop) { 1027 while(!tmp_loop) {
1032 const char *name = add_string (op->name); 1028 shstr name = op->name;
1033 int x = op->x, y = op->y; 1029 int x = op->x, y = op->y;
1034 remove_statbonus(op); 1030 remove_statbonus(op);
1035 remove_ob (op); 1031 remove_ob (op);
1036 op->arch = get_player_archetype(op->arch); 1032 op->arch = get_player_archetype(op->arch);
1037 copy_object (&op->arch->clone, op); 1033 copy_object (&op->arch->clone, op);
1038 op->instantiate (); 1034 op->instantiate ();
1039 op->stats = op->contr->orig_stats; 1035 op->stats = op->contr->orig_stats;
1040 free_string (op->name);
1041 op->name = name; 1036 op->name = op->name_pl = name;
1042 free_string(op->name_pl);
1043 op->name_pl = add_string(name);
1044 op->x = x; 1037 op->x = x;
1045 op->y = y; 1038 op->y = y;
1046 SET_ANIMATION(op, 2); /* So player faces south */ 1039 SET_ANIMATION(op, 2); /* So player faces south */
1047 insert_ob_in_map (op, op->map, op,0); 1040 insert_ob_in_map (op, op->map, op,0);
1048 strncpy(op->contr->title, op->arch->clone.name, sizeof(op->contr->title)-1); 1041 strncpy(op->contr->title, op->arch->clone.name, sizeof(op->contr->title)-1);
1049 op->contr->title[sizeof(op->contr->title)-1] = '\0'; 1042 op->contr->title[sizeof(op->contr->title)-1] = '\0';
1050 add_statbonus(op); 1043 add_statbonus(op);
1051 tmp_loop=allowed_class(op); 1044 tmp_loop=allowed_class(op);
1052
1053 if (!strncmp (op->msg, "Edit me", 7)) tmp_loop = 0; // pippijn fucked it up //D//TODO
1054 } 1045 }
1055 update_object(op,UP_OBJ_FACE); 1046 update_object(op,UP_OBJ_FACE);
1056 esrv_update_item(UPD_FACE,op,op); 1047 esrv_update_item(UPD_FACE,op,op);
1057 fix_player(op); 1048 fix_player(op);
1058 op->stats.hp=op->stats.maxhp; 1049 op->stats.hp=op->stats.maxhp;
1079 1070
1080 terminate_all_pets(op); 1071 terminate_all_pets(op);
1081 leave_map(op); 1072 leave_map(op);
1082 op->direction=0; 1073 op->direction=0;
1083 new_draw_info_format(NDI_UNIQUE | NDI_ALL, 5, NULL, 1074 new_draw_info_format(NDI_UNIQUE | NDI_ALL, 5, NULL,
1084 "%s quits the game.",op->name); 1075 "%s quits the game.", &op->name);
1085 1076
1086 strcpy(op->contr->killer,"quit"); 1077 strcpy(op->contr->killer,"quit");
1087 check_score(op); 1078 check_score(op);
1088 op->contr->party=NULL; 1079 op->contr->party=NULL;
1089 if (settings.set_title == TRUE) 1080 if (settings.set_title == TRUE)
1094 1085
1095 /* We need to hunt for any per player unique maps in memory and 1086 /* We need to hunt for any per player unique maps in memory and
1096 * get rid of them. The trailing slash in the path is intentional, 1087 * get rid of them. The trailing slash in the path is intentional,
1097 * so that players named 'Ab' won't match against players 'Abe' pathname 1088 * so that players named 'Ab' won't match against players 'Abe' pathname
1098 */ 1089 */
1099 sprintf(buf,"%s/%s/%s/", settings.localdir, settings.playerdir, op->name); 1090 sprintf(buf,"%s/%s/%s/", settings.localdir, settings.playerdir, &op->name);
1100 for (mp=first_map; mp!=NULL; mp=next) { 1091 for (mp=first_map; mp!=NULL; mp=next) {
1101 next = mp->next; 1092 next = mp->next;
1102 if (!strncmp(mp->path, buf, strlen(buf))) 1093 if (!strncmp(mp->path, buf, strlen(buf)))
1103 delete_map(mp); 1094 delete_map(mp);
1104 } 1095 }
1239 if(op->contr->mode & PU_DEBUG) 1230 if(op->contr->mode & PU_DEBUG)
1240 { 1231 {
1241 /* some debugging code to figure out item information */ 1232 /* some debugging code to figure out item information */
1242 if(tmp->name!=NULL) 1233 if(tmp->name!=NULL)
1243 sprintf(putstring,"item name: %s item type: %d weight/value: %d", 1234 sprintf(putstring,"item name: %s item type: %d weight/value: %d",
1244 tmp->name, tmp->type, 1235 &tmp->name, tmp->type,
1245 (int)(query_cost(tmp, op, F_TRUE)*100 / (tmp->weight * MAX(tmp->nrof,1)))); 1236 (int)(query_cost(tmp, op, F_TRUE)*100 / (tmp->weight * MAX(tmp->nrof,1))));
1246 else 1237 else
1247 sprintf(putstring,"item name: %s item type: %d weight/value: %d", 1238 sprintf(putstring,"item name: %s item type: %d weight/value: %d",
1248 tmp->arch->name, tmp->type, 1239 &tmp->arch->name, tmp->type,
1249 (int)(query_cost(tmp, op, F_TRUE)*100 / (tmp->weight * MAX(tmp->nrof,1)))); 1240 (int)(query_cost(tmp, op, F_TRUE)*100 / (tmp->weight * MAX(tmp->nrof,1))));
1250 new_draw_info(NDI_UNIQUE, 0,op,putstring); 1241 new_draw_info(NDI_UNIQUE, 0,op,putstring);
1251 1242
1252 sprintf(putstring,"...flags: "); 1243 sprintf(putstring,"...flags: ");
1253 for(k=0;k<4;k++) 1244 for(k=0;k<4;k++)
1613 */ 1604 */
1614 if(bow->type==BOW) 1605 if(bow->type==BOW)
1615 break; 1606 break;
1616 1607
1617 if (!bow) { 1608 if (!bow) {
1618 LOG (llevError, "Range: bow without activated bow (%s).\n", op->name); 1609 LOG (llevError, "Range: bow without activated bow (%s).\n", &op->name);
1619 return 0; 1610 return 0;
1620 } 1611 }
1621 } 1612 }
1622 if( !bow->race || !bow->skill) { 1613 if( !bow->race || !bow->skill) {
1623 new_draw_info_format(NDI_UNIQUE, 0, op, "Your %s is broken.", bow->name); 1614 new_draw_info_format(NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name);
1624 return 0; 1615 return 0;
1625 } 1616 }
1626 1617
1627 bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex]; 1618 bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex];
1628 1619
1634 1625
1635 if (arrow == NULL) { 1626 if (arrow == NULL) {
1636 if ((arrow=find_arrow(op, bow->race)) == NULL) { 1627 if ((arrow=find_arrow(op, bow->race)) == NULL) {
1637 if (op->type == PLAYER) 1628 if (op->type == PLAYER)
1638 new_draw_info_format(NDI_UNIQUE, 0, op, 1629 new_draw_info_format(NDI_UNIQUE, 0, op,
1639 "You have no %s left.", bow->race); 1630 "You have no %s left.", &bow->race);
1640 /* FLAG_READY_BOW will get reset if the monsters picks up some arrows */ 1631 /* FLAG_READY_BOW will get reset if the monsters picks up some arrows */
1641 else 1632 else
1642 CLEAR_FLAG(op, FLAG_READY_BOW); 1633 CLEAR_FLAG(op, FLAG_READY_BOW);
1643 return 0; 1634 return 0;
1644 } 1635 }
1661 1652
1662 left = arrow; /* these are arrows left to the player */ 1653 left = arrow; /* these are arrows left to the player */
1663 left_tag = left->count; 1654 left_tag = left->count;
1664 arrow = get_split_ob(arrow, 1); 1655 arrow = get_split_ob(arrow, 1);
1665 if (arrow == NULL) { 1656 if (arrow == NULL) {
1666 new_draw_info_format(NDI_UNIQUE, 0, op, "You have no %s left.", 1657 new_draw_info_format(NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race);
1667 bow->race);
1668 return 0; 1658 return 0;
1669 } 1659 }
1670 set_owner(arrow, op); 1660 set_owner(arrow, op);
1671 if (arrow->skill) free_string(arrow->skill);
1672 arrow->skill = add_refcount(bow->skill); 1661 arrow->skill = bow->skill;
1673 1662
1674 arrow->direction=dir; 1663 arrow->direction=dir;
1675 arrow->x = sx; 1664 arrow->x = sx;
1676 arrow->y = sy; 1665 arrow->y = sy;
1677 1666
1720 arrow->level = op->level; 1709 arrow->level = op->level;
1721 } 1710 }
1722 if (arrow->attacktype == AT_PHYSICAL) 1711 if (arrow->attacktype == AT_PHYSICAL)
1723 arrow->attacktype |= bow->attacktype; 1712 arrow->attacktype |= bow->attacktype;
1724 if (bow->slaying != NULL) 1713 if (bow->slaying != NULL)
1725 arrow->slaying = add_string(bow->slaying); 1714 arrow->slaying = bow->slaying;
1726 1715
1727 arrow->map = m; 1716 arrow->map = m;
1728 arrow->move_type = MOVE_FLY_LOW; 1717 arrow->move_type = MOVE_FLY_LOW;
1729 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; 1718 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK;
1730 1719
1793 return; 1782 return;
1794 } 1783 }
1795 1784
1796 item = op->contr->ranges[range_misc]; 1785 item = op->contr->ranges[range_misc];
1797 if (!item->inv) { 1786 if (!item->inv) {
1798 LOG(llevError,"Object %s lacks a spell\n", item->name); 1787 LOG(llevError,"Object %s lacks a spell\n", &item->name);
1799 return; 1788 return;
1800 } 1789 }
1801 if (item->type == WAND) { 1790 if (item->type == WAND) {
1802 if(item->stats.food<=0) { 1791 if(item->stats.food<=0) {
1803 play_sound_player_only(op->contr, SOUND_WAND_POOF,0,0); 1792 play_sound_player_only(op->contr, SOUND_WAND_POOF,0,0);
2368 char buf[MAX_BUF]; 2357 char buf[MAX_BUF];
2369 time_t now = time (NULL); 2358 time_t now = time (NULL);
2370 2359
2371 strcpy (buf2, " R.I.P.\n\n"); 2360 strcpy (buf2, " R.I.P.\n\n");
2372 if (op->type == PLAYER) 2361 if (op->type == PLAYER)
2373 sprintf (buf, "%s the %s\n", op->name, op->contr->title); 2362 sprintf (buf, "%s the %s\n", &op->name, op->contr->title);
2374 else 2363 else
2375 sprintf (buf, "%s\n", op->name); 2364 sprintf (buf, "%s\n", &op->name);
2376 strncat (buf2, " ", 20 - strlen (buf) / 2); 2365 strncat (buf2, " ", 20 - strlen (buf) / 2);
2377 strcat (buf2, buf); 2366 strcat (buf2, buf);
2378 if (op->type == PLAYER) 2367 if (op->type == PLAYER)
2379 sprintf (buf, "who was in level %d when killed\n", op->level); 2368 sprintf (buf, "who was in level %d when killed\n", op->level);
2380 else 2369 else
2626 2615
2627 /* create a bodypart-trophy to make the winner happy */ 2616 /* create a bodypart-trophy to make the winner happy */
2628 tmp=arch_to_object(find_archetype("finger")); 2617 tmp=arch_to_object(find_archetype("finger"));
2629 if (tmp != NULL) 2618 if (tmp != NULL)
2630 { 2619 {
2631 sprintf(buf,"%s's finger",op->name); 2620 sprintf(buf,"%s's finger", &op->name);
2632 tmp->name = add_string(buf); 2621 tmp->name = buf;
2633 sprintf(buf," This finger has been cut off %s\n" 2622 sprintf(buf," This finger has been cut off %s\n"
2634 " the %s, when he was defeated at\n level %d by %s.\n", 2623 " the %s, when he was defeated at\n level %d by %s.\n",
2635 op->name, op->contr->title, (int)(op->level), 2624 &op->name, op->contr->title, (int)(op->level),
2636 op->contr->killer); 2625 op->contr->killer);
2637 tmp->msg=add_string(buf); 2626 tmp->msg=buf;
2638 tmp->value=0, tmp->material=0, tmp->type=0; 2627 tmp->value=0, tmp->material=0, tmp->type=0;
2639 tmp->materialname = NULL; 2628 tmp->materialname = NULL;
2640 tmp->x = op->x, tmp->y = op->y; 2629 tmp->x = op->x, tmp->y = op->y;
2641 insert_ob_in_map(tmp,op->map,op,0); 2630 insert_ob_in_map(tmp,op->map,op,0);
2642 } 2631 }
2656 new_draw_info(NDI_UNIQUE, 0,op,"You would have starved, but you are"); 2645 new_draw_info(NDI_UNIQUE, 0,op,"You would have starved, but you are");
2657 new_draw_info(NDI_UNIQUE, 0,op,"in explore mode, so..."); 2646 new_draw_info(NDI_UNIQUE, 0,op,"in explore mode, so...");
2658 op->stats.food=999; 2647 op->stats.food=999;
2659 return; 2648 return;
2660 } 2649 }
2661 sprintf(buf,"%s starved to death.",op->name); 2650 sprintf(buf,"%s starved to death.",&op->name);
2662 strcpy(op->contr->killer,"starvation"); 2651 strcpy(op->contr->killer,"starvation");
2663 } 2652 }
2664 else { 2653 else {
2665 if (op->contr->explore) { 2654 if (op->contr->explore) {
2666 new_draw_info(NDI_UNIQUE, 0,op,"You would have died, but you are"); 2655 new_draw_info(NDI_UNIQUE, 0,op,"You would have died, but you are");
2667 new_draw_info(NDI_UNIQUE, 0,op,"in explore mode, so..."); 2656 new_draw_info(NDI_UNIQUE, 0,op,"in explore mode, so...");
2668 op->stats.hp=op->stats.maxhp; 2657 op->stats.hp=op->stats.maxhp;
2669 return; 2658 return;
2670 } 2659 }
2671 sprintf(buf,"%s died.",op->name); 2660 sprintf(buf,"%s died.", &op->name);
2672 } 2661 }
2673 play_sound_player_only(op->contr, SOUND_PLAYER_DIES,0,0); 2662 play_sound_player_only(op->contr, SOUND_PLAYER_DIES,0,0);
2674 2663
2675 /* save the map location for corpse, gravestone*/ 2664 /* save the map location for corpse, gravestone*/
2676 x=op->x;y=op->y;map=op->map; 2665 x=op->x;y=op->y;map=op->map;
2793 2782
2794 /* Put a gravestone up where the character 'almost' died. List the 2783 /* Put a gravestone up where the character 'almost' died. List the
2795 * exp loss on the stone. 2784 * exp loss on the stone.
2796 */ 2785 */
2797 tmp=arch_to_object(find_archetype("gravestone")); 2786 tmp=arch_to_object(find_archetype("gravestone"));
2798 sprintf(buf,"%s's gravestone",op->name); 2787 sprintf(buf,"%s's gravestone",&op->name); tmp->name = buf;
2799 FREE_AND_COPY(tmp->name, buf);
2800 sprintf(buf,"%s's gravestones",op->name); 2788 sprintf(buf,"%s's gravestones",&op->name); tmp->name_pl = buf;
2801 FREE_AND_COPY(tmp->name_pl, buf);
2802 sprintf(buf,"RIP\nHere rests the hero %s the %s,\n" 2789 sprintf(buf,"RIP\nHere rests the hero %s the %s,\n"
2803 "who was killed\n" 2790 "who was killed\n"
2804 "by %s.\n", 2791 "by %s.\n",
2805 op->name, op->contr->title, 2792 &op->name, op->contr->title,
2806 op->contr->killer); 2793 op->contr->killer);
2807 tmp->msg = add_string(buf); 2794 tmp->msg = buf;
2808 tmp->x=op->x,tmp->y=op->y; 2795 tmp->x=op->x,tmp->y=op->y;
2809 insert_ob_in_map (tmp, op->map, NULL,0); 2796 insert_ob_in_map (tmp, op->map, NULL,0);
2810 2797
2811 /**************************************/ 2798 /**************************************/
2812 /* */ 2799 /* */
2952 } 2939 }
2953 play_again(op); 2940 play_again(op);
2954 2941
2955 /* peterm: added to create a corpse at deathsite. */ 2942 /* peterm: added to create a corpse at deathsite. */
2956 tmp=arch_to_object(find_archetype("corpse_pl")); 2943 tmp=arch_to_object(find_archetype("corpse_pl"));
2957 sprintf(buf,"%s", op->name); 2944 sprintf(buf,"%s", &op->name);
2958 FREE_AND_COPY(tmp->name, buf); 2945 tmp->name = tmp->name_pl = buf;
2959 FREE_AND_COPY(tmp->name_pl, buf);
2960 tmp->level=op->level; 2946 tmp->level=op->level;
2961 tmp->x=x;tmp->y=y; 2947 tmp->x=x;tmp->y=y;
2962 if (tmp->msg)
2963 free_string(tmp->msg);
2964 tmp->msg = add_string (gravestone_text(op)); 2948 tmp->msg = gravestone_text(op);
2965 SET_FLAG (tmp, FLAG_UNIQUE); 2949 SET_FLAG (tmp, FLAG_UNIQUE);
2966 insert_ob_in_map (tmp, map, NULL,0); 2950 insert_ob_in_map (tmp, map, NULL,0);
2967 } 2951 }
2968} 2952}
2969 2953
3008 int old = pl->ob->carrying, sum = sum_weight(pl->ob); 2992 int old = pl->ob->carrying, sum = sum_weight(pl->ob);
3009 if(old == sum) 2993 if(old == sum)
3010 continue; 2994 continue;
3011 fix_player(pl->ob); 2995 fix_player(pl->ob);
3012 LOG(llevDebug,"Fixed inventory in %s (%d -> %d)\n", 2996 LOG(llevDebug,"Fixed inventory in %s (%d -> %d)\n",
3013 pl->ob->name, old, sum); 2997 &pl->ob->name, old, sum);
3014 } 2998 }
3015} 2999}
3016 3000
3017void fix_luck(void) { 3001void fix_luck(void) {
3018 player *pl; 3002 player *pl;
3036 3020
3037 /* casting POTION 'dusts' is really a use_magic_item skill */ 3021 /* casting POTION 'dusts' is really a use_magic_item skill */
3038 if (op->type == PLAYER && throw_ob->type == POTION && !skop) 3022 if (op->type == PLAYER && throw_ob->type == POTION && !skop)
3039 { 3023 {
3040 LOG (llevError, "Player %s lacks critical skill use_magic_item!\n", 3024 LOG (llevError, "Player %s lacks critical skill use_magic_item!\n",
3041 op->name); 3025 &op->name);
3042 return; 3026 return;
3043 } 3027 }
3044 3028
3045 spob = throw_ob->inv; 3029 spob = throw_ob->inv;
3046 3030
3048 // not pass NULL to cast_spell (which did indeed check itself, but 3032 // not pass NULL to cast_spell (which did indeed check itself, but
3049 // errors should be reported as early as possible IMHO) 3033 // errors should be reported as early as possible IMHO)
3050 if (!spob) 3034 if (!spob)
3051 { 3035 {
3052 LOG (llevError, "cast_dust: thrown object %s (by %s) had no spell in it!", 3036 LOG (llevError, "cast_dust: thrown object %s (by %s) had no spell in it!",
3053 throw_ob->name, op->name); 3037 &throw_ob->name, &op->name);
3054 return; 3038 return;
3055 } 3039 }
3056 3040
3057 if (op->type == PLAYER) 3041 if (op->type == PLAYER)
3058 new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", spob->name); 3042 new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name);
3059 3043
3060 cast_spell (op, throw_ob, dir, spob, NULL); 3044 cast_spell (op, throw_ob, dir, spob, NULL);
3061 3045
3062 if (!QUERY_FLAG (throw_ob, FLAG_REMOVED)) 3046 if (!QUERY_FLAG (throw_ob, FLAG_REMOVED))
3063 remove_ob (throw_ob); 3047 remove_ob (throw_ob);
3067void make_visible (object *op) { 3051void make_visible (object *op) {
3068 op->hide = 0; 3052 op->hide = 0;
3069 op->invisible = 0; 3053 op->invisible = 0;
3070 if(op->type==PLAYER) { 3054 if(op->type==PLAYER) {
3071 op->contr->tmp_invis = 0; 3055 op->contr->tmp_invis = 0;
3072 if (op->contr->invis_race) FREE_AND_CLEAR_STR(op->contr->invis_race); 3056 op->contr->invis_race = 0;
3073 } 3057 }
3074 update_object(op,UP_OBJ_FACE); 3058 update_object(op,UP_OBJ_FACE);
3075} 3059}
3076 3060
3077int is_true_undead(object *op) { 3061int is_true_undead(object *op) {
3356 3340
3357 if (item->type == SPELL) { 3341 if (item->type == SPELL) {
3358 if (check_spell_known (who, item->name)) 3342 if (check_spell_known (who, item->name))
3359 return; 3343 return;
3360 3344
3361 new_draw_info_format(NDI_UNIQUE|NDI_BLUE, 0, who, "You gained the ability of %s", item->name); 3345 new_draw_info_format(NDI_UNIQUE|NDI_BLUE, 0, who, "You gained the ability of %s", &item->name);
3362 do_learn_spell (who, item, 0); 3346 do_learn_spell (who, item, 0);
3363 return; 3347 return;
3364 } 3348 }
3365 3349
3366 /* grant direct spell */ 3350 /* grant direct spell */
3367 if (item->type == SPELLBOOK) { 3351 if (item->type == SPELLBOOK) {
3368 if (!item->inv) { 3352 if (!item->inv) {
3369 LOG(llevDebug,"dragon_ability_gain: Broken spellbook %s\n", 3353 LOG(llevDebug,"dragon_ability_gain: Broken spellbook %s\n", &item->name);
3370 item->name);
3371 return; 3354 return;
3372 } 3355 }
3373 if (check_spell_known (who, item->inv->name)) 3356 if (check_spell_known (who, item->inv->name))
3374 return; 3357 return;
3375 if (item->invisible) { 3358 if (item->invisible) {
3376 new_draw_info_format(NDI_UNIQUE|NDI_BLUE, 0, who, "You gained the ability of %s", item->inv->name); 3359 new_draw_info_format(NDI_UNIQUE|NDI_BLUE, 0, who, "You gained the ability of %s", &item->inv->name);
3377 do_learn_spell (who, item->inv, 0); 3360 do_learn_spell (who, item->inv, 0);
3378 return; 3361 return;
3379 } 3362 }
3380 } 3363 }
3381 else if (item->type == SKILL_TOOL && item->invisible) { 3364 else if (item->type == SKILL_TOOL && item->invisible) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines