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.158 by root, Mon Aug 13 15:46:45 2007 UTC vs.
Revision 1.166 by root, Thu Aug 30 05:16:10 2007 UTC

185 maplevel = ob->map->path; 185 maplevel = ob->map->path;
186 186
187 ob->remove (); 187 ob->remove ();
188 ob->map = 0; 188 ob->map = 0;
189 party = 0; 189 party = 0;
190 enemy = 0; // sometimes keeps an extra refcount on itself
190 191
191 combat_ob = ranged_ob = 0; //TODO, should be special marker, non-refcounted, not this 192 combat_ob = ranged_ob = 0; //TODO, should be special marker, non-refcounted, not this
192 193
193 players.erase (this); 194 players.erase (this);
194} 195}
284} 285}
285 286
286void 287void
287player::disconnect () 288player::disconnect ()
288{ 289{
290 if (ob)
291 {
292 ob->close_container (); //TODO: client-specific
293 ob->drop_unpaid_items ();
294 }
295
289 if (ns) 296 if (ns)
290 { 297 {
291 if (active) 298 if (active)
292 INVOKE_PLAYER (LOGOUT, this, ARG_INT (0)); 299 INVOKE_PLAYER (LOGOUT, this, ARG_INT (0));
293 300
294 INVOKE_PLAYER (DISCONNECT, this); 301 INVOKE_PLAYER (DISCONNECT, this);
295 302
296 ns->reset_stats (); 303 ns->reset_stats ();
297 ns->pl = 0; 304 ns->pl = 0;
298 ns = 0; 305 ns = 0;
299 }
300
301 if (ob)
302 {
303 ob->close_container (); //TODO: client-specific
304 ob->drop_unpaid_items ();
305 } 306 }
306 307
307 observe = ob; 308 observe = ob;
308 309
309 deactivate (); 310 deactivate ();
425 unsigned lastdist; 426 unsigned lastdist;
426 rv_vector rv; 427 rv_vector rv;
427 428
428 for (ol = first_friendly_object, lastdist = 1000; ol; ol = ol->next) 429 for (ol = first_friendly_object, lastdist = 1000; ol; ol = ol->next)
429 { 430 {
430 /* We should not find free objects on this friendly list, but it
431 * does periodically happen. Given that, lets deal with it.
432 * While unlikely, it is possible the next object on the friendly
433 * list is also free, so encapsulate this in a while loop.
434 */
435 while (QUERY_FLAG (ol->ob, FLAG_FREED) || !QUERY_FLAG (ol->ob, FLAG_FRIENDLY))
436 {
437 object *tmp = ol->ob;
438
439 /* Can't do much more other than log the fact, because the object
440 * itself will have been cleared.
441 */
442 LOG (llevDebug, "get_nearest_player: Found free/non friendly object '%s' on friendly list\n",
443 tmp->debug_desc ());
444 ol = ol->next;
445 remove_friendly_object (tmp);
446 if (!ol)
447 return op;
448 }
449
450 /* Remove special check for player from this. First, it looks to cause
451 * some crashes (ol->ob->contr not set properly?), but secondly, a more
452 * complicated method of state checking would be needed in any case -
453 * as it was, a clever player could type quit, and the function would
454 * skip them over while waiting for confirmation. Remove
455 * on_same_map check, as can_detect_enemy also does this
456 */
457 if (!can_detect_enemy (mon, ol->ob, &rv)) 431 if (!can_detect_enemy (mon, ol->ob, &rv))
458 continue; 432 continue;
459 433
460 if (lastdist > rv.distance) 434 if (lastdist > rv.distance)
461 { 435 {
2446 { 2420 {
2447 gen_grace = op->stats.maxgrace; 2421 gen_grace = op->stats.maxgrace;
2448 rate_grace -= rate_grace / 2 * op->contr->gen_grace; 2422 rate_grace -= rate_grace / 2 * op->contr->gen_grace;
2449 } 2423 }
2450 2424
2451 /* Regenerate Spell Points */
2452 if (!op->contr->golem && --op->last_sp < 0)
2453 {
2454 gen_sp = gen_sp * 10 / (op->contr->gen_sp_armour < 10 ? 10 : op->contr->gen_sp_armour);
2455 if (op->stats.sp < op->stats.maxsp)
2456 {
2457 op->stats.sp++;
2458 /* dms do not consume food */
2459 if (!QUERY_FLAG (op, FLAG_WIZ))
2460 {
2461 op->stats.food--;
2462 if (op->contr->digestion < 0)
2463 op->stats.food += op->contr->digestion;
2464 else if (op->contr->digestion > 0 && random_roll (0, op->contr->digestion, op, PREFER_HIGH))
2465 op->stats.food = last_food;
2466 }
2467 }
2468
2469 if (max_sp > 1)
2470 {
2471 over_sp = (gen_sp + 10) / rate_sp;
2472 if (over_sp > 0)
2473 {
2474 if (op->stats.sp < op->stats.maxsp)
2475 {
2476 op->stats.sp += over_sp > max_sp ? max_sp : over_sp;
2477
2478 if (random_roll (0, rate_sp - 1, op, PREFER_LOW) > ((gen_sp + 10) % rate_sp))
2479 op->stats.sp--;
2480
2481 if (op->stats.sp > op->stats.maxsp)
2482 op->stats.sp = op->stats.maxsp;
2483 }
2484 op->last_sp = 0;
2485 }
2486 else
2487 op->last_sp = rate_sp / (gen_sp < 20 ? 30 : gen_sp + 10);
2488 }
2489 else
2490 op->last_sp = rate_sp / (gen_sp < 20 ? 30 : gen_sp + 10);
2491 }
2492
2493 /* Regenerate Grace */ 2425 /* Regenerate Grace */
2494 /* I altered this a little - maximum grace is ony achieved through prayer -b.t. */ 2426 /* I altered this a little - maximum grace is ony achieved through prayer -b.t. */
2495 if (--op->last_grace < 0) 2427 if (--op->last_grace < 0)
2496 { 2428 {
2497 if (op->stats.grace < op->stats.maxgrace / 2) 2429 if (op->stats.grace < op->stats.maxgrace / 2)
2516 op->last_grace = rate_grace / (gen_grace < 20 ? 30 : gen_grace + 10); 2448 op->last_grace = rate_grace / (gen_grace < 20 ? 30 : gen_grace + 10);
2517 } 2449 }
2518 /* wearing stuff doesn't detract from grace generation. */ 2450 /* wearing stuff doesn't detract from grace generation. */
2519 } 2451 }
2520 2452
2453 if (op->stats.food > 0)
2454 {
2521 /* Regenerate Hit Points */ 2455 /* Regenerate Spell Points */
2522 if (--op->last_heal < 0) 2456 if (!op->contr->golem && --op->last_sp < 0)
2523 {
2524 if (op->stats.hp < op->stats.maxhp)
2525 { 2457 {
2526 op->stats.hp++; 2458 gen_sp = gen_sp * 10 / (op->contr->gen_sp_armour < 10 ? 10 : op->contr->gen_sp_armour);
2527 /* dms do not consume food */ 2459
2528 if (!QUERY_FLAG (op, FLAG_WIZ)) 2460 if (op->stats.sp < op->stats.maxsp)
2529 { 2461 {
2462 op->stats.sp++;
2463
2464 /* dms do not consume food */
2465 if (!QUERY_FLAG (op, FLAG_WIZ))
2466 {
2530 op->stats.food--; 2467 op->stats.food--;
2468
2531 if (op->contr->digestion < 0) 2469 if (op->contr->digestion < 0)
2532 op->stats.food += op->contr->digestion; 2470 op->stats.food += op->contr->digestion;
2533 else if (op->contr->digestion > 0 && random_roll (0, op->contr->digestion, op, PREFER_HIGH)) 2471 else if (op->contr->digestion > 0 && random_roll (0, op->contr->digestion, op, PREFER_HIGH))
2534 op->stats.food = last_food; 2472 op->stats.food = last_food;
2473 }
2535 } 2474 }
2536 }
2537 2475
2538 if (max_hp > 1) 2476 if (max_sp > 1)
2539 {
2540 over_hp = (gen_hp < 20 ? 30 : gen_hp + 10) / rate_hp;
2541 if (over_hp > 0)
2542 { 2477 {
2543 op->stats.sp += over_hp + (RANDOM () % rate_hp > ((gen_hp < 20 ? 30 : gen_hp + 10) % rate_hp)) ? -1 : 0; 2478 over_sp = (gen_sp + 10) / rate_sp;
2479 if (over_sp > 0)
2480 {
2481 if (op->stats.sp < op->stats.maxsp)
2482 {
2483 op->stats.sp += over_sp > max_sp ? max_sp : over_sp;
2484
2485 if (random_roll (0, rate_sp - 1, op, PREFER_LOW) > ((gen_sp + 10) % rate_sp))
2486 op->stats.sp--;
2487
2488 if (op->stats.sp > op->stats.maxsp)
2489 op->stats.sp = op->stats.maxsp;
2490 }
2491
2544 op->last_heal = 0; 2492 op->last_sp = 0;
2493 }
2494 else
2495 op->last_sp = rate_sp / (gen_sp < 20 ? 30 : gen_sp + 10);
2545 } 2496 }
2546 else 2497 else
2498 op->last_sp = rate_sp / (gen_sp < 20 ? 30 : gen_sp + 10);
2499 }
2500
2501 /* Regenerate Hit Points */
2502 if (--op->last_heal < 0)
2503 {
2504 if (op->stats.hp < op->stats.maxhp)
2547 { 2505 {
2548 op->last_heal = rate_hp / (gen_hp < 20 ? 30 : gen_hp + 10); 2506 op->stats.hp++;
2507
2508 /* dms do not consume food */
2509 if (!QUERY_FLAG (op, FLAG_WIZ))
2510 {
2511 op->stats.food--;
2512
2513 if (op->contr->digestion < 0)
2514 op->stats.food += op->contr->digestion;
2515 else if (op->contr->digestion > 0 && random_roll (0, op->contr->digestion, op, PREFER_HIGH))
2516 op->stats.food = last_food;
2517 }
2549 } 2518 }
2519
2520 if (max_hp > 1)
2521 {
2522 over_hp = (gen_hp < 20 ? 30 : gen_hp + 10) / rate_hp;
2523
2524 if (over_hp > 0)
2525 {
2526 op->stats.sp += over_hp + (RANDOM () % rate_hp > ((gen_hp < 20 ? 30 : gen_hp + 10) % rate_hp)) ? -1 : 0;
2527 op->last_heal = 0;
2528 }
2529 else
2530 op->last_heal = rate_hp / (gen_hp < 20 ? 30 : gen_hp + 10);
2550 } 2531 }
2551 else 2532 else
2552 {
2553 op->last_heal = rate_hp / (gen_hp < 20 ? 30 : gen_hp + 10); 2533 op->last_heal = rate_hp / (gen_hp < 20 ? 30 : gen_hp + 10);
2554 } 2534 }
2555 } 2535 }
2556 2536
2557 /* Digestion */ 2537 /* Digestion */
2558 if (--op->last_eat < 0) 2538 if (--op->last_eat < 0)
2595 new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); 2575 new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food.");
2596 manual_apply (op, flesh, 0); 2576 manual_apply (op, flesh, 0);
2597 } 2577 }
2598 } 2578 }
2599 2579
2600 while (op->stats.food < 0 && op->stats.hp >= 0) 2580 if (op->stats.food < 0)
2601 op->stats.food++, op->stats.hp--; 2581 {
2582 op->stats.hp += op->stats.food;
2583 op->stats.food = 0;
2584 }
2602 2585
2603 if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) 2586 if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ))
2604 kill_player (op); 2587 kill_player (op);
2605 } 2588 }
2606} 2589}
2653 { 2636 {
2654 tmp->destroy (); 2637 tmp->destroy ();
2655 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 2638 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
2656 } 2639 }
2657 2640
2658 cure_disease (op, 0); /* remove any disease */ 2641 cure_disease (op, 0, 0); /* remove any disease */
2659 op->stats.hp = op->stats.maxhp; 2642 op->stats.hp = op->stats.maxhp;
2660 if (op->stats.food <= 0) 2643 if (op->stats.food <= 0)
2661 op->stats.food = 999; 2644 op->stats.food = 999;
2662 2645
2663 /* create a bodypart-trophy to make the winner happy */ 2646 /* create a bodypart-trophy to make the winner happy */
2863 { 2846 {
2864 tmp->destroy (); 2847 tmp->destroy ();
2865 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 2848 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
2866 } 2849 }
2867 2850
2868 cure_disease (op, 0); /* remove any disease */ 2851 cure_disease (op, 0, 0); /* remove any disease */
2869 2852
2870 /*add_exp(op, (op->stats.exp * -0.20)); */ 2853 /*add_exp(op, (op->stats.exp * -0.20)); */
2871 apply_death_exp_penalty (op); 2854 apply_death_exp_penalty (op);
2872 if (op->stats.food < 100) 2855 if (op->stats.food < 100)
2873 op->stats.food = 900; 2856 op->stats.food = 900;
3027void 3010void
3028make_visible (object *op) 3011make_visible (object *op)
3029{ 3012{
3030 op->hide = 0; 3013 op->hide = 0;
3031 op->invisible = 0; 3014 op->invisible = 0;
3015
3032 if (op->type == PLAYER) 3016 if (op->type == PLAYER)
3033 { 3017 {
3034 op->contr->tmp_invis = 0; 3018 op->contr->tmp_invis = 0;
3035 op->contr->invis_race = 0; 3019 op->contr->invis_race = 0;
3036 } 3020 }
3049 3033
3050/* look at the surrounding terrain to determine 3034/* look at the surrounding terrain to determine
3051 * the hideability of this object. Positive levels 3035 * the hideability of this object. Positive levels
3052 * indicate greater hideability. 3036 * indicate greater hideability.
3053 */ 3037 */
3054
3055int 3038int
3056hideability (object *ob) 3039hideability (object *ob)
3057{ 3040{
3058 int i, level = 0, mflag; 3041 int i, level = 0, mflag;
3059 sint16 x, y; 3042 sint16 x, y;
3184 * object op. This function works fine for monsters, 3167 * object op. This function works fine for monsters,
3185 * but we dont worry if the object isnt the top one in 3168 * but we dont worry if the object isnt the top one in
3186 * a pile (say a coin under a table would return "viewable" 3169 * a pile (say a coin under a table would return "viewable"
3187 * by this routine). Another question, should we be 3170 * by this routine). Another question, should we be
3188 * concerned with the direction the player is looking 3171 * concerned with the direction the player is looking
3189 * in? Realistically, most of use cant see stuff behind 3172 * in? Realistically, most of us can't see stuff behind
3190 * our backs...on the other hand, does the "facing" direction 3173 * our backs...on the other hand, does the "facing" direction
3191 * imply the way your head, or body is facing? Its possible 3174 * imply the way your head, or body is facing? It's possible
3192 * for them to differ. Sigh, this fctn could get a bit more complex. 3175 * for them to differ. Sigh, this fctn could get a bit more complex.
3193 * -b.t. 3176 * -b.t.
3194 * This function is now map tiling safe. 3177 * This function is now map tiling safe.
3195 */ 3178 */
3196
3197int 3179int
3198player_can_view (object *pl, object *op) 3180player_can_view (object *pl, object *op)
3199{ 3181{
3200 rv_vector rv; 3182 rv_vector rv;
3201 int dx, dy; 3183 int dx, dy;
3213 3195
3214 get_rangevector (pl, op, &rv, 0x1); 3196 get_rangevector (pl, op, &rv, 0x1);
3215 3197
3216 /* starting with the 'head' part, lets loop 3198 /* starting with the 'head' part, lets loop
3217 * through the object and find if it has any 3199 * through the object and find if it has any
3218 * part that is in the los array but isnt on 3200 * part that is in the los array but isn't on
3219 * a blocked los square. 3201 * a blocked los square.
3220 * we use the archetype to figure out offsets. 3202 * we use the archetype to figure out offsets.
3221 */ 3203 */
3222 while (op) 3204 while (op)
3223 { 3205 {
3226 3208
3227 /* only the viewable area the player sees is updated by LOS 3209 /* only the viewable area the player sees is updated by LOS
3228 * code, so we need to restrict ourselves to that range of values 3210 * code, so we need to restrict ourselves to that range of values
3229 * for any meaningful values. 3211 * for any meaningful values.
3230 */ 3212 */
3231 if (FABS (dx) <= (pl->contr->ns->mapx / 2) && 3213 if (abs (dx) <= (pl->contr->ns->mapx / 2) &&
3232 FABS (dy) <= (pl->contr->ns->mapy / 2) && 3214 abs (dy) <= (pl->contr->ns->mapy / 2) &&
3233 !pl->contr->blocked_los[dx + (pl->contr->ns->mapx / 2)][dy + (pl->contr->ns->mapy / 2)]) 3215 !pl->contr->blocked_los[dx + (pl->contr->ns->mapx / 2)][dy + (pl->contr->ns->mapy / 2)])
3234 return 1; 3216 return 1;
3217
3235 op = op->more; 3218 op = op->more;
3236 } 3219 }
3220
3237 return 0; 3221 return 0;
3238} 3222}
3239 3223
3240/* routine for both players and monsters. We call this when 3224/* routine for both players and monsters. We call this when
3241 * there is a possibility for our action distrubing our hiding 3225 * there is a possibility for our action distrubing our hiding
3244 * return 0. 3228 * return 0.
3245 */ 3229 */
3246int 3230int
3247action_makes_visible (object *op) 3231action_makes_visible (object *op)
3248{ 3232{
3249
3250 if (op->invisible && QUERY_FLAG (op, FLAG_ALIVE)) 3233 if (op->invisible && QUERY_FLAG (op, FLAG_ALIVE))
3251 { 3234 {
3252 if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) 3235 if (QUERY_FLAG (op, FLAG_MAKE_INVIS))
3253 return 0; 3236 return 0;
3254 3237
3260 { 3243 {
3261 new_draw_info_format (NDI_UNIQUE, 0, op, "You become %s!", op->hide ? "unhidden" : "visible"); 3244 new_draw_info_format (NDI_UNIQUE, 0, op, "You become %s!", op->hide ? "unhidden" : "visible");
3262 return 1; 3245 return 1;
3263 } 3246 }
3264 } 3247 }
3248
3265 return 0; 3249 return 0;
3266} 3250}
3267 3251
3268/* op_on_battleground - checks if the given object op (usually 3252/* op_on_battleground - checks if the given object op (usually
3269 * a player) is standing on a valid battleground-tile, 3253 * a player) is standing on a valid battleground-tile,
3274 * Default is to do the same as before, so only people wanting to have different points need worry about this 3258 * Default is to do the same as before, so only people wanting to have different points need worry about this
3275 */ 3259 */
3276int 3260int
3277op_on_battleground (object *op, int *x, int *y) 3261op_on_battleground (object *op, int *x, int *y)
3278{ 3262{
3279 object *tmp;
3280
3281 /* A battleground-tile needs the following attributes to be valid: 3263 /* A battleground-tile needs the following attributes to be valid:
3282 * is_floor 1 (has to be the FIRST floor beneath the player's feet), 3264 * is_floor 1 (has to be the FIRST floor beneath the player's feet),
3283 * name="battleground", no_pick 1, type=58 (type BATTLEGROUND) 3265 * name="battleground", no_pick 1, type=58 (type BATTLEGROUND)
3284 * and the exit-coordinates sp/hp must both be > 0. 3266 * and the exit-coordinates sp/hp must both be > 0.
3285 * => The intention here is to prevent abuse of the battleground- 3267 * => The intention here is to prevent abuse of the battleground-
3286 * feature (like pickable or hidden battleground tiles). */ 3268 * feature (like pickable or hidden battleground tiles). */
3287 for (tmp = op->below; tmp != NULL; tmp = tmp->below) 3269 for (object *tmp = op->below; tmp; tmp = tmp->below)
3288 { 3270 {
3289 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) 3271 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR))
3290 { 3272 {
3291 if (QUERY_FLAG (tmp, FLAG_NO_PICK) && 3273 if (QUERY_FLAG (tmp, FLAG_NO_PICK)
3292 strcmp (tmp->name, "battleground") == 0 && tmp->type == BATTLEGROUND && EXIT_X (tmp) && EXIT_Y (tmp)) 3274 && tmp->type == BATTLEGROUND
3275 && tmp->name == shstr_battleground
3276 && EXIT_X (tmp) && EXIT_Y (tmp))
3293 { 3277 {
3294 /*before we assign the exit, check if this is a teambattle */ 3278 /* before we assign the exit, check if this is a teambattle */
3295 if (EXIT_ALT_X (tmp) && EXIT_ALT_Y (tmp) && EXIT_PATH (tmp)) 3279 if (EXIT_ALT_X (tmp) && EXIT_ALT_Y (tmp) && EXIT_PATH (tmp))
3296 { 3280 {
3297 object *invtmp;
3298
3299 for (invtmp = op->inv; invtmp != NULL; invtmp = invtmp->below) 3281 for (object *invtmp = op->inv; invtmp; invtmp = invtmp->below)
3300 { 3282 {
3301 if (invtmp->type == FORCE && invtmp->slaying && !strcmp (EXIT_PATH (tmp), invtmp->slaying)) 3283 if (invtmp->type == FORCE && invtmp->slaying && tmp->slaying == invtmp->slaying)
3302 { 3284 {
3303 if (x != NULL && y != NULL) 3285 if (x && y)
3304 *x = EXIT_ALT_X (tmp), *y = EXIT_ALT_Y (tmp); 3286 *x = EXIT_ALT_X (tmp), *y = EXIT_ALT_Y (tmp);
3287
3305 return 1; 3288 return 1;
3306 } 3289 }
3307 } 3290 }
3308 } 3291 }
3292
3309 if (x != NULL && y != NULL) 3293 if (x && y)
3310 *x = EXIT_X (tmp), *y = EXIT_Y (tmp); 3294 *x = EXIT_X (tmp), *y = EXIT_Y (tmp);
3295
3311 return 1; 3296 return 1;
3312 } 3297 }
3313 } 3298 }
3314 } 3299 }
3300
3315 /* If we got here, did not find a battleground */ 3301 /* If we got here, did not find a battleground */
3316 return 0; 3302 return 0;
3317} 3303}
3318 3304
3319/* 3305/*
3335 char buf[MAX_BUF]; /* tmp. string buffer */ 3321 char buf[MAX_BUF]; /* tmp. string buffer */
3336 int i = 0, j = 0; 3322 int i = 0, j = 0;
3337 3323
3338 /* get the appropriate treasurelist */ 3324 /* get the appropriate treasurelist */
3339 if (atnr == ATNR_FIRE) 3325 if (atnr == ATNR_FIRE)
3340 trlist = treasurelist::find ("dragon_ability_fire"); 3326 trlist = treasurelist::find (shstr_dragon_ability_fire);
3341 else if (atnr == ATNR_COLD) 3327 else if (atnr == ATNR_COLD)
3342 trlist = treasurelist::find ("dragon_ability_cold"); 3328 trlist = treasurelist::find (shstr_dragon_ability_cold);
3343 else if (atnr == ATNR_ELECTRICITY) 3329 else if (atnr == ATNR_ELECTRICITY)
3344 trlist = treasurelist::find ("dragon_ability_elec"); 3330 trlist = treasurelist::find (shstr_dragon_ability_elec);
3345 else if (atnr == ATNR_POISON) 3331 else if (atnr == ATNR_POISON)
3346 trlist = treasurelist::find ("dragon_ability_poison"); 3332 trlist = treasurelist::find (shstr_dragon_ability_poison);
3347 3333
3348 if (trlist == NULL || who->type != PLAYER) 3334 if (trlist == NULL || who->type != PLAYER)
3349 return; 3335 return;
3350 3336
3351 for (i = 0, tr = trlist->items; tr != NULL && i < level - 1; tr = tr->next, i++); 3337 for (i = 0, tr = trlist->items; tr != NULL && i < level - 1; tr = tr->next, i++);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines