ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/main.C
(Generate patch)

Comparing deliantra/server/server/main.C (file contents):
Revision 1.100 by root, Mon Apr 30 04:25:30 2007 UTC vs.
Revision 1.105 by root, Fri May 18 15:05:09 2007 UTC

244 pl->refcnt_chk (); 244 pl->refcnt_chk ();
245 245
246 if (!pl->ob || !pl->ns || !pl->ob->active) 246 if (!pl->ob || !pl->ns || !pl->ob->active)
247 continue; 247 continue;
248 248
249 if (pl->ob->speed_left > 0 && pl->ns) 249 if (pl->ob->speed_left > 0.f && pl->ns)
250 if (handle_newcs_player (pl->ob)) 250 if (handle_newcs_player (pl->ob))
251 flag = 1; 251 flag = 1;
252 252
253 /* If the player is not actively playing, don't make a 253 /* If the player is not actively playing, don't make a
254 * backup save - nothing to save anyway. Plus, the 254 * backup save - nothing to save anyway. Plus, the
261 } /* end of for loop for all the players */ 261 } /* end of for loop for all the players */
262 } /* for flag */ 262 } /* for flag */
263 263
264 for_all_players (pl) 264 for_all_players (pl)
265 { 265 {
266 object *ob = pl->ob;
267
266 if (!pl->ob || !pl->ns || !pl->ob->active) 268 if (!ob || !pl->ns || !ob->active)
267 continue; 269 continue;
268 270
269 if (settings.casting_time) 271 // process_events might steal us one speed slot, so adjust accordingly
270 { 272 if (ob->speed_left > 0.f)
271 if (pl->ob->casting_time > 0) 273 ++ob->speed_left;
272 {
273 pl->ob->casting_time--;
274 pl->ob->start_holding = 1;
275 }
276 274
277 /* set spell_state so we can update the range in stats field */
278 if ((pl->ob->casting_time == 0) && (pl->ob->start_holding == 1))
279 pl->ob->start_holding = 0;
280 }
281
282 do_some_living (pl->ob); 275 do_some_living (ob);
283 } 276 }
284} 277}
285 278
286static void 279static void
287process_players2 () 280process_players2 ()
288{ 281{
289 /* Then check if any players should use weapon-speed instead of speed */ 282 /* Then check if any players should use weapon-speed instead of speed */
290 for_all_players (pl) 283 for_all_players (pl)
291 { 284 {
292 /* The code that did weapon_sp handling here was out of place -
293 * this isn't called until after the player has finished there
294 * actions, and is thus out of place. All we do here is bounds
295 * checking.
296 */
297 if (pl->has_hit) 285 if (pl->has_hit)
298 { 286 {
287 pl->ob->speed_left = min (pl->weapon_sp, pl->ob->speed_left + pl->weapon_sp);
288
299 if (pl->ob->speed_left > pl->weapon_sp) 289 if (pl->ob->speed_left > 0.f)
300 pl->ob->speed_left = pl->weapon_sp;
301
302 /* This needs to be here - if the player is running, we need to
303 * clear this each tick, but new commands are not being received
304 * so execute_newserver_command() is never called
305 */
306 pl->has_hit = 0; 290 pl->has_hit = 0;
307 } 291 }
308 else if (pl->ob->speed_left > pl->ob->speed) 292 else
309 pl->ob->speed_left = pl->ob->speed; 293 pl->ob->speed_left = min (pl->ob->speed, pl->ob->speed_left + pl->ob->speed);
310 } 294 }
311} 295}
312 296
313void 297void
314process_events () 298process_events ()
344 /* Animate the object. Bug or feature that anim_speed 328 /* Animate the object. Bug or feature that anim_speed
345 * is based on ticks, and not the creatures speed? 329 * is based on ticks, and not the creatures speed?
346 */ 330 */
347 if (op->anim_speed && op->last_anim >= op->anim_speed) 331 if (op->anim_speed && op->last_anim >= op->anim_speed)
348 { 332 {
349 animate_object (op, op->type == PLAYER ? op->facing : op->direction); 333 animate_object (op, op->contr ? op->facing : op->direction);
350
351 op->last_anim = 1; 334 op->last_anim = 1;
352 } 335 }
353 else 336 else
354 op->last_anim++; 337 ++op->last_anim;
355 338
356 if (op->speed_left > 0) 339 if (op->speed_left > 0.f)
357 {
358#if 0
359 /* I've seen occasional crashes in move_symptom() with it
360 * crashing because op is removed - add some debugging to
361 * track if it is removed at this point.
362 * This unfortunately is a bit too verbose it seems - not sure
363 * why - I think what happens is a map is freed or something and
364 * some objects get 'lost' - removed never to be reclaimed.
365 * removed objects generally shouldn't exist.
366 */
367 if (QUERY_FLAG (op, FLAG_REMOVED))
368 { 340 {
369 LOG (llevDebug, "process_events: calling process_object with removed object %s\n", op->name ? op->name : "null");
370 }
371#endif
372 --op->speed_left; 341 --op->speed_left;
373 process_object (op); 342 process_object (op);
374 343
375 if (op->destroyed ()) 344 if (op->destroyed ())
376 continue; 345 continue;
377 } 346 }
378 347
379 if (settings.casting_time == TRUE && op->casting_time > 0) 348 if (!op->contr)
380 op->casting_time--; 349 op->speed_left = min (abs (op->speed), op->speed_left + abs (op->speed));
381
382 if (op->speed_left <= 0)
383 op->speed_left += FABS (op->speed);
384 } 350 }
385 351
386 process_players2 (); 352 process_players2 ();
387} 353}
388 354

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines