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.51 by root, Thu Dec 21 06:12:37 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
698 698
699void 699void
700get_name (object *op) 700get_name (object *op)
701{ 701{
702 op->contr->write_buf[0] = '\0'; 702 op->contr->write_buf[0] = '\0';
703 op->contr->state = ST_GET_NAME; 703 op->contr->ns->state = ST_GET_NAME;
704 send_query (op->contr->socket, 0, "What is your name?\n:"); 704 send_query (op->contr->ns, 0, "What is your name?\n:");
705} 705}
706 706
707void 707void
708get_password (object *op) 708get_password (object *op)
709{ 709{
710 op->contr->write_buf[0] = '\0'; 710 op->contr->write_buf[0] = '\0';
711 op->contr->state = ST_GET_PASSWORD; 711 op->contr->ns->state = ST_GET_PASSWORD;
712 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:");
713} 713}
714 714
715void 715void
716play_again (object *op) 716play_again (object *op)
717{ 717{
718 op->contr->state = ST_PLAY_AGAIN; 718 op->contr->ns->state = ST_PLAY_AGAIN;
719 op->chosen_skill = NULL; 719 op->chosen_skill = NULL;
720 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)?");
721 /* 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
722 * player creation process that a user can quit (eg, roll 722 * player creation process that a user can quit (eg, roll
723 * stats) that isn't removing the player. Taking a quick 723 * stats) that isn't removing the player. Taking a quick
724 * look, there are many places that call play_again without 724 * look, there are many places that call play_again without
725 * removing the player - it probably makes more sense 725 * removing the player - it probably makes more sense
774void 774void
775confirm_password (object *op) 775confirm_password (object *op)
776{ 776{
777 777
778 op->contr->write_buf[0] = '\0'; 778 op->contr->write_buf[0] = '\0';
779 op->contr->state = ST_CONFIRM_PASSWORD; 779 op->contr->ns->state = ST_CONFIRM_PASSWORD;
780 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:");
781} 781}
782 782
783void 783void
784get_party_password (object *op, partylist *party) 784get_party_password (object *op, partylist *party)
785{ 785{
787 { 787 {
788 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);
789 return; 789 return;
790 } 790 }
791 op->contr->write_buf[0] = '\0'; 791 op->contr->write_buf[0] = '\0';
792 op->contr->state = ST_GET_PARTY_PASSWORD; 792 op->contr->ns->state = ST_GET_PARTY_PASSWORD;
793 op->contr->party_to_join = party; 793 op->contr->party_to_join = party;
794 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:");
795} 795}
796 796
797 797
798/* 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. */
799int 799int
896 896
897void 897void
898Roll_Again (object *op) 898Roll_Again (object *op)
899{ 899{
900 esrv_new_player (op->contr, 0); 900 esrv_new_player (op->contr, 0);
901 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, 901 send_query (op->contr->ns, CS_QUERY_SINGLECHAR,
902 "[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)? ");
903} 903}
904 904
905void 905void
906Swap_Stat (object *op, int Swap_Second) 906Swap_Stat (object *op, int Swap_Second)
973 new_draw_info (NDI_UNIQUE, 0, op, buf); 973 new_draw_info (NDI_UNIQUE, 0, op, buf);
974 } 974 }
975 else 975 else
976 Swap_Stat (op, stat_trans[keynum]); 976 Swap_Stat (op, stat_trans[keynum]);
977 977
978 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, ""); 978 send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "");
979 return 1; 979 return 1;
980 } 980 }
981 switch (key) 981 switch (key)
982 { 982 {
983 case 'n': 983 case 'n':
997 enter_exit (op, NULL); 997 enter_exit (op, NULL);
998#endif 998#endif
999 SET_ANIMATION (op, 2); /* So player faces south */ 999 SET_ANIMATION (op, 2); /* So player faces south */
1000 /* Enter exit adds a player otherwise */ 1000 /* Enter exit adds a player otherwise */
1001 add_statbonus (op); 1001 add_statbonus (op);
1002 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, 1002 send_query (op->contr->ns, CS_QUERY_SINGLECHAR,
1003 "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");
1004 op->contr->state = ST_CHANGE_CLASS; 1004 op->contr->ns->state = ST_CHANGE_CLASS;
1005 if (op->msg) 1005 if (op->msg)
1006 new_draw_info (NDI_BLUE, 0, op, op->msg); 1006 new_draw_info (NDI_BLUE, 0, op, op->msg);
1007 return 0; 1007 return 0;
1008 } 1008 }
1009 case 'y': 1009 case 'y':
1010 case 'Y': 1010 case 'Y':
1011 roll_stats (op); 1011 roll_stats (op);
1012 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, ""); 1012 send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "");
1013 return 1; 1013 return 1;
1014 1014
1015 case 'q': 1015 case 'q':
1016 case 'Q': 1016 case 'Q':
1017 play_again (op); 1017 play_again (op);
1018 return 1; 1018 return 1;
1019 1019
1020 default: 1020 default:
1021 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?");
1022 return 0; 1022 return 0;
1023 } 1023 }
1024 return 0; 1024 return 0;
1025} 1025}
1026 1026
1054 create_treasure (tl, op, 0, 0, 0); 1054 create_treasure (tl, op, 0, 0, 0);
1055 1055
1056 INVOKE_PLAYER (BIRTH, op->contr); 1056 INVOKE_PLAYER (BIRTH, op->contr);
1057 INVOKE_PLAYER (LOGIN, op->contr); 1057 INVOKE_PLAYER (LOGIN, op->contr);
1058 1058
1059 op->contr->state = ST_PLAYING; 1059 op->contr->ns->state = ST_PLAYING;
1060 1060
1061 if (op->msg) 1061 if (op->msg)
1062 op->msg = NULL; 1062 op->msg = NULL;
1063 1063
1064 /* 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
1135 op->stats.grace = 0; 1135 op->stats.grace = 0;
1136 1136
1137 if (op->msg) 1137 if (op->msg)
1138 new_draw_info (NDI_BLUE, 0, op, op->msg); 1138 new_draw_info (NDI_BLUE, 0, op, op->msg);
1139 1139
1140 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");
1141 return 0; 1141 return 0;
1142} 1142}
1143 1143
1144int 1144int
1145key_confirm_quit (object *op, char key) 1145key_confirm_quit (object *op, char key)
1146{ 1146{
1147 char buf[MAX_BUF]; 1147 char buf[MAX_BUF];
1148 1148
1149 if (key != 'y' && key != 'Y' && key != 'q' && key != 'Q') 1149 if (key != 'y' && key != 'Y' && key != 'q' && key != 'Q')
1150 { 1150 {
1151 op->contr->state = ST_PLAYING; 1151 op->contr->ns->state = ST_PLAYING;
1152 new_draw_info (NDI_UNIQUE, 0, op, "OK, continuing to play."); 1152 new_draw_info (NDI_UNIQUE, 0, op, "OK, continuing to play.");
1153 return 1; 1153 return 1;
1154 } 1154 }
1155 1155
1156 INVOKE_PLAYER (LOGOUT, op->contr); 1156 INVOKE_PLAYER (LOGOUT, op->contr);
2554 /* 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
2555 * the players time has been increased when doericserver has been 2555 * the players time has been increased when doericserver has been
2556 * called, so we recheck it here. 2556 * called, so we recheck it here.
2557 */ 2557 */
2558 //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
2559 for (int rep = 8; --rep && op->contr->socket->handle_command (); ) 2559 for (int rep = 8; --rep && op->contr->ns->handle_command (); )
2560 ; 2560 ;
2561 2561
2562 if (op->speed_left < 0) 2562 if (op->speed_left < 0)
2563 return 0; 2563 return 0;
2564 2564
2711 for (i = 0; i < NUM_OUTPUT_BUFS; i++) 2711 for (i = 0; i < NUM_OUTPUT_BUFS; i++)
2712 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)
2713 flush_output_element (op, &op->contr->outputs[i]); 2713 flush_output_element (op, &op->contr->outputs[i]);
2714 } 2714 }
2715 2715
2716 if (op->contr->state == ST_PLAYING) 2716 if (op->contr->ns->state == ST_PLAYING)
2717 { 2717 {
2718 2718
2719 /* these next three if clauses make it possible to SLOW DOWN 2719 /* these next three if clauses make it possible to SLOW DOWN
2720 hp/grace/spellpoint regeneration. */ 2720 hp/grace/spellpoint regeneration. */
2721 if (op->contr->gen_hp >= 0) 2721 if (op->contr->gen_hp >= 0)
2863 if (!QUERY_FLAG (op, FLAG_WIZ)) 2863 if (!QUERY_FLAG (op, FLAG_WIZ))
2864 op->stats.food--; 2864 op->stats.food--;
2865 } 2865 }
2866 } 2866 }
2867 2867
2868 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)
2869 { 2869 {
2870 object *tmp, *flesh = NULL; 2870 object *tmp, *flesh = NULL;
2871 2871
2872 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 2872 for (tmp = op->inv; tmp != NULL; tmp = tmp->below)
2873 { 2873 {
2895 } /* end if player is starving */ 2895 } /* end if player is starving */
2896 2896
2897 while (op->stats.food < 0 && op->stats.hp > 0) 2897 while (op->stats.food < 0 && op->stats.hp > 0)
2898 op->stats.food++, op->stats.hp--; 2898 op->stats.food++, op->stats.hp--;
2899 2899
2900 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))
2901 kill_player (op); 2901 kill_player (op);
2902} 2902}
2903 2903
2904 2904
2905 2905
3384fix_luck (void) 3384fix_luck (void)
3385{ 3385{
3386 player *pl; 3386 player *pl;
3387 3387
3388 for (pl = first_player; pl != NULL; pl = pl->next) 3388 for (pl = first_player; pl != NULL; pl = pl->next)
3389 if (!pl->ob->contr->state) 3389 if (!pl->ob->contr->ns->state)
3390 change_luck (pl->ob, 0); 3390 change_luck (pl->ob, 0);
3391} 3391}
3392 3392
3393 3393
3394/* cast_dust() - handles op throwing objects of type 'DUST'. 3394/* cast_dust() - handles op throwing objects of type 'DUST'.
3636 3636
3637 /* only the viewable area the player sees is updated by LOS 3637 /* only the viewable area the player sees is updated by LOS
3638 * 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
3639 * for any meaningful values. 3639 * for any meaningful values.
3640 */ 3640 */
3641 if (FABS (dx) <= (pl->contr->socket->mapx / 2) && 3641 if (FABS (dx) <= (pl->contr->ns->mapx / 2) &&
3642 FABS (dy) <= (pl->contr->socket->mapy / 2) && 3642 FABS (dy) <= (pl->contr->ns->mapy / 2) &&
3643 !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)])
3644 return 1; 3644 return 1;
3645 op = op->more; 3645 op = op->more;
3646 } 3646 }
3647 return 0; 3647 return 0;
3648} 3648}
3834 { 3834 {
3835 /* forces in the treasurelist can alter the player's stats */ 3835 /* forces in the treasurelist can alter the player's stats */
3836 object *skin; 3836 object *skin;
3837 3837
3838 /* first get the dragon skin force */ 3838 /* first get the dragon skin force */
3839 shstr_cmp dragon_skin_force ("dragon_skin_force");
3839 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
3840 if (skin == NULL) 3843 if (!skin)
3841 return; 3844 return;
3842 3845
3843 /* adding new spellpath attunements */ 3846 /* adding new spellpath attunements */
3844 if (item->path_attuned > 0 && !(skin->path_attuned & item->path_attuned)) 3847 if (item->path_attuned > 0 && !(skin->path_attuned & item->path_attuned))
3845 { 3848 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines