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.94 by root, Mon Jan 8 14:29:05 2007 UTC vs.
Revision 1.99 by root, Thu Jan 18 19:42:10 2007 UTC

194 return; 194 return;
195 195
196 terminate_all_pets (ob); 196 terminate_all_pets (ob);
197 remove_friendly_object (ob); 197 remove_friendly_object (ob);
198 ob->deactivate_recursive (); 198 ob->deactivate_recursive ();
199 maplevel = ob->map->path;
199 ob->remove (); 200 ob->remove ();
200 ob->map = 0; 201 ob->map = 0;
201 202
202 // for weird reasons, this is often "ob", keeping a circular reference 203 // for weird reasons, this is often "ob", keeping a circular reference
203 ranges [range_skill] = 0; 204 ranges [range_skill] = 0;
211player::connect (client *ns) 212player::connect (client *ns)
212{ 213{
213 this->ns = ns; 214 this->ns = ns;
214 ns->pl = this; 215 ns->pl = this;
215 216
217 run_on = 0;
218 fire_on = 0;
219 ob->container = 0; //TODO: client-specific
220
216 ns->update_look = 0; 221 ns->update_look = 0;
217 ns->look_position = 0; 222 ns->look_position = 0;
218 223
219 clear_los (ob); 224 clear_los (ob);
220 225
221//TODO: must move into client 226 ns->reset_stats ();
222/* we need to clear these to -1 and not zero - otherwise,
223 * if a player quits and starts a new character, we wont
224 * send new values to the client, as things like exp start
225 * at zero.
226 */
227for (int i = 0; i < NUM_SKILLS; i++)
228 last_skill_exp[i] = -1;
229
230for (int i = 0; i < NROFATTACKS; i++)
231 last_resist[i] = -1;
232
233last_weapon_sp = -1;
234last_level = -1;
235last_stats.exp = -1;
236last_weight = (uint32) - 1;
237last_flags = 0;
238last_weight = 0;
239last_weight_limit = 0;
240last_path_attuned = 0;
241last_path_repelled = 0;
242last_path_denied = 0;
243last_speed = 0;
244run_on = 0;
245fire_on = 0;
246memset (&last_stats, 0, sizeof (living)); //TODO dirty
247 227
248 /* make sure he's a player -- needed because of class change. */ 228 /* make sure he's a player -- needed because of class change. */
249 ob->type = PLAYER; // we are paranoid 229 ob->type = PLAYER; // we are paranoid
250 ob->race = ob->arch->clone.race; 230 ob->race = ob->arch->clone.race;
251 231
315 if (active) 295 if (active)
316 INVOKE_PLAYER (LOGOUT, this, ARG_INT (0)); 296 INVOKE_PLAYER (LOGOUT, this, ARG_INT (0));
317 297
318 INVOKE_PLAYER (DISCONNECT, this); 298 INVOKE_PLAYER (DISCONNECT, this);
319 299
300 ns->reset_stats ();
320 ns->pl = 0; 301 ns->pl = 0;
321 this->ns = 0; 302 this->ns = 0;
322 } 303 }
323 304
305 ob->container = 0; //TODO: client-specific
324 deactivate (); 306 deactivate ();
325} 307}
326 308
327// the need for this function can be explained 309// the need for this function can be explained
328// by load_object not returning the object 310// by load_object not returning the object
774roll_stat (void) 756roll_stat (void)
775{ 757{
776 int a[4], i, j, k; 758 int a[4], i, j, k;
777 759
778 for (i = 0; i < 4; i++) 760 for (i = 0; i < 4; i++)
779 a[i] = (int) RANDOM () % 6 + 1; 761 a[i] = (int) rndm (6) + 1;
780 762
781 for (i = 0, j = 0, k = 7; i < 4; i++) 763 for (i = 0, j = 0, k = 7; i < 4; i++)
782 if (a[i] < k) 764 if (a[i] < k)
783 k = a[i], j = i; 765 k = a[i], j = i;
784 766
914 * to save here. 896 * to save here.
915 */ 897 */
916 sprintf (buf, "%s/%s/%s", settings.localdir, settings.playerdir, &op->name); 898 sprintf (buf, "%s/%s/%s", settings.localdir, settings.playerdir, &op->name);
917 make_path_to_file (buf); 899 make_path_to_file (buf);
918 900
919#ifdef AUTOSAVE
920 op->contr->last_save_tick = pticks;
921#endif
922 start_info (op); 901 start_info (op);
923 CLEAR_FLAG (op, FLAG_WIZ); 902 CLEAR_FLAG (op, FLAG_WIZ);
924 give_initial_items (op, op->randomitems); 903 give_initial_items (op, op->randomitems);
925 link_player_skills (op); 904 link_player_skills (op);
926 esrv_send_inventory (op, op); 905 esrv_send_inventory (op, op);
2232 return 0; 2211 return 0;
2233 } 2212 }
2234 2213
2235 /* peterm: added following line */ 2214 /* peterm: added following line */
2236 if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) 2215 if (QUERY_FLAG (op, FLAG_CONFUSED) && dir)
2237 dir = absdir (dir + RANDOM () % 3 + RANDOM () % 3 - 2); 2216 dir = absdir (dir + rndm (3) + rndm (3) - 2);
2238 2217
2239 op->facing = dir; 2218 op->facing = dir;
2240 2219
2241 if (op->hide) 2220 if (op->hide)
2242 do_hidden_move (op); 2221 do_hidden_move (op);
3003 tmp->x = op->x, tmp->y = op->y; 2982 tmp->x = op->x, tmp->y = op->y;
3004 if (tmp->type == CONTAINER) 2983 if (tmp->type == CONTAINER)
3005 { /* empty container to ground */ 2984 { /* empty container to ground */
3006 loot_object (tmp); 2985 loot_object (tmp);
3007 } 2986 }
3008 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) 2987 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(rndm (3))))
3009 { 2988 {
3010 if (tmp->nrof > 1) 2989 if (tmp->nrof > 1)
3011 { 2990 {
3012 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); 2991 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1));
3013 tmp2->destroy (); 2992 tmp2->destroy ();
3547 * not readied. 3526 * not readied.
3548 */ 3527 */
3549void 3528void
3550player_unready_range_ob (player *pl, object *ob) 3529player_unready_range_ob (player *pl, object *ob)
3551{ 3530{
3552 rangetype i;
3553
3554 for (i = (rangetype) 0; i < range_size; i = (rangetype) ((int) i + 1)) 3531 for (rangetype i = (rangetype) 0; i < range_size; i = (rangetype) ((int) i + 1))
3555 {
3556 if (pl->ranges[i] == ob) 3532 if (pl->ranges[i] == ob)
3557 { 3533 {
3558 pl->ranges[i] = NULL; 3534 pl->ranges[i] = 0;
3559 if (pl->shoottype == i) 3535 if (pl->shoottype == i)
3560 {
3561 pl->shoottype = range_none; 3536 pl->shoottype = range_none;
3562 }
3563 } 3537 }
3564 }
3565} 3538}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines