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.50 by elmex, Wed Dec 20 10:31:00 2006 UTC vs.
Revision 1.52 by root, Thu Dec 21 23:37:06 2006 UTC

244 op->direction = 5; /* So player faces south */ 244 op->direction = 5; /* So player faces south */
245 op->stats.wc = 2; 245 op->stats.wc = 2;
246 op->run_away = 25; /* Then we panick... */ 246 op->run_away = 25; /* Then we panick... */
247 247
248 { 248 {
249 int oldmon = p->socket->monitor_spells; // what a hack 249 int oldmon = p->ns->monitor_spells; // what a hack
250 p->socket->monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */ 250 p->ns->monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */
251 roll_stats (op); 251 roll_stats (op);
252 p->socket->monitor_spells = oldmon; 252 p->ns->monitor_spells = oldmon;
253 } 253 }
254 p->state = ST_ROLL_STAT; 254 p->ns->state = ST_ROLL_STAT;
255 clear_los (op); 255 clear_los (op);
256 256
257 p->gen_sp_armour = 10; 257 p->gen_sp_armour = 10;
258 p->last_speed = -1; 258 p->last_speed = -1;
259 p->shoottype = range_none; 259 p->shoottype = range_none;
286 p->last_resist[i] = -1; 286 p->last_resist[i] = -1;
287 287
288 p->last_stats.exp = -1; 288 p->last_stats.exp = -1;
289 p->last_weight = (uint32) - 1; 289 p->last_weight = (uint32) - 1;
290 290
291 p->socket->update_look = 0; 291 p->ns->update_look = 0;
292 p->socket->look_position = 0; 292 p->ns->look_position = 0;
293 293
294 return p; 294 return p;
295} 295}
296 296
297/* This loads the first map an puts the player on it. */ 297/* This loads the first map an puts the player on it. */
312int 312int
313add_player (client *ns) 313add_player (client *ns)
314{ 314{
315 player *p = new player; 315 player *p = new player;
316 316
317 p->socket = ns; 317 p->ns = ns;
318 ns->pl = p; 318 ns->pl = p;
319 319
320 p->next = first_player; 320 p->next = first_player;
321 first_player = p; 321 first_player = p;
322 322
327 CLEAR_FLAG (p->ob, FLAG_FRIENDLY); 327 CLEAR_FLAG (p->ob, FLAG_FRIENDLY);
328 add_friendly_object (p->ob); 328 add_friendly_object (p->ob);
329 send_rules (p->ob); 329 send_rules (p->ob);
330 send_news (p->ob); 330 send_news (p->ob);
331 display_motd (p->ob); 331 display_motd (p->ob);
332
332 get_name (p->ob); 333 get_name (p->ob);
333 334
334 return 0; 335 return 0;
335} 336}
336 337
697 698
698void 699void
699get_name (object *op) 700get_name (object *op)
700{ 701{
701 op->contr->write_buf[0] = '\0'; 702 op->contr->write_buf[0] = '\0';
702 op->contr->state = ST_GET_NAME; 703 op->contr->ns->state = ST_GET_NAME;
703 send_query (op->contr->socket, 0, "What is your name?\n:"); 704 send_query (op->contr->ns, 0, "What is your name?\n:");
704} 705}
705 706
706void 707void
707get_password (object *op) 708get_password (object *op)
708{ 709{
709 op->contr->write_buf[0] = '\0'; 710 op->contr->write_buf[0] = '\0';
710 op->contr->state = ST_GET_PASSWORD; 711 op->contr->ns->state = ST_GET_PASSWORD;
711 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:"); 712 send_query (op->contr->ns, CS_QUERY_HIDEINPUT, "What is your password?\n:");
712} 713}
713 714
714void 715void
715play_again (object *op) 716play_again (object *op)
716{ 717{
717 op->contr->state = ST_PLAY_AGAIN; 718 op->contr->ns->state = ST_PLAY_AGAIN;
718 op->chosen_skill = NULL; 719 op->chosen_skill = NULL;
719 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?"); 720 send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?");
720 /* a bit of a hack, but there are various places early in th 721 /* a bit of a hack, but there are various places early in th
721 * player creation process that a user can quit (eg, roll 722 * player creation process that a user can quit (eg, roll
722 * stats) that isn't removing the player. Taking a quick 723 * stats) that isn't removing the player. Taking a quick
723 * look, there are many places that call play_again without 724 * look, there are many places that call play_again without
724 * removing the player - it probably makes more sense 725 * removing the player - it probably makes more sense
725 * to leave it to play_again to remove the object in all 726 * to leave it to play_again to remove the object in all
726 * cases. 727 * cases.
727 */ 728 */
728 if (!QUERY_FLAG (op, FLAG_REMOVED)) 729 if (!QUERY_FLAG (op, FLAG_REMOVED))
729 op->remove (); 730 op->remove ();
731
730 /* Need to set this to null - otherwise, it could point to garbage, 732 /* Need to set this to null - otherwise, it could point to garbage,
731 * and draw() doesn't check to see if the player is removed, only if 733 * and draw() doesn't check to see if the player is removed, only if
732 * the map is null or not swapped out. 734 * the map is null or not swapped out.
733 */ 735 */
734 op->map = NULL; 736 op->map = NULL;
772void 774void
773confirm_password (object *op) 775confirm_password (object *op)
774{ 776{
775 777
776 op->contr->write_buf[0] = '\0'; 778 op->contr->write_buf[0] = '\0';
777 op->contr->state = ST_CONFIRM_PASSWORD; 779 op->contr->ns->state = ST_CONFIRM_PASSWORD;
778 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:"); 780 send_query (op->contr->ns, CS_QUERY_HIDEINPUT, "Please type your password again.\n:");
779} 781}
780 782
781void 783void
782get_party_password (object *op, partylist *party) 784get_party_password (object *op, partylist *party)
783{ 785{
785 { 787 {
786 LOG (llevError, "get_party_password(): tried to make player %s join a NULL party", &op->name); 788 LOG (llevError, "get_party_password(): tried to make player %s join a NULL party", &op->name);
787 return; 789 return;
788 } 790 }
789 op->contr->write_buf[0] = '\0'; 791 op->contr->write_buf[0] = '\0';
790 op->contr->state = ST_GET_PARTY_PASSWORD; 792 op->contr->ns->state = ST_GET_PARTY_PASSWORD;
791 op->contr->party_to_join = party; 793 op->contr->party_to_join = party;
792 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:"); 794 send_query (op->contr->ns, CS_QUERY_HIDEINPUT, "What is the password?\n:");
793} 795}
794 796
795 797
796/* This rolls four 1-6 rolls and sums the best 3 of the 4. */ 798/* This rolls four 1-6 rolls and sums the best 3 of the 4. */
797int 799int
894 896
895void 897void
896Roll_Again (object *op) 898Roll_Again (object *op)
897{ 899{
898 esrv_new_player (op->contr, 0); 900 esrv_new_player (op->contr, 0);
899 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, 901 send_query (op->contr->ns, CS_QUERY_SINGLECHAR,
900 "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? "); 902 "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? ");
901} 903}
902 904
903void 905void
904Swap_Stat (object *op, int Swap_Second) 906Swap_Stat (object *op, int Swap_Second)
971 new_draw_info (NDI_UNIQUE, 0, op, buf); 973 new_draw_info (NDI_UNIQUE, 0, op, buf);
972 } 974 }
973 else 975 else
974 Swap_Stat (op, stat_trans[keynum]); 976 Swap_Stat (op, stat_trans[keynum]);
975 977
976 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, ""); 978 send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "");
977 return 1; 979 return 1;
978 } 980 }
979 switch (key) 981 switch (key)
980 { 982 {
981 case 'n': 983 case 'n':
995 enter_exit (op, NULL); 997 enter_exit (op, NULL);
996#endif 998#endif
997 SET_ANIMATION (op, 2); /* So player faces south */ 999 SET_ANIMATION (op, 2); /* So player faces south */
998 /* Enter exit adds a player otherwise */ 1000 /* Enter exit adds a player otherwise */
999 add_statbonus (op); 1001 add_statbonus (op);
1000 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, 1002 send_query (op->contr->ns, CS_QUERY_SINGLECHAR,
1001 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"); 1003 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n");
1002 op->contr->state = ST_CHANGE_CLASS; 1004 op->contr->ns->state = ST_CHANGE_CLASS;
1003 if (op->msg) 1005 if (op->msg)
1004 new_draw_info (NDI_BLUE, 0, op, op->msg); 1006 new_draw_info (NDI_BLUE, 0, op, op->msg);
1005 return 0; 1007 return 0;
1006 } 1008 }
1007 case 'y': 1009 case 'y':
1008 case 'Y': 1010 case 'Y':
1009 roll_stats (op); 1011 roll_stats (op);
1010 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, ""); 1012 send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "");
1011 return 1; 1013 return 1;
1012 1014
1013 case 'q': 1015 case 'q':
1014 case 'Q': 1016 case 'Q':
1015 play_again (op); 1017 play_again (op);
1016 return 1; 1018 return 1;
1017 1019
1018 default: 1020 default:
1019 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); 1021 send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?");
1020 return 0; 1022 return 0;
1021 } 1023 }
1022 return 0; 1024 return 0;
1023} 1025}
1024 1026
1052 create_treasure (tl, op, 0, 0, 0); 1054 create_treasure (tl, op, 0, 0, 0);
1053 1055
1054 INVOKE_PLAYER (BIRTH, op->contr); 1056 INVOKE_PLAYER (BIRTH, op->contr);
1055 INVOKE_PLAYER (LOGIN, op->contr); 1057 INVOKE_PLAYER (LOGIN, op->contr);
1056 1058
1057 op->contr->state = ST_PLAYING; 1059 op->contr->ns->state = ST_PLAYING;
1058 1060
1059 if (op->msg) 1061 if (op->msg)
1060 op->msg = NULL; 1062 op->msg = NULL;
1061 1063
1062 /* We create this now because some of the unique maps will need it 1064 /* We create this now because some of the unique maps will need it
1133 op->stats.grace = 0; 1135 op->stats.grace = 0;
1134 1136
1135 if (op->msg) 1137 if (op->msg)
1136 new_draw_info (NDI_BLUE, 0, op, op->msg); 1138 new_draw_info (NDI_BLUE, 0, op, op->msg);
1137 1139
1138 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n"); 1140 send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n");
1139 return 0; 1141 return 0;
1140} 1142}
1141 1143
1142int 1144int
1143key_confirm_quit (object *op, char key) 1145key_confirm_quit (object *op, char key)
1144{ 1146{
1145 char buf[MAX_BUF]; 1147 char buf[MAX_BUF];
1146 1148
1147 if (key != 'y' && key != 'Y' && key != 'q' && key != 'Q') 1149 if (key != 'y' && key != 'Y' && key != 'q' && key != 'Q')
1148 { 1150 {
1149 op->contr->state = ST_PLAYING; 1151 op->contr->ns->state = ST_PLAYING;
1150 new_draw_info (NDI_UNIQUE, 0, op, "OK, continuing to play."); 1152 new_draw_info (NDI_UNIQUE, 0, op, "OK, continuing to play.");
1151 return 1; 1153 return 1;
1152 } 1154 }
1153 1155
1154 INVOKE_PLAYER (LOGOUT, op->contr); 1156 INVOKE_PLAYER (LOGOUT, op->contr);
2552 /* call this here - we also will call this in do_ericserver, but 2554 /* call this here - we also will call this in do_ericserver, but
2553 * the players time has been increased when doericserver has been 2555 * the players time has been increased when doericserver has been
2554 * called, so we recheck it here. 2556 * called, so we recheck it here.
2555 */ 2557 */
2556 //TODO: better than handling 8 commands, use some more intelligent rate-limiting 2558 //TODO: better than handling 8 commands, use some more intelligent rate-limiting
2557 for (int rep = 8; --rep && op->contr->socket->handle_command (); ) 2559 for (int rep = 8; --rep && op->contr->ns->handle_command (); )
2558 ; 2560 ;
2559 2561
2560 if (op->speed_left < 0) 2562 if (op->speed_left < 0)
2561 return 0; 2563 return 0;
2562 2564
2709 for (i = 0; i < NUM_OUTPUT_BUFS; i++) 2711 for (i = 0; i < NUM_OUTPUT_BUFS; i++)
2710 if (op->contr->outputs[i].buf != NULL && (op->contr->outputs[i].first_update + op->contr->outputs_sync) < (uint16) pticks) 2712 if (op->contr->outputs[i].buf != NULL && (op->contr->outputs[i].first_update + op->contr->outputs_sync) < (uint16) pticks)
2711 flush_output_element (op, &op->contr->outputs[i]); 2713 flush_output_element (op, &op->contr->outputs[i]);
2712 } 2714 }
2713 2715
2714 if (op->contr->state == ST_PLAYING) 2716 if (op->contr->ns->state == ST_PLAYING)
2715 { 2717 {
2716 2718
2717 /* these next three if clauses make it possible to SLOW DOWN 2719 /* these next three if clauses make it possible to SLOW DOWN
2718 hp/grace/spellpoint regeneration. */ 2720 hp/grace/spellpoint regeneration. */
2719 if (op->contr->gen_hp >= 0) 2721 if (op->contr->gen_hp >= 0)
2861 if (!QUERY_FLAG (op, FLAG_WIZ)) 2863 if (!QUERY_FLAG (op, FLAG_WIZ))
2862 op->stats.food--; 2864 op->stats.food--;
2863 } 2865 }
2864 } 2866 }
2865 2867
2866 if (op->contr->state == ST_PLAYING && op->stats.food < 0 && op->stats.hp >= 0) 2868 if (op->contr->ns->state == ST_PLAYING && op->stats.food < 0 && op->stats.hp >= 0)
2867 { 2869 {
2868 object *tmp, *flesh = NULL; 2870 object *tmp, *flesh = NULL;
2869 2871
2870 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 2872 for (tmp = op->inv; tmp != NULL; tmp = tmp->below)
2871 { 2873 {
2893 } /* end if player is starving */ 2895 } /* end if player is starving */
2894 2896
2895 while (op->stats.food < 0 && op->stats.hp > 0) 2897 while (op->stats.food < 0 && op->stats.hp > 0)
2896 op->stats.food++, op->stats.hp--; 2898 op->stats.food++, op->stats.hp--;
2897 2899
2898 if (!op->contr->state && !QUERY_FLAG (op, FLAG_WIZ) && (op->stats.hp < 0 || op->stats.food < 0)) 2900 if (!op->contr->ns->state && !QUERY_FLAG (op, FLAG_WIZ) && (op->stats.hp < 0 || op->stats.food < 0))
2899 kill_player (op); 2901 kill_player (op);
2900} 2902}
2901 2903
2902 2904
2903 2905
3382fix_luck (void) 3384fix_luck (void)
3383{ 3385{
3384 player *pl; 3386 player *pl;
3385 3387
3386 for (pl = first_player; pl != NULL; pl = pl->next) 3388 for (pl = first_player; pl != NULL; pl = pl->next)
3387 if (!pl->ob->contr->state) 3389 if (!pl->ob->contr->ns->state)
3388 change_luck (pl->ob, 0); 3390 change_luck (pl->ob, 0);
3389} 3391}
3390 3392
3391 3393
3392/* cast_dust() - handles op throwing objects of type 'DUST'. 3394/* cast_dust() - handles op throwing objects of type 'DUST'.
3634 3636
3635 /* only the viewable area the player sees is updated by LOS 3637 /* only the viewable area the player sees is updated by LOS
3636 * code, so we need to restrict ourselves to that range of values 3638 * code, so we need to restrict ourselves to that range of values
3637 * for any meaningful values. 3639 * for any meaningful values.
3638 */ 3640 */
3639 if (FABS (dx) <= (pl->contr->socket->mapx / 2) && 3641 if (FABS (dx) <= (pl->contr->ns->mapx / 2) &&
3640 FABS (dy) <= (pl->contr->socket->mapy / 2) && 3642 FABS (dy) <= (pl->contr->ns->mapy / 2) &&
3641 !pl->contr->blocked_los[dx + (pl->contr->socket->mapx / 2)][dy + (pl->contr->socket->mapy / 2)]) 3643 !pl->contr->blocked_los[dx + (pl->contr->ns->mapx / 2)][dy + (pl->contr->ns->mapy / 2)])
3642 return 1; 3644 return 1;
3643 op = op->more; 3645 op = op->more;
3644 } 3646 }
3645 return 0; 3647 return 0;
3646} 3648}
3832 { 3834 {
3833 /* forces in the treasurelist can alter the player's stats */ 3835 /* forces in the treasurelist can alter the player's stats */
3834 object *skin; 3836 object *skin;
3835 3837
3836 /* first get the dragon skin force */ 3838 /* first get the dragon skin force */
3839 shstr_cmp dragon_skin_force ("dragon_skin_force");
3837 for (skin = who->inv; skin != NULL && strcmp (skin->arch->name, "dragon_skin_force") != 0; skin = skin->below); 3840 for (skin = who->inv; skin && !(skin->arch->name == dragon_skin_force); skin = skin->below)
3841 ;
3842
3838 if (skin == NULL) 3843 if (!skin)
3839 return; 3844 return;
3840 3845
3841 /* adding new spellpath attunements */ 3846 /* adding new spellpath attunements */
3842 if (item->path_attuned > 0 && !(skin->path_attuned & item->path_attuned)) 3847 if (item->path_attuned > 0 && !(skin->path_attuned & item->path_attuned))
3843 { 3848 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines