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.93 by root, Mon Jan 8 14:11: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
351 unapply = unapply_nochoice; 333 unapply = unapply_nochoice;
352 334
353 savebed_map = first_map_path; /* Init. respawn position */ 335 savebed_map = first_map_path; /* Init. respawn position */
354 336
355 gen_sp_armour = 10; 337 gen_sp_armour = 10;
356 last_speed = -1;
357 shoottype = range_none; 338 shoottype = range_none;
358 bowtype = bow_normal; 339 bowtype = bow_normal;
359 petmode = pet_normal; 340 petmode = pet_normal;
360 listening = 10; 341 listening = 10;
361 usekeys = containers; 342 usekeys = containers;
362 last_weapon_sp = -1;
363 peaceful = 1; /* default peaceful */ 343 peaceful = 1; /* default peaceful */
364 do_los = 1; 344 do_los = 1;
365} 345}
366 346
367void 347void
776roll_stat (void) 756roll_stat (void)
777{ 757{
778 int a[4], i, j, k; 758 int a[4], i, j, k;
779 759
780 for (i = 0; i < 4; i++) 760 for (i = 0; i < 4; i++)
781 a[i] = (int) RANDOM () % 6 + 1; 761 a[i] = (int) rndm (6) + 1;
782 762
783 for (i = 0, j = 0, k = 7; i < 4; i++) 763 for (i = 0, j = 0, k = 7; i < 4; i++)
784 if (a[i] < k) 764 if (a[i] < k)
785 k = a[i], j = i; 765 k = a[i], j = i;
786 766
916 * to save here. 896 * to save here.
917 */ 897 */
918 sprintf (buf, "%s/%s/%s", settings.localdir, settings.playerdir, &op->name); 898 sprintf (buf, "%s/%s/%s", settings.localdir, settings.playerdir, &op->name);
919 make_path_to_file (buf); 899 make_path_to_file (buf);
920 900
921#ifdef AUTOSAVE
922 op->contr->last_save_tick = pticks;
923#endif
924 start_info (op); 901 start_info (op);
925 CLEAR_FLAG (op, FLAG_WIZ); 902 CLEAR_FLAG (op, FLAG_WIZ);
926 give_initial_items (op, op->randomitems); 903 give_initial_items (op, op->randomitems);
927 link_player_skills (op); 904 link_player_skills (op);
928 esrv_send_inventory (op, op); 905 esrv_send_inventory (op, op);
2234 return 0; 2211 return 0;
2235 } 2212 }
2236 2213
2237 /* peterm: added following line */ 2214 /* peterm: added following line */
2238 if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) 2215 if (QUERY_FLAG (op, FLAG_CONFUSED) && dir)
2239 dir = absdir (dir + RANDOM () % 3 + RANDOM () % 3 - 2); 2216 dir = absdir (dir + rndm (3) + rndm (3) - 2);
2240 2217
2241 op->facing = dir; 2218 op->facing = dir;
2242 2219
2243 if (op->hide) 2220 if (op->hide)
2244 do_hidden_move (op); 2221 do_hidden_move (op);
3005 tmp->x = op->x, tmp->y = op->y; 2982 tmp->x = op->x, tmp->y = op->y;
3006 if (tmp->type == CONTAINER) 2983 if (tmp->type == CONTAINER)
3007 { /* empty container to ground */ 2984 { /* empty container to ground */
3008 loot_object (tmp); 2985 loot_object (tmp);
3009 } 2986 }
3010 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))))
3011 { 2988 {
3012 if (tmp->nrof > 1) 2989 if (tmp->nrof > 1)
3013 { 2990 {
3014 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); 2991 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1));
3015 tmp2->destroy (); 2992 tmp2->destroy ();
3549 * not readied. 3526 * not readied.
3550 */ 3527 */
3551void 3528void
3552player_unready_range_ob (player *pl, object *ob) 3529player_unready_range_ob (player *pl, object *ob)
3553{ 3530{
3554 rangetype i;
3555
3556 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))
3557 {
3558 if (pl->ranges[i] == ob) 3532 if (pl->ranges[i] == ob)
3559 { 3533 {
3560 pl->ranges[i] = NULL; 3534 pl->ranges[i] = 0;
3561 if (pl->shoottype == i) 3535 if (pl->shoottype == i)
3562 {
3563 pl->shoottype = range_none; 3536 pl->shoottype = range_none;
3564 }
3565 } 3537 }
3566 }
3567} 3538}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines