From d3a963f7bad52406a3420c8ad60c6c0cbfc07214 Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Thu, 27 Nov 2014 19:00:03 -0800 Subject: [PATCH] macro for Object pointer indexing --- main/ai.c | 34 ++++++++-------- main/ai2.c | 88 +++++++++++++++++++++--------------------- main/aipath.c | 78 ++++++++++++++++++------------------- main/cntrlcen.c | 10 ++--- main/collide.c | 60 ++++++++++++++-------------- main/editor/eobject.c | 16 ++++---- main/editor/kgame.c | 4 +- main/editor/med.c | 8 ++-- main/editor/medrobot.c | 2 +- main/editor/segment.c | 2 +- main/escort.c | 28 +++++++------- main/fireball.c | 22 +++++------ main/fuelcen.c | 4 +- main/game.c | 4 +- main/gamecntl.c | 4 +- main/gamerend.c | 2 +- main/gameseg.c | 2 +- main/gameseq.c | 6 +-- main/gauges.c | 2 +- main/laser.c | 46 +++++++++++----------- main/lighting.c | 4 +- main/multi.c | 18 ++++----- main/multibot.c | 30 +++++++------- main/network.c | 4 +- main/newdemo.c | 14 +++---- main/object.c | 62 ++++++++++++++--------------- main/object.h | 1 + main/physics.c | 12 +++--- main/powerup.c | 10 ++--- main/render.c | 6 +-- main/vclip.c | 4 +- main/wall.c | 6 +-- 32 files changed, 297 insertions(+), 296 deletions(-) diff --git a/main/ai.c b/main/ai.c index 128d26f6..5690c6e6 100644 --- a/main/ai.c +++ b/main/ai.c @@ -310,7 +310,7 @@ int Robots_kill_robots_cheat = 0; // -------------------------------------------------------------------------------------------------------------------- void do_ai_frame(object *obj) { - int objnum = obj-Objects; + int objnum = OBJECT_NUMBER(obj); ai_static *aip = &obj->ctype.ai_info; ai_local *ailp = &Ai_local_info[objnum]; fix dist_to_player; @@ -363,12 +363,12 @@ void do_ai_frame(object *obj) return; if (Break_on_object != -1) - if ((obj-Objects) == Break_on_object) + if (OBJECT_NUMBER(obj) == Break_on_object) Int3(); // Contact Mike: This is a debug break #endif - //mprintf((0, "Object %i: behavior = %02x, mode = %i, awareness = %i, time = %7.3f\n", obj-Objects, aip->behavior, ailp->mode, ailp->player_awareness_type, f2fl(ailp->player_awareness_time))); - //mprintf((0, "Object %i: behavior = %02x, mode = %i, awareness = %i, cur=%i, goal=%i\n", obj-Objects, aip->behavior, ailp->mode, ailp->player_awareness_type, aip->CURRENT_STATE, aip->GOAL_STATE)); + //mprintf((0, "Object %i: behavior = %02x, mode = %i, awareness = %i, time = %7.3f\n", OBJECT_NUMBER(obj), aip->behavior, ailp->mode, ailp->player_awareness_type, f2fl(ailp->player_awareness_time))); + //mprintf((0, "Object %i: behavior = %02x, mode = %i, awareness = %i, cur=%i, goal=%i\n", OBJECT_NUMBER(obj), aip->behavior, ailp->mode, ailp->player_awareness_type, aip->CURRENT_STATE, aip->GOAL_STATE)); //Assert((aip->behavior >= MIN_BEHAVIOR) && (aip->behavior <= MAX_BEHAVIOR)); if (!((aip->behavior >= MIN_BEHAVIOR) && (aip->behavior <= MAX_BEHAVIOR))) { @@ -519,7 +519,7 @@ _exit_cheat: attempt_to_resume_path(obj); break; case AIM_FOLLOW_PATH: - // mprintf((0, "Object %i following path got %i retries in frame %i\n", obj-Objects, ailp->consecutive_retries, FrameCount)); + // mprintf((0, "Object %i following path got %i retries in frame %i\n", OBJECT_NUMBER(obj), ailp->consecutive_retries, FrameCount)); if (Game_mode & GM_MULTI) { ailp->mode = AIM_STILL; } else @@ -534,7 +534,7 @@ _exit_cheat: ailp->mode = AIM_RUN_FROM_OBJECT; break; case AIM_BEHIND: - mprintf((0, "Hiding robot (%i) collided much.\n", obj-Objects)); + mprintf((0, "Hiding robot (%i) collided much.\n", OBJECT_NUMBER(obj))); move_towards_segment_center(obj); obj->mtype.phys_info.velocity.x = 0; obj->mtype.phys_info.velocity.y = 0; @@ -620,7 +620,7 @@ _exit_cheat: rval = d_rand(); sval = (dist_to_player * (Difficulty_level+1))/64; - // -- mprintf((0, "Object #%3i: dist = %7.3f, rval = %8x, sval = %8x", obj-Objects, f2fl(dist_to_player), rval, sval)); + // -- mprintf((0, "Object #%3i: dist = %7.3f, rval = %8x, sval = %8x", OBJECT_NUMBER(obj), f2fl(dist_to_player), rval, sval)); if ((fixmul(rval, sval) < FrameTime) || (Players[Player_num].flags & PLAYER_FLAGS_HEADLIGHT_ON)) { ailp->player_awareness_type = PA_PLAYER_COLLISION; ailp->player_awareness_time = F1_0*3; @@ -645,7 +645,7 @@ _exit_cheat: object_animates = do_silly_animation(obj); if (object_animates) ai_frame_animation(obj); - //mprintf((0, "Object %i: goal=%i, current=%i\n", obj-Objects, obj->ctype.ai_info.GOAL_STATE, obj->ctype.ai_info.CURRENT_STATE)); + //mprintf((0, "Object %i: goal=%i, current=%i\n", OBJECT_NUMBER(obj), obj->ctype.ai_info.GOAL_STATE, obj->ctype.ai_info.CURRENT_STATE)); } else { // If Object is supposed to animate, but we don't let it animate due to distance, then // we must change its state, else it will never update. @@ -814,7 +814,7 @@ _exit_cheat: ; // mprintf((0, "Not Firing at player because dot = %7.3f, dist = %7.3f\n", f2fl(vm_vec_dot(&ConsoleObject->orient.fvec, &vec_to_player)), f2fl(dist_to_player))); if (do_stuff) { - Laser_create_new_easy( &obj->orient.fvec, &obj->pos, obj-Objects, FLARE_ID, 1); + Laser_create_new_easy( &obj->orient.fvec, &obj->pos, OBJECT_NUMBER(obj), FLARE_ID, 1 ); ailp->next_fire = F1_0/2; if (!Buddy_allowed_to_talk) // If buddy not talking, make him fire flares less often. ailp->next_fire += d_rand()*4; @@ -839,7 +839,7 @@ _exit_cheat: if (do_stuff) { // @mk, 05/08/95: Firing flare from center of object, this is dumb... - Laser_create_new_easy( &obj->orient.fvec, &obj->pos, obj-Objects, FLARE_ID, 1); + Laser_create_new_easy( &obj->orient.fvec, &obj->pos, OBJECT_NUMBER(obj), FLARE_ID, 1 ); ailp->next_fire = F1_0/2; if (Stolen_item_index == 0) // If never stolen an item, fire flares less often (bad: Stolen_item_index wraps, but big deal) ailp->next_fire += d_rand()*4; @@ -886,7 +886,7 @@ _exit_cheat: if (player_visibility) { if (d_rand() < FrameTime*player_visibility) { if (dist_to_player/256 < d_rand()*player_visibility) { - // mprintf((0, "Object %i searching for player.\n", obj-Objects)); + // mprintf((0, "Object %i searching for player.\n", OBJECT_NUMBER(obj))); aip->GOAL_STATE = AIS_SRCH; aip->CURRENT_STATE = AIS_SRCH; } @@ -975,9 +975,9 @@ _exit_cheat: vm_vec_add(&fire_pos, &obj->pos, &fire_vec); if (aip->SUB_FLAGS & SUB_FLAGS_SPROX) - Laser_create_new_easy( &fire_vec, &fire_pos, obj-Objects, ROBOT_SUPERPROX_ID, 1); + Laser_create_new_easy( &fire_vec, &fire_pos, OBJECT_NUMBER(obj), ROBOT_SUPERPROX_ID, 1 ); else - Laser_create_new_easy( &fire_vec, &fire_pos, obj-Objects, PROXIMITY_ID, 1); + Laser_create_new_easy( &fire_vec, &fire_pos, OBJECT_NUMBER(obj), PROXIMITY_ID, 1 ); ailp->next_fire = (F1_0/2)*(NDL+5 - Difficulty_level); // Drop a proximity bomb every 5 seconds. @@ -985,11 +985,11 @@ _exit_cheat: #ifndef SHAREWARE if (Game_mode & GM_MULTI) { - ai_multi_send_robot_position(obj-Objects, -1); + ai_multi_send_robot_position(OBJECT_NUMBER(obj), -1); if (aip->SUB_FLAGS & SUB_FLAGS_SPROX) - multi_send_robot_fire(obj-Objects, -2, &fire_vec); + multi_send_robot_fire(OBJECT_NUMBER(obj), -2, &fire_vec); else - multi_send_robot_fire(obj-Objects, -1, &fire_vec); + multi_send_robot_fire(OBJECT_NUMBER(obj), -1, &fire_vec); } #endif #endif @@ -1213,7 +1213,7 @@ _exit_cheat: break; default: - mprintf((0, "Unknown mode = %i in robot %i, behavior = %i\n", ailp->mode, obj-Objects, aip->behavior)); + mprintf((0, "Unknown mode = %i in robot %i, behavior = %i\n", ailp->mode, OBJECT_NUMBER(obj), aip->behavior)); ailp->mode = AIM_CHASE_OBJECT; break; } // end: switch (ailp->mode) { diff --git a/main/ai2.c b/main/ai2.c index 51de4005..c77bce40 100644 --- a/main/ai2.c +++ b/main/ai2.c @@ -579,7 +579,7 @@ int player_is_visible_from_object(object *objp, vms_vector *pos, fix field_of_vi if (segnum == -1) { fq.startseg = objp->segnum; *pos = objp->pos; - mprintf((1, "Object %i, gun is outside mine, moving towards center.\n", objp-Objects)); + mprintf((1, "Object %i, gun is outside mine, moving towards center.\n", OBJECT_NUMBER(objp))); move_towards_segment_center(objp); } else { if (segnum != objp->segnum) { @@ -592,7 +592,7 @@ int player_is_visible_from_object(object *objp, vms_vector *pos, fix field_of_vi fq.startseg = objp->segnum; fq.p1 = &Believed_player_pos; fq.rad = F1_0/4; - fq.thisobjnum = objp-Objects; + fq.thisobjnum = OBJECT_NUMBER(objp); fq.ignore_obj_list = NULL; fq.flags = FQ_TRANSWALL; // -- Why were we checking objects? | FQ_CHECK_OBJS; //what about trans walls??? @@ -619,7 +619,7 @@ int player_is_visible_from_object(object *objp, vms_vector *pos, fix field_of_vi // Return 1 if animates, else return 0 int do_silly_animation(object *objp) { - int objnum = objp-Objects; + int objnum = OBJECT_NUMBER(objp); jointpos *jp_list; int robot_type, gun_num, robot_state, num_joint_positions; polyobj_info *pobj_info = &objp->rtype.pobj_info; @@ -634,7 +634,7 @@ int do_silly_animation(object *objp) attack_type = Robot_info[robot_type].attack_type; if (num_guns == 0) { - // mprintf((0, "Object #%i of type #%i has 0 guns.\n", objp-Objects, robot_type)); + // mprintf((0, "Object #%i of type #%i has 0 guns.\n", OBJECT_NUMBER(objp), robot_type)); return 0; } @@ -729,7 +729,7 @@ int do_silly_animation(object *objp) if (at_goal) { //ai_static *aip = &objp->ctype.ai_info; - ai_local *ailp = &Ai_local_info[objp-Objects]; + ai_local *ailp = &Ai_local_info[OBJECT_NUMBER(objp)]; ailp->achieved_state[gun_num] = ailp->goal_state[gun_num]; if (ailp->achieved_state[gun_num] == AIS_RECO) ailp->goal_state[gun_num] = AIS_FIRE; @@ -753,7 +753,7 @@ int do_silly_animation(object *objp) // Delta orientation of object is at: ai_info.delta_angles void ai_frame_animation(object *objp) { - int objnum = objp-Objects; + int objnum = OBJECT_NUMBER(objp); int joint; int num_joints; @@ -845,7 +845,7 @@ void set_next_fire_time(object *objp, ai_local *ailp, robot_info *robptr, int gu // If player is cloaked, then robot probably didn't actually collide, deal with that here. void do_ai_robot_hit_attack(object *robot, object *playerobj, vms_vector *collision_point) { - ai_local *ailp = &Ai_local_info[robot-Objects]; + ai_local *ailp = &Ai_local_info[OBJECT_NUMBER(robot)]; robot_info *robptr = &Robot_info[robot->id]; //#ifndef NDEBUG @@ -982,7 +982,7 @@ int lead_player(object *objp, vms_vector *fire_point, vms_vector *believed_playe // When this routine is complete, the parameter vec_to_player should not be necessary. void ai_fire_laser_at_player(object *obj, vms_vector *fire_point, int gun_num, vms_vector *believed_player_pos) { - int objnum = obj-Objects; + int objnum = OBJECT_NUMBER(obj); ai_local *ailp = &Ai_local_info[objnum]; robot_info *robptr = &Robot_info[obj->id]; vms_vector fire_vec; @@ -1055,7 +1055,7 @@ void ai_fire_laser_at_player(object *obj, vms_vector *fire_point, int gun_num, v fq.p0 = &obj->pos; fq.p1 = fire_point; fq.rad = 0; - fq.thisobjnum = obj-Objects; + fq.thisobjnum = OBJECT_NUMBER(obj); fq.ignore_obj_list = NULL; fq.flags = FQ_TRANSWALL; @@ -1110,7 +1110,7 @@ player_led: ; if (gun_num == 0) weapon_type = robptr->weapon_type2; - Laser_create_new_easy( &fire_vec, fire_point, obj-Objects, weapon_type, 1); + Laser_create_new_easy( &fire_vec, fire_point, OBJECT_NUMBER(obj), weapon_type, 1 ); #ifdef NETWORK if (Game_mode & GM_MULTI) { @@ -1185,7 +1185,7 @@ void move_around_player(object *objp, vms_vector *vec_to_player, int fast_flag) physics_info *pptr = &objp->mtype.phys_info; fix speed; robot_info *robptr = &Robot_info[objp->id]; - int objnum = objp-Objects; + int objnum = OBJECT_NUMBER(objp); int dir; int dir_change; fix ft; @@ -1266,7 +1266,7 @@ void move_around_player(object *objp, vms_vector *vec_to_player, int fast_flag) pptr->velocity.z += evade_vector.z; speed = vm_vec_mag_quick(&pptr->velocity); - if ((objp-Objects != 1) && (speed > robptr->max_speed[Difficulty_level])) { + if ((OBJECT_NUMBER(objp) != 1) && (speed > robptr->max_speed[Difficulty_level])) { pptr->velocity.x = (pptr->velocity.x*3)/4; pptr->velocity.y = (pptr->velocity.y*3)/4; pptr->velocity.z = (pptr->velocity.z*3)/4; @@ -1287,7 +1287,7 @@ void move_away_from_player(object *objp, vms_vector *vec_to_player, int attack_t if (attack_type) { // Get value in 0..3 to choose evasion direction. - objref = ((objp-Objects) ^ ((FrameCount + 3*(objp-Objects)) >> 5)) & 3; + objref = ((OBJECT_NUMBER(objp)) ^ ((FrameCount + 3*(OBJECT_NUMBER(objp))) >> 5)) & 3; switch (objref) { case 0: vm_vec_scale_add2(&pptr->velocity, &objp->orient.uvec, FrameTime << 5); break; @@ -1388,7 +1388,7 @@ void ai_move_relative_to_player(object *objp, ai_local *ailp, fix dist_to_player } else if (robptr->thief) { move_towards_player(objp, vec_to_player); } else { - int objval = ((objp-Objects) & 0x0f) ^ 0x0a; + int objval = ((OBJECT_NUMBER(objp)) & 0x0f) ^ 0x0a; // Changes here by MK, 12/29/95. Trying to get rid of endless circling around bots in a large room. if (robptr->kamikaze) { @@ -1427,7 +1427,7 @@ void make_random_vector(vms_vector *vec) void mprintf_animation_info(object *objp) { ai_static *aip = &objp->ctype.ai_info; - ai_local *ailp = &Ai_local_info[objp-Objects]; + ai_local *ailp = &Ai_local_info[OBJECT_NUMBER(objp)]; if (!Ai_info_enabled) return; @@ -1483,7 +1483,7 @@ void do_firing_stuff(object *obj, int player_visibility, vms_vector *vec_to_play fix dot = vm_vec_dot(&obj->orient.fvec, vec_to_player); if ((dot >= 7*F1_0/8) || (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED)) { ai_static *aip = &obj->ctype.ai_info; - ai_local *ailp = &Ai_local_info[obj-Objects]; + ai_local *ailp = &Ai_local_info[OBJECT_NUMBER(obj)]; switch (aip->GOAL_STATE) { case AIS_NONE: @@ -1531,11 +1531,11 @@ void do_ai_robot_hit(object *objp, int type) create_path_to_player(objp, 10, 1); objp->ctype.ai_info.behavior = AIB_STATION; objp->ctype.ai_info.hide_segment = objp->segnum; - Ai_local_info[objp-Objects].mode = AIM_CHASE_OBJECT; + Ai_local_info[OBJECT_NUMBER(objp)].mode = AIM_CHASE_OBJECT; } else if (r < 4096+8192) { // -- mprintf((0, "Still guy creating n segment path.")); create_n_segment_path(objp, d_rand()/8192 + 2, -1); - Ai_local_info[objp-Objects].mode = AIM_FOLLOW_PATH; + Ai_local_info[OBJECT_NUMBER(objp)].mode = AIM_FOLLOW_PATH; } break; } @@ -1568,7 +1568,7 @@ void compute_vis_and_vec(object *objp, vms_vector *pos, ai_local *ailp, vms_vect if (!*flag) { if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) { fix delta_time, dist; - int cloak_index = (objp-Objects) % MAX_AI_CLOAK_INFO; + int cloak_index = (OBJECT_NUMBER(objp)) % MAX_AI_CLOAK_INFO; delta_time = GameTime - Ai_cloak_info[cloak_index].last_time; if (delta_time > F1_0*2) { @@ -1678,7 +1678,7 @@ void move_object_to_legal_spot(object *objp) int new_segnum = find_point_seg(&objp->pos, objp->segnum); if (new_segnum != -1) { - obj_relink(objp-Objects, new_segnum); + obj_relink(OBJECT_NUMBER(objp), new_segnum); return; } } else @@ -1690,8 +1690,8 @@ void move_object_to_legal_spot(object *objp) Int3(); // Note: Boss is poking outside mine. Will try to resolve. teleport_boss(objp); } else { - mprintf((0, "Note: Killing robot #%i because he's badly stuck outside the mine.\n", objp-Objects)); - apply_damage_to_robot(objp, objp->shields*2, objp-Objects); + mprintf((0, "Note: Killing robot #%i because he's badly stuck outside the mine.\n", OBJECT_NUMBER(objp))); + apply_damage_to_robot(objp, objp->shields*2, OBJECT_NUMBER(objp)); } } @@ -1712,7 +1712,7 @@ void move_towards_segment_center(object *objp) if (dist_to_center < objp->size) { // Center is nearer than the distance we want to move, so move to center. objp->pos = segment_center; - mprintf((0, "Object #%i moved to center of segment #%i (%7.3f %7.3f %7.3f)\n", objp-Objects, objp->segnum, f2fl(objp->pos.x), f2fl(objp->pos.y), f2fl(objp->pos.z))); + mprintf((0, "Object #%i moved to center of segment #%i (%7.3f %7.3f %7.3f)\n", OBJECT_NUMBER(objp), objp->segnum, f2fl(objp->pos.x), f2fl(objp->pos.y), f2fl(objp->pos.z))); if (object_intersects_wall(objp)) { mprintf((0, "Object #%i still illegal, trying trickier move.\n")); move_object_to_legal_spot(objp); @@ -1727,7 +1727,7 @@ void move_towards_segment_center(object *objp) objp->pos = segment_center; move_object_to_legal_spot(objp); } - // -- mprintf((0, "Obj %i moved twrds seg %i (%6.2f %6.2f %6.2f), dists: [%6.2f %6.2f]\n", objp-Objects, objp->segnum, f2fl(objp->pos.x), f2fl(objp->pos.y), f2fl(objp->pos.z), f2fl(vm_vec_dist_quick(&objp->pos, &segment_center)), f2fl(vm_vec_dist_quick(&objp->pos, &segment_center)))); + // -- mprintf((0, "Obj %i moved twrds seg %i (%6.2f %6.2f %6.2f), dists: [%6.2f %6.2f]\n", OBJECT_NUMBER(objp), objp->segnum, f2fl(objp->pos.x), f2fl(objp->pos.y), f2fl(objp->pos.z), f2fl(vm_vec_dist_quick(&objp->pos, &segment_center)), f2fl(vm_vec_dist_quick(&objp->pos, &segment_center)))); } } @@ -1792,7 +1792,7 @@ int ai_door_is_openable(object *objp, segment *segp, int sidenum) if (objp == NULL) ailp_mode = Ai_local_info[Buddy_objnum].mode; else - ailp_mode = Ai_local_info[objp-Objects].mode; + ailp_mode = Ai_local_info[OBJECT_NUMBER(objp)].mode; // -- if (Buddy_got_stuck) { if (ailp_mode == AIM_GOTO_PLAYER) { @@ -1961,7 +1961,7 @@ int create_gated_robot( int segnum, int object_id, vms_vector *pos) compute_segment_center(&object_pos, segp); if (pos == NULL) - pick_random_point_in_seg(&object_pos, segp-Segments); + pick_random_point_in_seg(&object_pos, (int)(segp - Segments)); else object_pos = *pos; @@ -2006,7 +2006,7 @@ int create_gated_robot( int segnum, int object_id, vms_vector *pos) objp->matcen_creator = BOSS_GATE_MATCEN_NUM; // flag this robot as having been created by the boss. default_behavior = Robot_info[objp->id].behavior; - init_ai_object(objp-Objects, default_behavior, -1 ); // Note, -1 = segment this robot goes to to hide, should probably be something useful + init_ai_object( OBJECT_NUMBER(objp), default_behavior, -1 ); // Note, -1 = segment this robot goes to to hide, should probably be something useful object_create_explosion(segnum, &object_pos, i2f(10), VCLIP_MORPHING_ROBOT ); digi_link_sound_to_pos( Vclip[VCLIP_MORPHING_ROBOT].sound_num, segnum, 0, &object_pos, 0 , F1_0); @@ -2017,7 +2017,7 @@ int create_gated_robot( int segnum, int object_id, vms_vector *pos) Players[Player_num].num_robots_level++; Players[Player_num].num_robots_total++; - return objp-Objects; + return OBJECT_NUMBER(objp); } #define MAX_SPEW_BOT 3 @@ -2111,7 +2111,7 @@ int gate_in_robot(int type, int segnum) int boss_fits_in_seg(object *boss_objp, int segnum) { vms_vector segcenter; - int boss_objnum = boss_objp-Objects; + int boss_objnum = OBJECT_NUMBER(boss_objp); int posnum; compute_segment_center(&segcenter, &Segments[segnum]); @@ -2150,11 +2150,11 @@ void teleport_boss(object *objp) #ifdef NETWORK if (Game_mode & GM_MULTI) - multi_send_boss_actions(objp-Objects, 1, rand_segnum, 0); + multi_send_boss_actions(OBJECT_NUMBER(objp), 1, rand_segnum, 0); #endif compute_segment_center(&objp->pos, &Segments[rand_segnum]); - obj_relink(objp-Objects, rand_segnum); + obj_relink(OBJECT_NUMBER(objp), rand_segnum); Last_teleport_time = GameTime; @@ -2163,12 +2163,12 @@ void teleport_boss(object *objp) vm_vector_2_matrix(&objp->orient, &boss_dir, NULL, NULL); digi_link_sound_to_pos( Vclip[VCLIP_MORPHING_ROBOT].sound_num, rand_segnum, 0, &objp->pos, 0 , F1_0); - digi_kill_sound_linked_to_object( objp-Objects); - digi_link_sound_to_object2( Robot_info[objp->id].see_sound, objp-Objects, 1, F1_0, F1_0*512 ); // F1_0*512 means play twice as loud + digi_kill_sound_linked_to_object( OBJECT_NUMBER(objp) ); + digi_link_sound_to_object2( Robot_info[objp->id].see_sound, OBJECT_NUMBER(objp), 1, F1_0, F1_0*512 ); // F1_0*512 means play twice as loud // After a teleport, boss can fire right away. - Ai_local_info[objp-Objects].next_fire = 0; - Ai_local_info[objp-Objects].next_fire2 = 0; + Ai_local_info[OBJECT_NUMBER(objp)].next_fire = 0; + Ai_local_info[OBJECT_NUMBER(objp)].next_fire2 = 0; } @@ -2213,7 +2213,7 @@ int do_robot_dying_frame(object *objp, fix start_time, fix roll_duration, sbyte if (!*dying_sound_playing) { mprintf((0, "Starting death sound!\n")); *dying_sound_playing = 1; - digi_link_sound_to_object2( death_sound, objp-Objects, 0, sound_scale, sound_scale*256 ); // F1_0*512 means play twice as loud + digi_link_sound_to_object2( death_sound, OBJECT_NUMBER(objp), 0, sound_scale, sound_scale*256 ); // F1_0*512 means play twice as loud } else if (d_rand() < FrameTime*16) create_small_fireball_on_object(objp, (F1_0 + d_rand()) * (16 * expl_scale/F1_0)/8, 0); } else if (d_rand() < FrameTime*8) @@ -2244,7 +2244,7 @@ void do_boss_dying_frame(object *objp) if (rval) { do_controlcen_destroyed_stuff(NULL); explode_object(objp, F1_0/4); - digi_link_sound_to_object2(SOUND_BADASS_EXPLOSION, objp-Objects, 0, F2_0, F1_0*512); + digi_link_sound_to_object2(SOUND_BADASS_EXPLOSION, OBJECT_NUMBER(objp), 0, F2_0, F1_0*512); } } @@ -2261,7 +2261,7 @@ int do_any_robot_dying_frame(object *objp) if (rval) { explode_object(objp, F1_0/4); - digi_link_sound_to_object2(SOUND_BADASS_EXPLOSION, objp-Objects, 0, F2_0, F1_0*512); + digi_link_sound_to_object2(SOUND_BADASS_EXPLOSION, OBJECT_NUMBER(objp), 0, F2_0, F1_0*512); if ((Current_level_num < 0) && (Robot_info[objp->id].thief)) recreate_thief(objp); } @@ -2290,7 +2290,7 @@ int ai_multiplayer_awareness(object *objp, int awareness_level) if (Game_mode & GM_MULTI) { if (awareness_level == 0) return 0; - rval = multi_can_move_robot(objp-Objects, awareness_level); + rval = multi_can_move_robot(OBJECT_NUMBER(objp), awareness_level); } #endif @@ -2316,7 +2316,7 @@ void do_boss_stuff(object *objp, int player_visibility) #ifndef NDEBUG if (objp->shields != Prev_boss_shields) { - mprintf((0, "Boss shields = %7.3f, object %i\n", f2fl(objp->shields), objp-Objects)); + mprintf((0, "Boss shields = %7.3f, object %i\n", f2fl(objp->shields), OBJECT_NUMBER(objp))); Prev_boss_shields = objp->shields; } #endif @@ -2353,7 +2353,7 @@ void do_boss_stuff(object *objp, int player_visibility) objp->ctype.ai_info.CLOAKED = 1; #ifdef NETWORK if (Game_mode & GM_MULTI) - multi_send_boss_actions(objp-Objects, 2, 0, 0); + multi_send_boss_actions(OBJECT_NUMBER(objp), 2, 0, 0); #endif } } @@ -2379,14 +2379,14 @@ void do_boss_stuff(object *objp, int player_visibility) // -- Obsolete D1 code -- if (GameTime - Last_gate_time > Gate_interval/2) { // -- Obsolete D1 code -- restart_effect(BOSS_ECLIP_NUM); // -- Obsolete D1 code -- if (eclip_state == 0) { -// -- Obsolete D1 code -- multi_send_boss_actions(objp-Objects, 4, 0, 0); +// -- Obsolete D1 code -- multi_send_boss_actions(OBJECT_NUMBER(objp), 4, 0, 0); // -- Obsolete D1 code -- eclip_state = 1; // -- Obsolete D1 code -- } // -- Obsolete D1 code -- } // -- Obsolete D1 code -- else { // -- Obsolete D1 code -- stop_effect(BOSS_ECLIP_NUM); // -- Obsolete D1 code -- if (eclip_state == 1) { -// -- Obsolete D1 code -- multi_send_boss_actions(objp-Objects, 5, 0, 0); +// -- Obsolete D1 code -- multi_send_boss_actions(OBJECT_NUMBER(objp), 5, 0, 0); // -- Obsolete D1 code -- eclip_state = 0; // -- Obsolete D1 code -- } // -- Obsolete D1 code -- } @@ -2403,7 +2403,7 @@ void do_boss_stuff(object *objp, int player_visibility) // -- Obsolete D1 code -- rtval = gate_in_robot(randtype, -1); // -- Obsolete D1 code -- if ((rtval != -1) && (Game_mode & GM_MULTI)) // -- Obsolete D1 code -- { -// -- Obsolete D1 code -- multi_send_boss_actions(objp-Objects, 3, randtype, Net_create_objnums[0]); +// -- Obsolete D1 code -- multi_send_boss_actions(OBJECT_NUMBER(objp), 3, randtype, Net_create_objnums[0]); // -- Obsolete D1 code -- map_objnum_local_to_local(Net_create_objnums[0]); // -- Obsolete D1 code -- } // -- Obsolete D1 code -- } diff --git a/main/aipath.c b/main/aipath.c index 8643e87e..b634053b 100644 --- a/main/aipath.c +++ b/main/aipath.c @@ -230,7 +230,7 @@ if (vm_vec_mag_quick(&e) < F1_0/2) fq.startseg = psegs[i].segnum; fq.p1 = &goal_pos; fq.rad = objp->size; - fq.thisobjnum = objp-Objects; + fq.thisobjnum = OBJECT_NUMBER(objp); fq.ignore_obj_list = NULL; fq.flags = 0; @@ -294,7 +294,7 @@ int create_path_points(object *objp, int start_seg, int end_seg, point_seg *pseg point_seg *original_psegs = psegs; int l_num_points; -// -- mprintf((0, "cpp: frame = %4i obj %3i, psegs = %5i\n", FrameCount, objp-Objects, psegs-Point_segs)); +// -- mprintf((0, "cpp: frame = %4i obj %3i, psegs = %5i\n", FrameCount, OBJECT_NUMBER(objp), psegs-Point_segs)); #if PATH_VALIDATION validate_all_paths(); #endif @@ -367,7 +367,7 @@ if ((objp->type == OBJ_ROBOT) && (objp->ctype.ai_info.behavior == AIB_RUN_FROM)) fq.startseg = objp->segnum; fq.p1 = ¢er_point; fq.rad = objp->size; - fq.thisobjnum = objp-Objects; + fq.thisobjnum = OBJECT_NUMBER(objp); fq.ignore_obj_list = NULL; fq.flags = 0; @@ -419,7 +419,7 @@ cpp_done1: ; #ifdef EDITOR // -- N_selected_segs = 0; #endif -//printf("Object #%3i, start: %3i ", objp-Objects, psegs-Point_segs); +//printf("Object #%3i, start: %3i ", OBJECT_NUMBER(objp), psegs-Point_segs); while (qtail >= 0) { int parent_seg, this_seg; @@ -539,7 +539,7 @@ int polish_path(object *objp, point_seg *psegs, int num_points) fq.startseg = objp->segnum; fq.p1 = &psegs[i].point; fq.rad = objp->size; - fq.thisobjnum = objp-Objects; + fq.thisobjnum = OBJECT_NUMBER(objp); fq.ignore_obj_list = NULL; fq.flags = 0; @@ -656,7 +656,7 @@ void validate_all_paths(void) // -- void create_path(object *objp) // -- { // -- ai_static *aip = &objp->ctype.ai_info; -// -- ai_local *ailp = &Ai_local_info[objp-Objects]; +// -- ai_local *ailp = &Ai_local_info[OBJECT_NUMBER(objp)]; // -- int start_seg, end_seg; // -- // -- start_seg = objp->segnum; @@ -666,7 +666,7 @@ void validate_all_paths(void) // -- create_n_segment_path(objp, 3, -1); // -- // -- if (end_seg == -1) { -// -- ; //mprintf((0, "Object %i, hide_segment = -1, not creating path.\n", objp-Objects)); +// -- ; //mprintf((0, "Object %i, hide_segment = -1, not creating path.\n", OBJECT_NUMBER(objp))); // -- } else { // -- create_path_points(objp, start_seg, end_seg, Point_segs_free_ptr, &aip->path_length, -1, 0, 0, -1); // -- aip->hide_index = Point_segs_free_ptr - Point_segs; @@ -698,7 +698,7 @@ void validate_all_paths(void) void create_path_to_player(object *objp, int max_length, int safety_flag) { ai_static *aip = &objp->ctype.ai_info; - ai_local *ailp = &Ai_local_info[objp-Objects]; + ai_local *ailp = &Ai_local_info[OBJECT_NUMBER(objp)]; int start_seg, end_seg; //mprintf((0, "Creating path to player.\n")); @@ -711,10 +711,10 @@ void create_path_to_player(object *objp, int max_length, int safety_flag) start_seg = objp->segnum; end_seg = ailp->goal_segment; - // mprintf((0, "Creating path for object #%i, from segment #%i to #%i\n", objp-Objects, start_seg, end_seg)); + // mprintf((0, "Creating path for object #%i, from segment #%i to #%i\n", OBJECT_NUMBER(objp), start_seg, end_seg)); if (end_seg == -1) { - ; //mprintf((0, "Object %i, hide_segment = -1, not creating path.\n", objp-Objects)); + ; //mprintf((0, "Object %i, hide_segment = -1, not creating path.\n", OBJECT_NUMBER(objp))); } else { create_path_points(objp, start_seg, end_seg, Point_segs_free_ptr, &aip->path_length, max_length, 1, safety_flag, -1); aip->path_length = polish_path(objp, Point_segs_free_ptr, aip->path_length); @@ -744,7 +744,7 @@ void create_path_to_player(object *objp, int max_length, int safety_flag) void create_path_to_segment(object *objp, int goalseg, int max_length, int safety_flag) { ai_static *aip = &objp->ctype.ai_info; - ai_local *ailp = &Ai_local_info[objp-Objects]; + ai_local *ailp = &Ai_local_info[OBJECT_NUMBER(objp)]; int start_seg, end_seg; if (max_length == -1) @@ -786,7 +786,7 @@ void create_path_to_segment(object *objp, int goalseg, int max_length, int safet void create_path_to_station(object *objp, int max_length) { ai_static *aip = &objp->ctype.ai_info; - ai_local *ailp = &Ai_local_info[objp-Objects]; + ai_local *ailp = &Ai_local_info[OBJECT_NUMBER(objp)]; int start_seg, end_seg; if (max_length == -1) @@ -797,10 +797,10 @@ void create_path_to_station(object *objp, int max_length) start_seg = objp->segnum; end_seg = aip->hide_segment; - //1001: mprintf((0, "Back to station for object #%i, from segment #%i to #%i\n", objp-Objects, start_seg, end_seg)); + //1001: mprintf((0, "Back to station for object #%i, from segment #%i to #%i\n", OBJECT_NUMBER(objp), start_seg, end_seg)); if (end_seg == -1) { - ; //mprintf((0, "Object %i, hide_segment = -1, not creating path.\n", objp-Objects)); + ; //mprintf((0, "Object %i, hide_segment = -1, not creating path.\n", OBJECT_NUMBER(objp))); } else { create_path_points(objp, start_seg, end_seg, Point_segs_free_ptr, &aip->path_length, max_length, 1, 1, -1); aip->path_length = polish_path(objp, Point_segs_free_ptr, aip->path_length); @@ -832,7 +832,7 @@ void create_path_to_station(object *objp, int max_length) void create_n_segment_path(object *objp, int path_length, int avoid_seg) { ai_static *aip=&objp->ctype.ai_info; - ai_local *ailp = &Ai_local_info[objp-Objects]; + ai_local *ailp = &Ai_local_info[OBJECT_NUMBER(objp)]; //mprintf((0, "Creating %i segment path.\n", path_length)); @@ -862,7 +862,7 @@ void create_n_segment_path(object *objp, int path_length, int avoid_seg) // If this robot is visible (player_visibility is not available) and it's running away, move towards outside with // randomness to prevent a stream of bots from going away down the center of a corridor. - if (Ai_local_info[objp-Objects].previous_visibility) { + if (Ai_local_info[OBJECT_NUMBER(objp)].previous_visibility) { if (aip->path_length) { int t_num_points = aip->path_length; move_towards_outside(&Point_segs[aip->hide_index], &t_num_points, objp, 1); @@ -896,7 +896,7 @@ void move_object_to_goal(object *objp, vms_vector *goal_point, int goal_seg) Assert(objp->segnum != -1); - // mprintf((0, "[%i -> %i]\n", objp-Objects, goal_seg)); + // mprintf((0, "[%i -> %i]\n", OBJECT_NUMBER(objp), goal_seg)); #ifndef NDEBUG if (objp->segnum != goal_seg) @@ -905,7 +905,7 @@ void move_object_to_goal(object *objp, vms_vector *goal_point, int goal_seg) dist = find_connected_distance(&objp->pos, objp->segnum, goal_point, goal_seg, 30, WID_FLY_FLAG); if (Connected_segment_distance > 2) { // This global is set in find_connected_distance // -- Int3(); - mprintf((1, "Warning: Object %i hopped across %i segments, a distance of %7.3f.\n", objp-Objects, Connected_segment_distance, f2fl(dist))); + mprintf((1, "Warning: Object %i hopped across %i segments, a distance of %7.3f.\n", OBJECT_NUMBER(objp), Connected_segment_distance, f2fl(dist))); } } #endif @@ -914,7 +914,7 @@ void move_object_to_goal(object *objp, vms_vector *goal_point, int goal_seg) if (aip->cur_path_index <= 0) { if (aip->behavior == AIB_STATION) { - // mprintf((0, "Object #%i, creating path back to station.\n", objp-Objects)); + // mprintf((0, "Object #%i, creating path back to station.\n", OBJECT_NUMBER(objp))); create_path_to_station(objp, 15); return; } @@ -922,10 +922,10 @@ void move_object_to_goal(object *objp, vms_vector *goal_point, int goal_seg) aip->PATH_DIR = 1; } else if (aip->cur_path_index >= aip->path_length - 1) { if (aip->behavior == AIB_STATION) { - // mprintf((0, "Object #%i, creating path back to station.\n", objp-Objects)); + // mprintf((0, "Object #%i, creating path back to station.\n", OBJECT_NUMBER(objp))); create_path_to_station(objp, 15); if (aip->path_length == 0) { - ai_local *ailp = &Ai_local_info[objp-Objects]; + ai_local *ailp = &Ai_local_info[OBJECT_NUMBER(objp)]; ailp->mode = AIM_STILL; } return; @@ -941,7 +941,7 @@ void move_object_to_goal(object *objp, vms_vector *goal_point, int goal_seg) objp->pos = *goal_point; segnum = find_object_seg(objp); if (segnum != goal_seg) - mprintf((1, "Object #%i goal supposed to be in segment #%i, but in segment #%i\n", objp-Objects, goal_seg, segnum)); + mprintf((1, "Object #%i goal supposed to be in segment #%i, but in segment #%i\n", OBJECT_NUMBER(objp), goal_seg, segnum)); if (segnum == -1) { Int3(); // Oops, object is not in any segment. @@ -949,7 +949,7 @@ void move_object_to_goal(object *objp, vms_vector *goal_point, int goal_seg) // Hack, move object to center of segment it used to be in. compute_segment_center(&objp->pos, &Segments[objp->segnum]); } else - obj_relink(objp-Objects, segnum); + obj_relink(OBJECT_NUMBER(objp), segnum); } // -- too much work -- // ---------------------------------------------------------------------------------------------------------- @@ -970,7 +970,7 @@ void move_object_to_goal(object *objp, vms_vector *goal_point, int goal_seg) // -- too much work -- fq.startseg = objp->segnum; // -- too much work -- fq.p1 = &kill_objp->pos; // -- too much work -- fq.rad = objp->size; -// -- too much work -- fq.thisobjnum = objp-Objects; +// -- too much work -- fq.thisobjnum = OBJECT_NUMBER(objp); // -- too much work -- fq.ignore_obj_list = NULL; // -- too much work -- fq.flags = 0; // -- too much work -- @@ -994,11 +994,11 @@ void ai_follow_path(object *objp, int player_visibility, int previous_visibility int forced_break, original_dir, original_index; fix dist_to_player; int goal_seg; - ai_local *ailp = &Ai_local_info[objp-Objects]; + ai_local *ailp = &Ai_local_info[OBJECT_NUMBER(objp)]; fix threshold_distance; -// mprintf((0, "Obj %i, dist=%6.1f index=%i len=%i seg=%i pos = %6.1f %6.1f %6.1f.\n", objp-Objects, f2fl(vm_vec_dist_quick(&objp->pos, &ConsoleObject->pos)), aip->cur_path_index, aip->path_length, objp->segnum, f2fl(objp->pos.x), f2fl(objp->pos.y), f2 +// mprintf((0, "Obj %i, dist=%6.1f index=%i len=%i seg=%i pos = %6.1f %6.1f %6.1f.\n", OBJECT_NUMBER(objp), f2fl(vm_vec_dist_quick(&objp->pos, &ConsoleObject->pos)), aip->cur_path_index, aip->path_length, objp->segnum, f2fl(objp->pos.x), f2fl(objp->pos.y), f2 if ((aip->hide_index == -1) || (aip->path_length == 0)) { @@ -1007,7 +1007,7 @@ void ai_follow_path(object *objp, int player_visibility, int previous_visibility //--Int3_if((aip->path_length != 0)); ailp->mode = AIM_RUN_FROM_OBJECT; } else { - // -- mprintf((0, "Object %i creating path for no apparent reason.\n", objp-Objects)); + // -- mprintf((0, "Object %i creating path for no apparent reason.\n", OBJECT_NUMBER(objp))); create_n_segment_path(objp, 5, -1); //--Int3_if((aip->path_length != 0)); } @@ -1101,7 +1101,7 @@ void ai_follow_path(object *objp, int player_visibility, int previous_visibility vm_vec_scale(&objp->mtype.phys_info.velocity, vel_scale); return; - } else if (!(FrameCount ^ ((objp-Objects) & 0x07))) { // Done 1/8 frames. + } else if (!(FrameCount ^ ((OBJECT_NUMBER(objp)) & 0x07))) { // Done 1/8 frames. // If player on path (beyond point robot is now at), then create a new path. point_seg *curpsp = &Point_segs[aip->hide_index]; int player_segnum = ConsoleObject->segnum; @@ -1161,7 +1161,7 @@ void ai_follow_path(object *objp, int player_visibility, int previous_visibility // See if next point wraps past end of path (in either direction), and if so, deal with it based on mode. if ((aip->cur_path_index >= aip->path_length) || (aip->cur_path_index < 0)) { - //mprintf((0, "Object %i reached end of the line!\n", objp-Objects)); + //mprintf((0, "Object %i reached end of the line!\n", OBJECT_NUMBER(objp))); // If mode = hiding, then stay here until get bonked or hit by player. // -- if (ailp->mode == AIM_BEHIND) { // -- ailp->mode = AIM_STILL; @@ -1197,7 +1197,7 @@ void ai_follow_path(object *objp, int player_visibility, int previous_visibility create_n_segment_path(objp, 10, ConsoleObject->segnum); //--Int3_if(((aip->cur_path_index >= 0) && (aip->cur_path_index < aip->path_length))); } else if (aip->behavior == AIB_STATION) { - // mprintf((0, "Object %i reached end of line, creating path back to station.\n", objp-Objects)); + // mprintf((0, "Object %i reached end of line, creating path back to station.\n", OBJECT_NUMBER(objp))); create_path_to_station(objp, 15); if ((aip->hide_segment != Point_segs[aip->hide_index+aip->path_length-1].segnum) || (aip->path_length == 0)) { ailp->mode = AIM_STILL; @@ -1252,7 +1252,7 @@ void ai_follow_path(object *objp, int player_visibility, int previous_visibility fq.startseg = objp->segnum; fq.p1 = opposite_end_point; fq.rad = objp->size; - fq.thisobjnum = objp-Objects; + fq.thisobjnum = OBJECT_NUMBER(objp); fq.ignore_obj_list = NULL; fq.flags = 0; //what about trans walls??? @@ -1322,7 +1322,7 @@ void ai_path_set_orient_and_vel(object *objp, vms_vector *goal_point, int player // If evading player, use highest difficulty level speed, plus something based on diff level max_speed = robptr->max_speed[Difficulty_level]; - if ((Ai_local_info[objp-Objects].mode == AIM_RUN_FROM_OBJECT) || (objp->ctype.ai_info.behavior == AIB_SNIPE)) + if ((Ai_local_info[OBJECT_NUMBER(objp)].mode == AIM_RUN_FROM_OBJECT) || (objp->ctype.ai_info.behavior == AIB_SNIPE)) max_speed = max_speed*3/2; vm_vec_sub(&norm_vec_to_goal, goal_point, &cur_pos); @@ -1365,8 +1365,8 @@ void ai_path_set_orient_and_vel(object *objp, vms_vector *goal_point, int player vm_vec_scale(&norm_cur_vel, speed_scale); objp->mtype.phys_info.velocity = norm_cur_vel; - if ((Ai_local_info[objp-Objects].mode == AIM_RUN_FROM_OBJECT) || (robptr->companion == 1) || (objp->ctype.ai_info.behavior == AIB_SNIPE)) { - if (Ai_local_info[objp-Objects].mode == AIM_SNIPE_RETREAT_BACKWARDS) { + if ((Ai_local_info[OBJECT_NUMBER(objp)].mode == AIM_RUN_FROM_OBJECT) || (robptr->companion == 1) || (objp->ctype.ai_info.behavior == AIB_SNIPE)) { + if (Ai_local_info[OBJECT_NUMBER(objp)].mode == AIM_SNIPE_RETREAT_BACKWARDS) { if ((player_visibility) && (vec_to_player != NULL)) norm_vec_to_goal = *vec_to_player; else @@ -1507,21 +1507,21 @@ void ai_reset_all_paths(void) // Try to resume path. void attempt_to_resume_path(object *objp) { - //int objnum = objp-Objects; + //int objnum = OBJECT_NUMBER(objp); ai_static *aip = &objp->ctype.ai_info; // int goal_segnum, object_segnum, int abs_index, new_path_index; - // mprintf((0, "Object %i trying to resume path at index %i\n", objp-Objects, aip->cur_path_index)); + // mprintf((0, "Object %i trying to resume path at index %i\n", OBJECT_NUMBER(objp), aip->cur_path_index)); if ((aip->behavior == AIB_STATION) && (Robot_info[objp->id].companion != 1)) if (d_rand() > 8192) { - ai_local *ailp = &Ai_local_info[objp-Objects]; + ai_local *ailp = &Ai_local_info[OBJECT_NUMBER(objp)]; aip->hide_segment = objp->segnum; //Int3(); ailp->mode = AIM_STILL; - mprintf((1, "Note: Bashing hide segment of robot %i to current segment because he's lost.\n", objp-Objects)); + mprintf((1, "Note: Bashing hide segment of robot %i to current segment because he's lost.\n", OBJECT_NUMBER(objp))); } // object_segnum = objp->segnum; @@ -1700,7 +1700,7 @@ void player_path_set_orient_and_vel(object *objp, vms_vector *goal_point) vm_vec_normalize_quick(&norm_fvec); dot = vm_vec_dot(&norm_vec_to_goal, &norm_fvec); - if (Ai_local_info[objp-Objects].mode == AIM_SNIPE_RETREAT_BACKWARDS) { + if (Ai_local_info[OBJECT_NUMBER(objp)].mode == AIM_SNIPE_RETREAT_BACKWARDS) { dot = -dot; } diff --git a/main/cntrlcen.c b/main/cntrlcen.c index 506ff75d..e4e91a2d 100644 --- a/main/cntrlcen.c +++ b/main/cntrlcen.c @@ -281,7 +281,7 @@ void do_controlcen_destroyed_stuff(object *objp) //Assert(objp != NULL); - Dead_controlcen_object_num = objp-Objects; + Dead_controlcen_object_num = OBJECT_NUMBER(objp); } int Last_time_cc_vis_check = 0; @@ -388,9 +388,9 @@ void do_controlcen_frame(object *obj) #ifdef NETWORK if (Game_mode & GM_MULTI) - multi_send_controlcen_fire(&vec_to_goal, best_gun_num, obj-Objects); + multi_send_controlcen_fire(&vec_to_goal, best_gun_num, OBJECT_NUMBER(obj)); #endif - Laser_create_new_easy( &vec_to_goal, &Gun_pos[best_gun_num], obj-Objects, CONTROLCEN_WEAPON_NUM, 1); + Laser_create_new_easy( &vec_to_goal, &Gun_pos[best_gun_num], OBJECT_NUMBER(obj), CONTROLCEN_WEAPON_NUM, 1 ); // some of time, based on level, fire another thing, not directly at player, so it might hit him if he's constantly moving. rand_prob = F1_0/(abs(Current_level_num)/4+2); @@ -403,9 +403,9 @@ void do_controlcen_frame(object *obj) vm_vec_normalize_quick(&vec_to_goal); #ifdef NETWORK if (Game_mode & GM_MULTI) - multi_send_controlcen_fire(&vec_to_goal, best_gun_num, obj-Objects); + multi_send_controlcen_fire(&vec_to_goal, best_gun_num, OBJECT_NUMBER(obj)); #endif - Laser_create_new_easy( &vec_to_goal, &Gun_pos[best_gun_num], obj-Objects, CONTROLCEN_WEAPON_NUM, 0); + Laser_create_new_easy( &vec_to_goal, &Gun_pos[best_gun_num], OBJECT_NUMBER(obj), CONTROLCEN_WEAPON_NUM, 0 ); count++; } diff --git a/main/collide.c b/main/collide.c index a21ada73..e2c87d2a 100644 --- a/main/collide.c +++ b/main/collide.c @@ -100,7 +100,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. // The only reason this routine is called (as of 10/12/94) is so Brain guys can open doors. void collide_robot_and_wall( object * robot, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt) { - ai_local *ailp = &Ai_local_info[robot-Objects]; + ai_local *ailp = &Ai_local_info[OBJECT_NUMBER(robot)]; if ((robot->id == ROBOT_BRAIN) || (robot->ctype.ai_info.behavior == AIB_RUN_FROM) || (Robot_info[robot->id].companion == 1) || (robot->ctype.ai_info.behavior == AIB_SNIPE)) { int wall_num = Segments[hitseg].sides[hitwall].wall_num; @@ -166,7 +166,7 @@ void apply_force_damage(object *obj,fix force,object *other_obj) if ((other_obj->type == OBJ_PLAYER) && Monster_mode) damage = 0x7fffffff; -//mprintf((0,"obj %d, damage=%x\n",obj-Objects,damage)); +//mprintf((0,"obj %d, damage=%x\n",OBJECT_NUMBER(obj),damage)); switch (obj->type) { @@ -176,13 +176,13 @@ void apply_force_damage(object *obj,fix force,object *other_obj) if (other_obj->type == OBJ_WEAPON) result = apply_damage_to_robot(obj,damage/4, other_obj->ctype.laser_info.parent_num); else - result = apply_damage_to_robot(obj,damage/4, other_obj-Objects); + result = apply_damage_to_robot(obj,damage/4, OBJECT_NUMBER(other_obj)); } else { if (other_obj->type == OBJ_WEAPON) result = apply_damage_to_robot(obj,damage/2, other_obj->ctype.laser_info.parent_num); else - result = apply_damage_to_robot(obj,damage/2, other_obj-Objects); + result = apply_damage_to_robot(obj,damage/2, OBJECT_NUMBER(other_obj)); } if (result && (other_obj->ctype.laser_info.parent_signature == ConsoleObject->signature)) @@ -210,7 +210,7 @@ void apply_force_damage(object *obj,fix force,object *other_obj) case OBJ_CNTRLCEN: - apply_damage_to_controlcen(obj,damage, other_obj-Objects); + apply_damage_to_controlcen(obj, damage, OBJECT_NUMBER(other_obj)); break; case OBJ_WEAPON: @@ -852,7 +852,7 @@ void collide_weapon_and_wall( object * weapon, fix hitspeed, short hitseg, short if ( Weapon_info[weapon->id].damage_radius ) { - digi_link_sound_to_object(SOUND_BADASS_EXPLOSION, weapon-Objects, 0, F1_0); + digi_link_sound_to_object(SOUND_BADASS_EXPLOSION, OBJECT_NUMBER(weapon), 0, F1_0); // MK: 09/13/95: Badass in water is 1/2 normal intensity. object_create_badass_explosion( weapon, hitseg, hitpt, @@ -944,7 +944,7 @@ void collide_weapon_and_wall( object * weapon, fix hitspeed, short hitseg, short break; } } // else - //mprintf((0, "Weapon %i hits wall, but has silent bit set.\n", weapon-Objects)); + //mprintf((0, "Weapon %i hits wall, but has silent bit set.\n", OBJECT_NUMBER(weapon))); } // else { // if (weapon->lifeleft <= 0) // weapon->flags |= OF_SHOULD_BE_DEAD; @@ -1008,8 +1008,8 @@ void collide_debris_and_wall( object * debris, fix hitspeed, short hitseg, short // ------------------------------------------------------------------------------------------------------------------- void collide_robot_and_robot( object * robot1, object * robot2, vms_vector *collision_point ) { // mprintf((0, "Coll: [%2i %4i %4i %4i] [%2i %4i %4i %4i] at [%4i %4i %4i]", -// robot1-Objects, f2i(robot1->pos.x), f2i(robot1->pos.y), f2i(robot1->pos.z), -// robot2-Objects, f2i(robot2->pos.x), f2i(robot2->pos.y), f2i(robot2->pos.z), +// OBJECT_NUMBER(robot1), f2i(robot1->pos.x), f2i(robot1->pos.y), f2i(robot1->pos.z), +// OBJECT_NUMBER(robot2), f2i(robot2->pos.x), f2i(robot2->pos.y), f2i(robot2->pos.z), // f2i(collision_point->x), f2i(collision_point->y), f2i(collision_point->z))); bump_two_objects(robot1, robot2, 1); @@ -1053,13 +1053,13 @@ void collide_robot_and_player( object * robot, object * playerobj, vms_vector *c if (Robot_info[robot->id].companion) // Player and companion don't collide. return; if (Robot_info[robot->id].kamikaze) { - apply_damage_to_robot(robot, robot->shields+1, playerobj-Objects); + apply_damage_to_robot(robot, robot->shields+1, OBJECT_NUMBER(playerobj)); if (playerobj == ConsoleObject) add_points_to_score(Robot_info[robot->id].score_value); } if (Robot_info[robot->id].thief) { - if (Ai_local_info[robot-Objects].mode == AIM_THIEF_ATTACK) { + if (Ai_local_info[OBJECT_NUMBER(robot)].mode == AIM_THIEF_ATTACK) { Last_thief_hit_time = GameTime; attempt_to_steal_item(robot, playerobj->id); steal_attempt = 1; @@ -1152,7 +1152,7 @@ void apply_damage_to_controlcen(object *controlcen, fix damage, short who) if (Game_mode & GM_MULTI) { if (who == Players[Player_num].objnum) add_points_to_score(CONTROL_CEN_SCORE); - multi_send_destroy_controlcen((ushort)(controlcen-Objects), Objects[who].id ); + multi_send_destroy_controlcen( (ushort)(OBJECT_NUMBER(controlcen)), Objects[who].id ); } #endif @@ -1200,7 +1200,7 @@ void collide_player_and_marker( object * marker, object * playerobj, vms_vector if (drawn) digi_play_sample( SOUND_MARKER_HIT, F1_0 ); - detect_escort_goal_accomplished(marker-Objects); + detect_escort_goal_accomplished(OBJECT_NUMBER(marker)); } } @@ -1426,13 +1426,13 @@ int apply_damage_to_robot(object *robot, fix damage, int killer_objnum) for (i=0;iid].thief)) + if (multi_explode_robot_sub(OBJECT_NUMBER(robot), killer_objnum,Robot_info[robot->id].thief)) { if (isthief) for (i=0;iid].thief); + multi_send_robot_explode(OBJECT_NUMBER(robot), killer_objnum,Robot_info[robot->id].thief); if (isthief) for (i=0;imtype.phys_info.flags & PF_PERSISTENT) { - if (weapon->ctype.laser_info.last_hitobj == robot-Objects) + if (weapon->ctype.laser_info.last_hitobj == OBJECT_NUMBER(robot)) return; else - weapon->ctype.laser_info.last_hitobj = robot-Objects; + weapon->ctype.laser_info.last_hitobj = OBJECT_NUMBER(robot); - // mprintf((0, "weapon #%i with power %i hits robot #%i.\n", weapon - Objects, f2i(weapon->shields), robot - Objects)); + // mprintf((0, "weapon #%i with power %i hits robot #%i.\n", OBJECT_NUMBER(weapon), f2i(weapon->shields), OBJECT_NUMBER(robot))); } if (weapon->ctype.laser_info.parent_signature == robot->signature) @@ -1711,7 +1711,7 @@ void collide_robot_and_weapon( object * robot, object * weapon, vms_vector *coll bump_two_objects(robot, weapon, 0); //only bump if not dead. no damage from bump else if (weapon->ctype.laser_info.parent_signature == ConsoleObject->signature) { add_points_to_score(Robot_info[robot->id].score_value); - detect_escort_goal_accomplished(robot-Objects); + detect_escort_goal_accomplished(OBJECT_NUMBER(robot)); } } @@ -1756,7 +1756,7 @@ void collide_robot_and_weapon( object * robot, object * weapon, vms_vector *coll void collide_hostage_and_player( object * hostage, object * player, vms_vector *collision_point ) { // Give player points, etc. if ( player == ConsoleObject ) { - detect_escort_goal_accomplished(hostage-Objects); + detect_escort_goal_accomplished(OBJECT_NUMBER(hostage)); add_points_to_score(HOSTAGE_SCORE); // Do effect @@ -1767,7 +1767,7 @@ void collide_hostage_and_player( object * hostage, object * player, vms_vector * #ifdef NETWORK if (Game_mode & GM_MULTI) - multi_send_remobj(hostage-Objects); + multi_send_remobj(OBJECT_NUMBER(hostage)); #endif } return; @@ -1894,7 +1894,7 @@ void drop_player_eggs(object *playerobj) vm_vec_add(&tvec, &playerobj->pos, &randvec); newseg = find_point_seg(&tvec, playerobj->segnum); if (newseg != -1) - Laser_create_new(&randvec, &tvec, newseg, playerobj-Objects, SUPERPROX_ID, 0); + Laser_create_new(&randvec, &tvec, newseg, OBJECT_NUMBER(playerobj), SUPERPROX_ID, 0); } // If the player had proximity bombs, maybe arm one of them. @@ -1911,7 +1911,7 @@ void drop_player_eggs(object *playerobj) vm_vec_add(&tvec, &playerobj->pos, &randvec); newseg = find_point_seg(&tvec, playerobj->segnum); if (newseg != -1) - Laser_create_new(&randvec, &tvec, newseg, playerobj-Objects, PROXIMITY_ID, 0); + Laser_create_new(&randvec, &tvec, newseg, OBJECT_NUMBER(playerobj), PROXIMITY_ID, 0); } } @@ -2135,10 +2135,10 @@ void apply_damage_to_player(object *playerobj, object *killer, fix damage) if (Players[Player_num].shields < 0) { - Players[Player_num].killer_objnum = killer-Objects; + Players[Player_num].killer_objnum = OBJECT_NUMBER(killer); // if ( killer && (killer->type == OBJ_PLAYER)) -// Players[Player_num].killer_objnum = killer-Objects; +// Players[Player_num].killer_objnum = OBJECT_NUMBER(killer); playerobj->flags |= OF_SHOULD_BE_DEAD; @@ -2183,7 +2183,7 @@ void collide_player_and_weapon( object * playerobj, object * weapon, vms_vector // Don't collide own smart mines unless direct hit. if (weapon->id == SUPERPROX_ID) - if (playerobj-Objects == weapon->ctype.laser_info.parent_num) + if (OBJECT_NUMBER(playerobj) == weapon->ctype.laser_info.parent_num) if (vm_vec_dist_quick(collision_point, &playerobj->pos) > playerobj->size) return; @@ -2198,10 +2198,10 @@ void collide_player_and_weapon( object * playerobj, object * weapon, vms_vector if (weapon->mtype.phys_info.flags & PF_PERSISTENT) { - if (weapon->ctype.laser_info.last_hitobj == playerobj-Objects) + if (weapon->ctype.laser_info.last_hitobj == OBJECT_NUMBER(playerobj)) return; else - weapon->ctype.laser_info.last_hitobj = playerobj-Objects; + weapon->ctype.laser_info.last_hitobj = OBJECT_NUMBER(playerobj); } if (playerobj->id == Player_num) @@ -2344,7 +2344,7 @@ void collide_player_and_powerup( object * playerobj, object * powerup, vms_vecto powerup->flags |= OF_SHOULD_BE_DEAD; #ifdef NETWORK if (Game_mode & GM_MULTI) - multi_send_remobj(powerup-Objects); + multi_send_remobj(OBJECT_NUMBER(powerup)); #endif } } @@ -2522,7 +2522,7 @@ void collide_two_objects( object * A, object * B, vms_vector *collision_point ) collision_type = COLLISION_OF(A->type,B->type); - //mprintf( (0, "Object %d of type %d collided with object %d of type %d\n", A-Objects,A->type, B-Objects, B->type )); + //mprintf( (0, "Object %d of type %d collided with object %d of type %d\n", OBJECT_NUMBER(A), A->type, OBJECT_NUMBER(B), B->type) ); switch( collision_type ) { NO_SAME_COLLISION( OBJ_FIREBALL, OBJ_FIREBALL, collide_fireball_and_fireball ) diff --git a/main/editor/eobject.c b/main/editor/eobject.c index a62ce195..735561ed 100644 --- a/main/editor/eobject.c +++ b/main/editor/eobject.c @@ -85,7 +85,7 @@ int get_first_object(segment *seg) id = seg->objects; - if (id == (ConsoleObject-Objects)) + if (id == OBJECT_NUMBER(ConsoleObject)) id = Objects[id].next; return id; @@ -97,7 +97,7 @@ int get_next_object(segment *seg,int id) if (id==-1 || (id=Objects[id].next)==-1) return get_first_object(seg); - if (id == (ConsoleObject-Objects)) + if (id == OBJECT_NUMBER(ConsoleObject)) return get_next_object(seg,id); return id; @@ -184,9 +184,9 @@ int place_object(segment *segp, vms_vector *object_pos, short object_type, short hide_segment = -1; // robots which lunge forward to attack cannot have behavior type still. if (Robot_info[obj->id].attack_type) - init_ai_object(obj-Objects, AIB_NORMAL, hide_segment); + init_ai_object(OBJECT_NUMBER(obj), AIB_NORMAL, hide_segment); else - init_ai_object(obj-Objects, AIB_STILL, hide_segment); + init_ai_object(OBJECT_NUMBER(obj), AIB_STILL, hide_segment); } break; @@ -416,7 +416,7 @@ int ObjectSelectNextInMine() Cur_object_index++; if (Cur_object_index>= MAX_OBJECTS ) Cur_object_index= 0; - if ((Objects[Cur_object_index ].type != OBJ_NONE) && (Cur_object_index != (ConsoleObject-Objects)) ) { + if ( (Objects[Cur_object_index ].type != OBJ_NONE) && (Cur_object_index != OBJECT_NUMBER(ConsoleObject)) ) { Cursegp = &Segments[Objects[Cur_object_index ].segnum]; med_create_new_segment_from_cursegp(); //Cur_object_seg = Cursegp; @@ -438,7 +438,7 @@ int ObjectSelectPrevInMine() if (Cur_object_index < 0 ) Cur_object_index = MAX_OBJECTS-1; - if ((Objects[Cur_object_index ].type != OBJ_NONE) && (Cur_object_index != (ConsoleObject-Objects)) ) { + if ( (Objects[Cur_object_index ].type != OBJ_NONE) && (Cur_object_index != OBJECT_NUMBER(ConsoleObject)) ) { Cursegp = &Segments[Objects[Cur_object_index ].segnum]; med_create_new_segment_from_cursegp(); //Cur_object_seg = Cursegp; @@ -505,7 +505,7 @@ int move_object_within_mine(object * obj, vms_vector *newpos ) if (fate != HIT_WALL) { if ( segnum != obj->segnum ) - obj_relink( obj-Objects, segnum); + obj_relink( OBJECT_NUMBER(obj), segnum ); obj->pos = *newpos; return 0; } //else @@ -969,7 +969,7 @@ void move_object_to_position(int objnum, vms_vector *newpos) objp->pos = hit_info.hit_pnt; new_segnum = find_object_seg(objp); Assert(new_segnum != -1); - obj_relink(objp-Objects, new_segnum); + obj_relink(OBJECT_NUMBER(objp), new_segnum); //mprintf((0, "Object moved from segment %i to %i\n", old_segnum, objp->segnum)); } else { editor_status("Attempted to move object out of mine. Object not moved."); diff --git a/main/editor/kgame.c b/main/editor/kgame.c index e437e2a0..4d0a312a 100644 --- a/main/editor/kgame.c +++ b/main/editor/kgame.c @@ -115,7 +115,7 @@ int SaveGameData() if (get_seg_masks(&Perm_player_position, Perm_player_segnum, 0, __FILE__, __LINE__).centermask == 0) { ConsoleObject->pos = Perm_player_position; - obj_relink(ConsoleObject-Objects,Perm_player_segnum); + obj_relink(OBJECT_NUMBER(ConsoleObject), Perm_player_segnum); ConsoleObject->orient = Perm_player_orient; } else @@ -135,7 +135,7 @@ int SaveGameData() found_save_segnum = save_segnum; } - obj_relink(ConsoleObject-Objects,found_save_segnum); + obj_relink(OBJECT_NUMBER(ConsoleObject), found_save_segnum); ConsoleObject->orient = save_orient; } if (saved_flag) diff --git a/main/editor/med.c b/main/editor/med.c index 751a57e3..bb976335 100644 --- a/main/editor/med.c +++ b/main/editor/med.c @@ -509,7 +509,7 @@ void move_player_2_segment_and_rotate(segment *seg,int side) vm_vector_2_matrix(&ConsoleObject->orient,&vp,&upvec,NULL); // vm_vector_2_matrix(&ConsoleObject->orient,&vp,NULL,NULL); - obj_relink( ConsoleObject-Objects, SEG_PTR_2_NUM(seg) ); + obj_relink( OBJECT_NUMBER(ConsoleObject), SEG_PTR_2_NUM(seg) ); } @@ -561,12 +561,12 @@ int SetPlayerFromCursegMinusOne() vm_vec_copy_scale(&view_vec2,&view_vec,view_dist); vm_vec_sub(&ConsoleObject->pos,&side_center,&view_vec2); - //obj_relink(ConsoleObject-Objects, SEG_PTR_2_NUM(Cursegp) ); + //obj_relink( OBJECT_NUMBER(ConsoleObject), SEG_PTR_2_NUM(Cursegp) ); //update_object_seg(ConsoleObject); //might have backed right out of curseg newseg = find_point_seg(&ConsoleObject->pos,SEG_PTR_2_NUM(Cursegp) ); if (newseg != -1) - obj_relink(ConsoleObject-Objects,newseg); + obj_relink(OBJECT_NUMBER(ConsoleObject), newseg); Update_flags |= UF_ED_STATE_CHANGED | UF_GAME_VIEW_CHANGED; return 1; @@ -966,7 +966,7 @@ void gamestate_restore_check() { if (Save_position.segnum <= Highest_segment_index) { ConsoleObject->pos = Save_position.pos; ConsoleObject->orient = Save_position.orient; - obj_relink(ConsoleObject-Objects,Save_position.segnum); + obj_relink(OBJECT_NUMBER(ConsoleObject), Save_position.segnum); } gamestate_not_restored = 0; diff --git a/main/editor/medrobot.c b/main/editor/medrobot.c index 9fe072e3..9a630005 100644 --- a/main/editor/medrobot.c +++ b/main/editor/medrobot.c @@ -93,7 +93,7 @@ void call_init_ai_object(object *objp, int behavior) } mprintf((0, "Initializing AI object with hide segment = %i\n", hide_segment)); - init_ai_object(objp-Objects, behavior, hide_segment); + init_ai_object(OBJECT_NUMBER(objp), behavior, hide_segment); if (behavior == AIB_STATION) { int cseg, mseg; diff --git a/main/editor/segment.c b/main/editor/segment.c index 20e35dd0..e375cf30 100644 --- a/main/editor/segment.c +++ b/main/editor/segment.c @@ -1266,7 +1266,7 @@ int med_delete_segment(segment *sp) //if an object is in the seg, delete it //if the object is the player, move to new curseg - if (objnum == (ConsoleObject-Objects)) { + if (objnum == OBJECT_NUMBER(ConsoleObject)) { compute_segment_center(&ConsoleObject->pos,Cursegp); obj_relink(objnum,Cursegp-Segments); } else diff --git a/main/escort.c b/main/escort.c index c70adae8..b03be9b8 100644 --- a/main/escort.c +++ b/main/escort.c @@ -767,7 +767,7 @@ void say_escort_goal(int goal_num) void escort_create_path_to_goal(object *objp) { int goal_seg = -1; - int objnum = objp-Objects; + int objnum = OBJECT_NUMBER(objp); ai_static *aip = &objp->ctype.ai_info; ai_local *ailp = &Ai_local_info[objnum]; @@ -957,7 +957,7 @@ void bash_buddy_weapon_info(int weapon_objnum) { object *objp = &Objects[weapon_objnum]; - objp->ctype.laser_info.parent_num = ConsoleObject-Objects; + objp->ctype.laser_info.parent_num = OBJECT_NUMBER(ConsoleObject); objp->ctype.laser_info.parent_type = OBJ_PLAYER; objp->ctype.laser_info.parent_signature = ConsoleObject->signature; } @@ -1066,11 +1066,11 @@ void do_buddy_dude_stuff(void) // Called every frame (or something). void do_escort_frame(object *objp, fix dist_to_player, int player_visibility) { - int objnum = objp-Objects; + int objnum = OBJECT_NUMBER(objp); ai_static *aip = &objp->ctype.ai_info; ai_local *ailp = &Ai_local_info[objnum]; - Buddy_objnum = objp-Objects; + Buddy_objnum = OBJECT_NUMBER(objp); if (player_visibility) { Buddy_last_seen_player = GameTime; @@ -1188,7 +1188,7 @@ void invalidate_escort_goal(void) // ------------------------------------------------------------------------------------------------- void do_snipe_frame(object *objp, fix dist_to_player, int player_visibility, vms_vector *vec_to_player) { - int objnum = objp-Objects; + int objnum = OBJECT_NUMBER(objp); ai_local *ailp = &Ai_local_info[objnum]; fix connected_distance; @@ -1312,7 +1312,7 @@ void recreate_thief(object *objp) compute_segment_center(¢er_point, &Segments[segnum]); new_obj = create_morph_robot( &Segments[segnum], ¢er_point, objp->id); - init_ai_object(new_obj-Objects, AIB_SNIPE, -1); + init_ai_object(OBJECT_NUMBER(new_obj), AIB_SNIPE, -1); Re_init_thief_time = GameTime + F1_0*10; // In 10 seconds, re-initialize thief. } @@ -1324,7 +1324,7 @@ fix Thief_wait_times[NDL] = {F1_0*30, F1_0*25, F1_0*20, F1_0*15, F1_0*10}; // ------------------------------------------------------------------------------------------------- void do_thief_frame(object *objp, fix dist_to_player, int player_visibility, vms_vector *vec_to_player) { - int objnum = objp-Objects; + int objnum = OBJECT_NUMBER(objp); ai_local *ailp = &Ai_local_info[objnum]; fix connected_distance; @@ -1423,8 +1423,8 @@ void do_thief_frame(object *objp, fix dist_to_player, int player_visibility, vms if (d_rand() > 8192) { // --- mprintf((0, "RETREAT!!\n")); create_n_segment_path(objp, 10, ConsoleObject->segnum); - Ai_local_info[objp-Objects].next_action_time = Thief_wait_times[Difficulty_level]/2; - Ai_local_info[objp-Objects].mode = AIM_THIEF_RETREAT; + Ai_local_info[OBJECT_NUMBER(objp)].next_action_time = Thief_wait_times[Difficulty_level]/2; + Ai_local_info[OBJECT_NUMBER(objp)].mode = AIM_THIEF_RETREAT; } } else if (ailp->next_action_time < 0) { // This forces him to create a new path every second. @@ -1440,8 +1440,8 @@ void do_thief_frame(object *objp, fix dist_to_player, int player_visibility, vms fix dot = vm_vec_dot(vec_to_player, &ConsoleObject->orient.fvec); if (dot < -F1_0/2) { // Looking at least towards thief, so thief will run! create_n_segment_path(objp, 10, ConsoleObject->segnum); - Ai_local_info[objp-Objects].next_action_time = Thief_wait_times[Difficulty_level]/2; - Ai_local_info[objp-Objects].mode = AIM_THIEF_RETREAT; + Ai_local_info[OBJECT_NUMBER(objp)].next_action_time = Thief_wait_times[Difficulty_level]/2; + Ai_local_info[OBJECT_NUMBER(objp)].mode = AIM_THIEF_RETREAT; } } ai_turn_towards_vector(vec_to_player, objp, F1_0/4); @@ -1592,7 +1592,7 @@ int attempt_to_steal_item_3(object *objp, int player_num) { int i; - if (Ai_local_info[objp-Objects].mode != AIM_THIEF_ATTACK) + if (Ai_local_info[OBJECT_NUMBER(objp)].mode != AIM_THIEF_ATTACK) return 0; // First, try to steal equipped items. @@ -1682,8 +1682,8 @@ int attempt_to_steal_item(object *objp, int player_num) // -- mprintf((0, "%i items were stolen!\n", rval)); create_n_segment_path(objp, 10, ConsoleObject->segnum); - Ai_local_info[objp-Objects].next_action_time = Thief_wait_times[Difficulty_level]/2; - Ai_local_info[objp-Objects].mode = AIM_THIEF_RETREAT; + Ai_local_info[OBJECT_NUMBER(objp)].next_action_time = Thief_wait_times[Difficulty_level]/2; + Ai_local_info[OBJECT_NUMBER(objp)].mode = AIM_THIEF_RETREAT; if (rval) { PALETTE_FLASH_ADD(30, 15, -20); update_laser_weapon_info(); diff --git a/main/fireball.c b/main/fireball.c index 62942d08..40ba57db 100644 --- a/main/fireball.c +++ b/main/fireball.c @@ -298,7 +298,7 @@ object *explode_badass_weapon(object *obj,vms_vector *pos) if ((obj->id == EARTHSHAKER_ID) || (obj->id == ROBOT_EARTHSHAKER_ID)) smega_rock_stuff(); - digi_link_sound_to_object(SOUND_BADASS_EXPLOSION, obj-Objects, 0, F1_0); + digi_link_sound_to_object(SOUND_BADASS_EXPLOSION, OBJECT_NUMBER(obj), 0, F1_0); return object_create_badass_explosion(obj, obj->segnum, pos, wi->impact_size, @@ -317,9 +317,9 @@ object *explode_badass_object(object *objp, fix damage, fix distance, fix force) rval = object_create_badass_explosion(objp, objp->segnum, &objp->pos, objp->size, get_explosion_vclip(objp, 0), damage, distance, force, - objp-Objects); + OBJECT_NUMBER(objp)); if (rval) - digi_link_sound_to_object(SOUND_BADASS_EXPLOSION, rval-Objects, 0, F1_0); + digi_link_sound_to_object(SOUND_BADASS_EXPLOSION, OBJECT_NUMBER(rval), 0, F1_0); return (rval); @@ -391,7 +391,7 @@ object *object_create_debris(object *parent, int subobj_num) void draw_fireball(object *obj) { - //mprintf( 0, "[Drawing obj %d type %d fireball size %x]\n", obj-Objects, obj->id, obj->size ); + //mprintf( 0, "[Drawing obj %d type %d fireball size %x]\n", OBJECT_NUMBER(obj), obj->id, obj->size ); if ( obj->lifeleft > 0 ) draw_vclip_object(obj,obj->lifeleft,0, obj->id); @@ -767,7 +767,7 @@ void maybe_replace_powerup_with_energy(object *del_obj) // If this robot was gated in by the boss and it now contains energy, make it contain nothing, // else the room gets full of energy. if ( (del_obj->matcen_creator == BOSS_GATE_MATCEN_NUM) && (del_obj->contains_id == POW_ENERGY) && (del_obj->contains_type == OBJ_POWERUP) ) { - mprintf((0, "Converting energy powerup to nothing because robot %i gated in by boss.\n", del_obj-Objects)); + mprintf((0, "Converting energy powerup to nothing because robot %i gated in by boss.\n", OBJECT_NUMBER(del_obj))); del_obj->contains_count = 0; } @@ -946,8 +946,8 @@ int drop_powerup(int type, int id, int num, vms_vector *init_vel, vms_vector *po obj->shields = Robot_info[obj->id].strength; obj->ctype.ai_info.behavior = AIB_NORMAL; - Ai_local_info[obj-Objects].player_awareness_type = PA_WEAPON_ROBOT_COLLISION; - Ai_local_info[obj-Objects].player_awareness_time = F1_0*3; + Ai_local_info[OBJECT_NUMBER(obj)].player_awareness_type = PA_WEAPON_ROBOT_COLLISION; + Ai_local_info[OBJECT_NUMBER(obj)].player_awareness_time = F1_0*3; obj->ctype.ai_info.CURRENT_STATE = AIS_LOCK; obj->ctype.ai_info.GOAL_STATE = AIS_LOCK; obj->ctype.ai_info.REMOTE_OWNER = -1; @@ -1127,7 +1127,7 @@ void explode_object(object *hitobj,fix delay_time) //now set explosion-specific data obj->lifeleft = delay_time; - obj->ctype.expl_info.delete_objnum = hitobj-Objects; + obj->ctype.expl_info.delete_objnum = OBJECT_NUMBER(hitobj); #ifndef NDEBUG if (obj->ctype.expl_info.delete_objnum < 0) Int3(); // See Rob! @@ -1187,7 +1187,7 @@ void do_explosion_sequence(object *obj) { Assert(obj->control_type == CT_EXPLOSION); - //mprintf( 0, "Object %d life left is %d\n", obj-Objects, obj->lifeleft ); + //mprintf( 0, "Object %d life left is %d\n", OBJECT_NUMBER(obj), obj->lifeleft ); //See if we should die of old age if (obj->lifeleft <= 0 ) { // We died of old age @@ -1254,7 +1254,7 @@ void do_explosion_sequence(object *obj) // mprintf( 0, "Spawned an explosion of type %d\n", Robot_info[del_obj->id].exp2_vclip_num ); - //mprintf( 0, "Object %d spawned.\n", obj-Objects ); + //mprintf( 0, "Object %d spawned.\n", OBJECT_NUMBER(obj) ); //mprintf( 0, "Explosion at %d,%d,%d\n", obj->pos.x, obj->pos.y, obj->pos.z ); //mprintf( 0, "Explosion at %d,%d,%d\n", obj->pos.x, obj->pos.y, obj->pos.z ); //mprintf( 0, "Spawned exp at %d,%d,%d\n", expl_obj->pos.x, expl_obj->pos.y, expl_obj->pos.z ); @@ -1274,7 +1274,7 @@ void do_explosion_sequence(object *obj) } expl_obj->ctype.expl_info.delete_time = expl_obj->lifeleft/2; - expl_obj->ctype.expl_info.delete_objnum = del_obj-Objects; + expl_obj->ctype.expl_info.delete_objnum = OBJECT_NUMBER(del_obj); #ifndef NDEBUG if (obj->ctype.expl_info.delete_objnum < 0) Int3(); // See Rob! diff --git a/main/fuelcen.c b/main/fuelcen.c index 01df3a3f..b2d557ca 100644 --- a/main/fuelcen.c +++ b/main/fuelcen.c @@ -370,7 +370,7 @@ object * create_morph_robot( segment *segp, vms_vector *object_pos, int object_i default_behavior = Robot_info[obj->id].behavior; - init_ai_object(obj-Objects, default_behavior, -1 ); // Note, -1 = segment this robot goes to to hide, should probably be something useful + init_ai_object( OBJECT_NUMBER(obj), default_behavior, -1 ); // Note, -1 = segment this robot goes to to hide, should probably be something useful create_n_segment_path(obj, 6, -1); // Create a 6 segment path from creation point. @@ -565,7 +565,7 @@ void robotmaker_proc( FuelCenter * robotcen ) #ifndef SHAREWARE #ifdef NETWORK if (Game_mode & GM_MULTI) - multi_send_create_robot(robotcen-Station, obj-Objects, type); + multi_send_create_robot(robotcen-Station, OBJECT_NUMBER(obj), type); #endif #endif obj->matcen_creator = (robotcen-Station) | 0x80; diff --git a/main/game.c b/main/game.c index e94542da..53380953 100644 --- a/main/game.c +++ b/main/game.c @@ -910,7 +910,7 @@ void move_player_2_segment(segment *seg,int side) vm_vec_sub2(&vp,&ConsoleObject->pos); vm_vector_2_matrix(&ConsoleObject->orient,&vp,NULL,NULL); - obj_relink( ConsoleObject-Objects, SEG_PTR_2_NUM(seg) ); + obj_relink( OBJECT_NUMBER(ConsoleObject), SEG_PTR_2_NUM(seg) ); } @@ -1781,7 +1781,7 @@ void game_setup(void) #ifdef EDITOR if (Segments[ConsoleObject->segnum].segnum == -1) //segment no longer exists - obj_relink( ConsoleObject-Objects, SEG_PTR_2_NUM(Cursegp) ); + obj_relink( OBJECT_NUMBER(ConsoleObject), SEG_PTR_2_NUM(Cursegp) ); if (!check_obj_seg(ConsoleObject)) move_player_2_segment(Cursegp,Curside); diff --git a/main/gamecntl.c b/main/gamecntl.c index 2007e416..e91a7c56 100644 --- a/main/gamecntl.c +++ b/main/gamecntl.c @@ -1629,7 +1629,7 @@ void kill_and_so_forth(void) for (j=0; jpos, &Segments[Walls[j].segnum]); - obj_relink(ConsoleObject-Objects,Walls[j].segnum); + obj_relink(OBJECT_NUMBER(ConsoleObject), Walls[j].segnum); goto kasf_done; } } @@ -2369,7 +2369,7 @@ void speedtest_frame(void) compute_segment_center(&Viewer->pos, &Segments[Speedtest_segnum]); Viewer->pos.x += 0x10; Viewer->pos.y -= 0x10; Viewer->pos.z += 0x17; - obj_relink(Viewer-Objects, Speedtest_segnum); + obj_relink(OBJECT_NUMBER(Viewer), Speedtest_segnum); compute_center_point_on_side(¢er_point, &Segments[Speedtest_segnum], Speedtest_sidenum); vm_vec_normalized_dir_quick(&view_dir, ¢er_point, &Viewer->pos); vm_vector_2_matrix(&Viewer->orient, &view_dir, NULL, NULL); diff --git a/main/gamerend.c b/main/gamerend.c index 6b269b60..e3b82471 100644 --- a/main/gamerend.c +++ b/main/gamerend.c @@ -251,7 +251,7 @@ void draw_window_label() } gr_set_fontcolor( gr_getcolor(31, 0, 0), -1 ); - gr_printf( 0x8000, 45, "%i: %s [%s] View - %s",Viewer-Objects, viewer_name, viewer_id, control_name ); + gr_printf( 0x8000, 45, "%i: %s [%s] View - %s", OBJECT_NUMBER(Viewer), viewer_name, viewer_id, control_name ); } } diff --git a/main/gameseg.c b/main/gameseg.c index 6d2a3e48..930e28e1 100644 --- a/main/gameseg.c +++ b/main/gameseg.c @@ -1233,7 +1233,7 @@ void extract_shortpos(object *objp, shortpos *spp, int swap_bytes) objp->mtype.phys_info.velocity.y = (spp->vely << VEL_PRECISION); objp->mtype.phys_info.velocity.z = (spp->velz << VEL_PRECISION); - obj_relink(objp-Objects, segnum); + obj_relink(OBJECT_NUMBER(objp), segnum); // mprintf((0, "Matrix: %08x %08x %08x %08x %08x %08x\n", objp->orient.m1,objp->orient.m2,objp->orient.m3, // spp->bytemat[0],spp->bytemat[1],spp->bytemat[2])); diff --git a/main/gameseq.c b/main/gameseq.c index a78d663b..3a0a584e 100644 --- a/main/gameseq.c +++ b/main/gameseq.c @@ -660,7 +660,7 @@ void create_player_appearance_effect(object *player_obj) #ifndef NDEBUG { - int objnum = player_obj-Objects; + int objnum = OBJECT_NUMBER(player_obj); if ( (objnum < 0) || (objnum > Highest_object_index) ) Int3(); // See Rob, trying to track down weird network bug } @@ -677,7 +677,7 @@ void create_player_appearance_effect(object *player_obj) effect_obj->orient = player_obj->orient; if ( Vclip[VCLIP_PLAYER_APPEARANCE].sound_num > -1 ) - digi_link_sound_to_object( Vclip[VCLIP_PLAYER_APPEARANCE].sound_num, effect_obj-Objects, 0, F1_0); + digi_link_sound_to_object( Vclip[VCLIP_PLAYER_APPEARANCE].sound_num, OBJECT_NUMBER(effect_obj), 0, F1_0 ); } } @@ -2111,7 +2111,7 @@ void InitPlayerPosition(int random_flag) // -- mprintf((0, "Re-starting in location %d of %d.\n", NewPlayer+1, NumNetPlayerPositions)); - obj_relink(ConsoleObject-Objects,Player_init[NewPlayer].segnum); + obj_relink(OBJECT_NUMBER(ConsoleObject), Player_init[NewPlayer].segnum); #ifdef NETWORK done: diff --git a/main/gauges.c b/main/gauges.c index ee9bbc15..4a57a9ed 100644 --- a/main/gauges.c +++ b/main/gauges.c @@ -2751,7 +2751,7 @@ int see_object(int objnum) fq.p0 = &Viewer->pos; fq.p1 = &Objects[objnum].pos; fq.rad = 0; - fq.thisobjnum = Viewer - Objects; + fq.thisobjnum = OBJECT_NUMBER(Viewer); fq.flags = FQ_TRANSWALL | FQ_CHECK_OBJS; fq.startseg = Viewer->segnum; fq.ignore_obj_list = NULL; diff --git a/main/laser.c b/main/laser.c index f222e6de..bd38fafc 100644 --- a/main/laser.c +++ b/main/laser.c @@ -109,7 +109,7 @@ void Laser_render(object *obj) switch( Weapon_info[obj->id].render_type ) { case WEAPON_RENDER_LASER: Int3(); // Not supported anymore! - //Laser_draw_one(obj-Objects, Weapon_info[obj->id].bitmap ); + //Laser_draw_one( OBJECT_NUMBER(obj), Weapon_info[obj->id].bitmap ); break; case WEAPON_RENDER_BLOB: draw_object_blob(obj, Weapon_info[obj->id].bitmap ); @@ -454,7 +454,7 @@ void create_omega_blobs(int firing_segnum, vms_vector *firing_pos, vms_vector *g objp->ctype.laser_info.parent_type = parent_objp->type; objp->ctype.laser_info.parent_signature = parent_objp->signature; - objp->ctype.laser_info.parent_num = parent_objp-Objects; + objp->ctype.laser_info.parent_num = OBJECT_NUMBER(parent_objp); objp->movement_type = MT_NONE; // Only last one moves, that will get bashed below. } @@ -540,7 +540,7 @@ void do_omega_stuff(object *parent_objp, vms_vector *firing_pos, object *weapon_ if (pnum == Player_num) { // If charge >= min, or (some charge and zero energy), allow to fire. if (!((Omega_charge >= MIN_OMEGA_CHARGE) || (Omega_charge && !Players[pnum].energy))) { - obj_delete(weapon_objp-Objects); + obj_delete(OBJECT_NUMBER(weapon_objp)); return; } @@ -574,7 +574,7 @@ void do_omega_stuff(object *parent_objp, vms_vector *firing_pos, object *weapon_ // -- } // Delete the original object. Its only purpose in life was to determine which object to home in on. - obj_delete(weapon_objp-Objects); + obj_delete(OBJECT_NUMBER(weapon_objp)); // If couldn't lock on anything, fire straight ahead. if (lock_objnum == -1) { @@ -595,7 +595,7 @@ void do_omega_stuff(object *parent_objp, vms_vector *firing_pos, object *weapon_ fq.p0 = firing_pos; fq.p1 = &goal_pos; fq.rad = 0; - fq.thisobjnum = parent_objp-Objects; + fq.thisobjnum = OBJECT_NUMBER(parent_objp); fq.ignore_obj_list = NULL; fq.flags = FQ_IGNORE_POWERUPS | FQ_TRANSPOINT | FQ_CHECK_OBJS; //what about trans walls??? @@ -741,7 +741,7 @@ int Laser_create_new( vms_vector * direction, vms_vector * position, int segnum, volume = F1_0; if (Weapon_info[obj->id].flash_sound > -1 ) { if (make_sound) { - if ( parent == (Viewer-Objects) ) { + if ( parent == OBJECT_NUMBER(Viewer) ) { if (weapon_type == VULCAN_ID) // Make your own vulcan gun 1/2 as loud. volume = F1_0 / 2; digi_play_sample( Weapon_info[obj->id].flash_sound, volume ); @@ -765,7 +765,7 @@ int Laser_create_new( vms_vector * direction, vms_vector * position, int segnum, // mprintf(0, "Warning: Laser tip not in same segment as player.\n"); if (end_segnum != -1) { obj->pos = end_pos; - obj_relink(obj-Objects, end_segnum); + obj_relink(OBJECT_NUMBER(obj), end_segnum); } else mprintf((0, "Warning: Laser tip outside mine. Laser not being moved to end of gun.\n")); } else @@ -833,7 +833,7 @@ int Laser_create_new_easy( vms_vector * direction, vms_vector * position, int pa fq.startseg = pobjp->segnum; fq.p1 = position; fq.rad = 0; - fq.thisobjnum = pobjp-Objects; + fq.thisobjnum = OBJECT_NUMBER(pobjp); fq.ignore_obj_list = NULL; fq.flags = FQ_TRANSWALL | FQ_CHECK_OBJS; //what about trans walls??? @@ -864,7 +864,7 @@ int object_to_object_visibility(object *obj1, object *obj2, int trans_type) fq.startseg = obj1->segnum; fq.p1 = &obj2->pos; fq.rad = 0x10; - fq.thisobjnum = obj1-Objects; + fq.thisobjnum = OBJECT_NUMBER(obj1); fq.ignore_obj_list = NULL; fq.flags = trans_type; @@ -990,7 +990,7 @@ int find_homing_object(vms_vector *curpos, object *tracker) // Not in network mode. If not fired by player, then track player. if (tracker->ctype.laser_info.parent_num != Players[Player_num].objnum) { if (!(Players[Player_num].flags & PLAYER_FLAGS_CLOAKED)) - best_objnum = ConsoleObject - Objects; + best_objnum = OBJECT_NUMBER(ConsoleObject); } else { int window_num = -1; fix dist, max_trackable_dist; @@ -1045,7 +1045,7 @@ int find_homing_object(vms_vector *curpos, object *tracker) // Note: This uses the constant, not-scaled-by-frametime value, because it is only used // to determine if an object is initially trackable. find_homing_object is called on subsequent // frames to determine if the object remains trackable. - // mprintf((0, "find_homing_object: [%3i] %7.3f, min = %7.3f\n", curobjp-Objects, f2fl(dot), f2fl(MIN_TRACKABLE_DOT))); + // mprintf((0, "find_homing_object: [%3i] %7.3f, min = %7.3f\n", OBJECT_NUMBER(curobjp), f2fl(dot), f2fl(MIN_TRACKABLE_DOT))); if (dot > cur_min_trackable_dot) { if (dot > max_dot) { if (object_to_object_visibility(tracker, &Objects[objnum], FQ_TRANSWALL)) { @@ -1155,7 +1155,7 @@ int find_homing_object_complete(vms_vector *curpos, object *tracker, int track_o // Note: This uses the constant, not-scaled-by-frametime value, because it is only used // to determine if an object is initially trackable. find_homing_object is called on subsequent // frames to determine if the object remains trackable. - // mprintf((0, "fho_complete: [%3i] %7.3f, min = %7.3f\n", curobjp-Objects, f2fl(dot), f2fl(MIN_TRACKABLE_DOT))); + // mprintf((0, "fho_complete: [%3i] %7.3f, min = %7.3f\n", OBJECT_NUMBER(curobjp), f2fl(dot), f2fl(MIN_TRACKABLE_DOT))); if (dot > min_trackable_dot) { // mprintf(0, "Object %i: dist = %7.3f, dot = %7.3f\n", objnum, f2fl(dist), f2fl(dot)); if (dot > max_dot) { @@ -1181,10 +1181,10 @@ int find_homing_object_complete(vms_vector *curpos, object *tracker, int track_o int track_track_goal(int track_goal, object *tracker, fix *dot) { // Every 8 frames for each object, scan all objects. - if (object_is_trackable(track_goal, tracker, dot) && ((((tracker-Objects) ^ FrameCount) % 8) != 0)) { + if (object_is_trackable(track_goal, tracker, dot) && (((OBJECT_NUMBER(tracker) ^ FrameCount) % 8) != 0)) { //mprintf((0, "ttg: QO")); return track_goal; - } else if ((((tracker-Objects) ^ FrameCount) % 4) == 0) { + } else if (((OBJECT_NUMBER(tracker) ^ FrameCount) % 4) == 0) { int rval = -2; // If player fired missile, then search for an object, if not, then give up. @@ -1233,7 +1233,7 @@ int track_track_goal(int track_goal, object *tracker, fix *dot) } //if (track_goal != -1) -// mprintf((0, "Object %i not tracking anything.\n", tracker-Objects)); +// mprintf((0, "Object %i not tracking anything.\n", OBJECT_NUMBER(tracker))); return -1; } @@ -1271,7 +1271,7 @@ void Laser_player_fire_spread_delay(object *obj, int laser_type, int gun_num, fi fq.startseg = obj->segnum; fq.p1 = &LaserPos; fq.rad = 0x10; - fq.thisobjnum = obj-Objects; + fq.thisobjnum = OBJECT_NUMBER(obj); fq.ignore_obj_list = NULL; fq.flags = FQ_CHECK_OBJS | FQ_IGNORE_POWERUPS; @@ -1311,7 +1311,7 @@ void Laser_player_fire_spread_delay(object *obj, int laser_type, int gun_num, fi vm_vec_scale_add2(&LaserDir, &obj->orient.uvec, spreadu); } - objnum = Laser_create_new( &LaserDir, &LaserPos, LaserSeg, obj-Objects, laser_type, make_sound ); + objnum = Laser_create_new( &LaserDir, &LaserPos, LaserSeg, OBJECT_NUMBER(obj), laser_type, make_sound ); // Omega cannon is a hack, not surprisingly. Don't want to do the rest of this stuff. if (laser_type == OMEGA_ID) @@ -1498,7 +1498,7 @@ void Laser_do_weapon_sequence(object *obj) (obj->id != FLARE_ID) && (Weapon_info[obj->id].speed[Difficulty_level] > 0) && (vm_vec_mag_quick(&obj->mtype.phys_info.velocity) < F2_0)) { - obj_delete(obj-Objects); + obj_delete(OBJECT_NUMBER(obj)); return; } @@ -1551,7 +1551,7 @@ void Laser_do_weapon_sequence(object *obj) // If it's time to do tracking, then it's time to grow up, stop bouncing and start exploding!. if ((obj->id == ROBOT_SMART_MINE_HOMING_ID) || (obj->id == ROBOT_SMART_HOMING_ID) || (obj->id == SMART_MINE_HOMING_ID) || (obj->id == PLAYER_SMART_HOMING_ID) || (obj->id == EARTHSHAKER_MEGA_ID)) { - // if (obj->mtype.phys_info.flags & PF_BOUNCE) mprintf(0, "Debouncing smart child %i\n", obj-Objects); + // if (obj->mtype.phys_info.flags & PF_BOUNCE) mprintf(0, "Debouncing smart child %i\n", OBJECT_NUMBER(obj)); obj->mtype.phys_info.flags &= ~PF_BOUNCE; } @@ -1601,7 +1601,7 @@ void Laser_do_weapon_sequence(object *obj) lifelost = fixmul(absdot*32, FrameTime); obj->lifeleft -= lifelost; - // -- mprintf((0, "Missile %3i, dot = %7.3f life lost = %7.3f, life left = %7.3f\n", obj-Objects, f2fl(dot), f2fl(lifelost), f2fl(obj->lifeleft))); + // -- mprintf((0, "Missile %3i, dot = %7.3f life lost = %7.3f, life left = %7.3f\n", OBJECT_NUMBER(obj), f2fl(dot), f2fl(lifelost), f2fl(obj->lifeleft))); } // Only polygon objects have visible orientation, so only they should turn. @@ -1862,7 +1862,7 @@ if (Zbonkers) { // -- { // -- if ((GameTime - Lightning_start_time < LIGHTNING_TIME) && (GameTime - Lightning_start_time > 0)) { // -- if (GameTime - Lightning_last_time > LIGHTNING_DELAY) { -// -- create_lightning_blobs(&ConsoleObject->orient.fvec, &ConsoleObject->pos, ConsoleObject->segnum, ConsoleObject-Objects); +// -- create_lightning_blobs(&ConsoleObject->orient.fvec, &ConsoleObject->pos, ConsoleObject->segnum, OBJECT_NUMBER(ConsoleObject)); // -- Lightning_last_time = GameTime; // -- } // -- } @@ -2068,7 +2068,7 @@ int create_homing_missile(object *objp, int goal_obj, int objtype, int make_soun } // Create a vector towards the goal, then add some noise to it. - objnum = Laser_create_new(&vector_to_goal, &objp->pos, objp->segnum, objp-Objects, objtype, make_sound); + objnum = Laser_create_new(&vector_to_goal, &objp->pos, objp->segnum, OBJECT_NUMBER(objp), objtype, make_sound); if (objnum == -1) return -1; @@ -2100,7 +2100,7 @@ void create_smart_children(object *objp, int num_smart_children) parent_num = objp->ctype.laser_info.parent_num; } else if (objp->type == OBJ_ROBOT) { parent_type = OBJ_ROBOT; - parent_num = objp-Objects; + parent_num = OBJECT_NUMBER(objp); } else { Int3(); // Hey, what kind of object is this!? parent_type = 0; diff --git a/main/lighting.c b/main/lighting.c index 352bfec7..e1dd0784 100644 --- a/main/lighting.c +++ b/main/lighting.c @@ -443,7 +443,7 @@ void set_dynamic_light(void) obj_intensity = compute_light_intensity(objnum); if (obj_intensity) { - apply_light(obj_intensity, obj->segnum, objpos, n_render_vertices, render_vertices, obj-Objects); + apply_light(obj_intensity, obj->segnum, objpos, n_render_vertices, render_vertices, OBJECT_NUMBER(obj)); new_lighting_objects[objnum] = 1; } @@ -630,7 +630,7 @@ fix compute_object_light(object *obj,vms_vector *rotated_pnt) { fix light; g3s_point objpnt; - int objnum = obj-Objects; + int objnum = OBJECT_NUMBER(obj); if (!rotated_pnt) { g3_rotate_point(&objpnt,&obj->pos); diff --git a/main/multi.c b/main/multi.c index 62b57082..cad0769d 100644 --- a/main/multi.c +++ b/main/multi.c @@ -1518,7 +1518,7 @@ multi_do_fire(char *buf) // mprintf((0,"multi_do_fire, weapon = %d\n",weapon)); if (weapon == FLARE_ADJUST) - Laser_player_fire( Objects+Players[(int)pnum].objnum, FLARE_ID, 6, 1, 0); + Laser_player_fire( &Objects[Players[(int)pnum].objnum], FLARE_ID, 6, 1, 0 ); else if (weapon >= MISSILE_ADJUST) { int weapon_id,weapon_gun; @@ -1532,7 +1532,7 @@ multi_do_fire(char *buf) Multi_is_guided=1; } - Laser_player_fire( Objects+Players[(int)pnum].objnum, weapon_id, weapon_gun, 1, 0 ); + Laser_player_fire( &Objects[Players[(int)pnum].objnum], weapon_id, weapon_gun, 1, 0 ); } else { fix save_charge = Fusion_charge; @@ -1715,7 +1715,7 @@ multi_do_player_explode(char *buf) multi_adjust_remote_cap (pnum); - objp = Objects+Players[pnum].objnum; + objp = &Objects[Players[pnum].objnum]; // objp->phys_info.velocity = *(vms_vector *)(buf+16); // 12 bytes // objp->pos = *(vms_vector *)(buf+28); // 12 bytes @@ -1829,7 +1829,7 @@ void multi_do_controlcen_destroy(char *buf) HUD_init_message(TXT_CONTROL_DESTROYED); if (objnum != -1) - net_destroy_controlcen(Objects+objnum); + net_destroy_controlcen(&Objects[objnum]); else net_destroy_controlcen(NULL); } @@ -2328,8 +2328,8 @@ multi_reset_player_object(object *objp) //Init physics for a non-console player - Assert(objp >= Objects); - Assert(objp <= Objects+Highest_object_index); + Assert(OBJECT_NUMBER(objp) >= 0); + Assert(OBJECT_NUMBER(objp) <= Highest_object_index); Assert((objp->type == OBJ_PLAYER) || (objp->type == OBJ_GHOST)); vm_vec_zero(&objp->mtype.phys_info.velocity); @@ -2834,10 +2834,10 @@ multi_send_position(int objnum) multibuf[count++] = (char)MULTI_POSITION; #ifndef WORDS_BIGENDIAN - create_shortpos((shortpos *)(multibuf+count), Objects+objnum,0); + create_shortpos((shortpos *)(multibuf+count), &Objects[objnum], 0); count += sizeof(shortpos); #else - create_shortpos(&sp, Objects+objnum, 1); + create_shortpos(&sp, &Objects[objnum], 1); memcpy(&(multibuf[count]), (ubyte *)(sp.bytemat), 9); count += 9; memcpy(&(multibuf[count]), (ubyte *)&(sp.xo), 14); @@ -3935,7 +3935,7 @@ void multi_do_guided (char *buf) } - if (Guided_missile[(int)pnum]-Objects<0 || Guided_missile[(int)pnum]-Objects > Highest_object_index) + if (OBJECT_NUMBER(Guided_missile[(int)pnum]) < 0 || OBJECT_NUMBER(Guided_missile[(int)pnum]) > Highest_object_index) { Int3(); // Get Jason immediately! return; diff --git a/main/multibot.c b/main/multibot.c index 702f783b..2edf9e5a 100644 --- a/main/multibot.c +++ b/main/multibot.c @@ -465,9 +465,9 @@ multi_send_robot_position_sub(int objnum) loc += 3; #ifndef WORDS_BIGENDIAN - create_shortpos((shortpos *)(multibuf+loc), Objects+objnum,0); loc += sizeof(shortpos); + create_shortpos((shortpos *)(multibuf+loc), &Objects[objnum], 0); loc += sizeof(shortpos); #else - create_shortpos(&sp, Objects+objnum, 1); + create_shortpos(&sp, &Objects[objnum], 1); memcpy(&(multibuf[loc]), (ubyte *)(sp.bytemat), 9); loc += 9; memcpy(&(multibuf[loc]), (ubyte *)&(sp.xo), 14); @@ -914,13 +914,13 @@ multi_explode_robot_sub(int botnum, int killer,char isthief) } else if (robot->ctype.ai_info.REMOTE_OWNER == Player_num) { - multi_drop_robot_powerups(robot-Objects); - multi_delete_controlled_robot(robot-Objects); + multi_drop_robot_powerups(OBJECT_NUMBER(robot)); + multi_delete_controlled_robot(OBJECT_NUMBER(robot)); } else if (robot->ctype.ai_info.REMOTE_OWNER == -1 && network_i_am_master()) { - multi_drop_robot_powerups(robot-Objects); - //multi_delete_controlled_robot(robot-Objects); + multi_drop_robot_powerups(OBJECT_NUMBER(robot)); + //multi_delete_controlled_robot(OBJECT_NUMBER(robot)); } if (isthief || Robot_info[robot->id].thief) @@ -1030,8 +1030,8 @@ multi_do_create_robot(char *buf) vm_vector_2_matrix( &obj->orient, &direction, &obj->orient.uvec, NULL); morph_start( obj ); - mprintf((1, "matcen created robot %d (remote %d)\n", obj-Objects, objnum)); - map_objnum_local_to_remote(obj-Objects, objnum, pnum); + mprintf((1, "matcen created robot %d (remote %d)\n", OBJECT_NUMBER(obj), objnum)); + map_objnum_local_to_remote(OBJECT_NUMBER(obj), objnum, pnum); Assert(obj->ctype.ai_info.REMOTE_OWNER == -1); } @@ -1091,16 +1091,16 @@ multi_do_boss_actions(char *buf) return; } compute_segment_center(&boss_obj->pos, &Segments[teleport_segnum]); - obj_relink(boss_obj-Objects, teleport_segnum); + obj_relink(OBJECT_NUMBER(boss_obj), teleport_segnum); Last_teleport_time = GameTime; vm_vec_sub(&boss_dir, &Objects[Players[pnum].objnum].pos, &boss_obj->pos); vm_vector_2_matrix(&boss_obj->orient, &boss_dir, NULL, NULL); digi_link_sound_to_pos( Vclip[VCLIP_MORPHING_ROBOT].sound_num, teleport_segnum, 0, &boss_obj->pos, 0 , F1_0); - digi_kill_sound_linked_to_object( boss_obj-Objects); - digi_link_sound_to_object2( SOUND_BOSS_SHARE_SEE, boss_obj-Objects, 1, F1_0, F1_0*512 ); // F1_0*512 means play twice as loud - Ai_local_info[boss_obj-Objects].next_fire = 0; + digi_kill_sound_linked_to_object( OBJECT_NUMBER(boss_obj) ); + digi_link_sound_to_object2( SOUND_BOSS_SHARE_SEE, OBJECT_NUMBER(boss_obj), 1, F1_0, F1_0*512 ); // F1_0*512 means play twice as loud + Ai_local_info[OBJECT_NUMBER(boss_obj)].next_fire = 0; if (boss_obj->ctype.ai_info.REMOTE_OWNER == Player_num) { @@ -1263,7 +1263,7 @@ multi_drop_robot_powerups(int objnum) if (egg_objnum >= 0) { // Transmit the object creation to the other players - mprintf((0, "Dropped %d powerups for robot %d.\n", Net_create_loc, del_obj-Objects)); + mprintf((0, "Dropped %d powerups for robot %d.\n", Net_create_loc, OBJECT_NUMBER(del_obj))); multi_send_create_robot_powerups(del_obj); } } @@ -1291,7 +1291,7 @@ void multi_robot_request_change(object *robot, int player_num) return; } - remote_objnum = objnum_local_to_remote(robot-Objects, &dummy); + remote_objnum = objnum_local_to_remote(OBJECT_NUMBER(robot), &dummy); if (remote_objnum < 0) return; @@ -1300,7 +1300,7 @@ void multi_robot_request_change(object *robot, int player_num) if ( (robot_agitation[slot] < 70) || (MULTI_ROBOT_PRIORITY(remote_objnum, player_num) > MULTI_ROBOT_PRIORITY(remote_objnum, Player_num)) || (d_rand() > 0x4400)) { - mprintf((0, "Robot %d (%d) released because it got hit by Player %d.\n", robot-Objects, remote_objnum, player_num)); + mprintf((0, "Robot %d (%d) released because it got hit by Player %d.\n", OBJECT_NUMBER(robot), remote_objnum, player_num)); if (robot_send_pending[slot]) multi_send_robot_position(robot_controlled[slot], -1); multi_send_release_robot(robot_controlled[slot]); diff --git a/main/network.c b/main/network.c index b2401d9a..d8c28522 100644 --- a/main/network.c +++ b/main/network.c @@ -2757,7 +2757,7 @@ network_read_object_packet( ubyte *data ) obj->next = obj->prev = obj->segnum = -1; obj->attached_obj = -1; if (segnum > -1) - obj_link(obj-Objects,segnum); + obj_link(OBJECT_NUMBER(obj), segnum); if (obj_owner == my_pnum) map_objnum_local_to_local(objnum); else if (obj_owner != -1) @@ -5081,7 +5081,7 @@ void network_do_frame(int force, int listen) ubyte send_data[IPX_MAX_DATA_SIZE]; //int squished_size; #endif - create_shortpos(&ShortSyncPack.thepos, Objects+objnum, 0); + create_shortpos(&ShortSyncPack.thepos, &Objects[objnum], 0); ShortSyncPack.type = PID_PDATA; ShortSyncPack.playernum = Player_num; ShortSyncPack.obj_render_type = Objects[objnum].render_type; diff --git a/main/newdemo.c b/main/newdemo.c index 88780948..a0ab8f42 100644 --- a/main/newdemo.c +++ b/main/newdemo.c @@ -933,7 +933,7 @@ void newdemo_record_start_frame(int frame_number, fix frame_time ) void newdemo_record_render_object(object * obj) { - if (ViewWasRecorded[obj-Objects]) + if (ViewWasRecorded[OBJECT_NUMBER(obj)]) return; //if (obj==&Objects[Players[Player_num].objnum] && !Player_is_dead) @@ -950,14 +950,14 @@ extern ubyte RenderingType; void newdemo_record_viewer_object(object * obj) { - if (ViewWasRecorded[obj-Objects] && (ViewWasRecorded[obj-Objects]-1)==RenderingType) + if (ViewWasRecorded[OBJECT_NUMBER(obj)] && (ViewWasRecorded[OBJECT_NUMBER(obj)] - 1) == RenderingType) return; - //if (WasRecorded[obj-Objects]) + //if (WasRecorded[OBJECT_NUMBER(obj)]) // return; if (RenderingWasRecorded[RenderingType]) return; - ViewWasRecorded[obj-Objects]=RenderingType+1; + ViewWasRecorded[OBJECT_NUMBER(obj)] = RenderingType + 1; RenderingWasRecorded[RenderingType]=1; stop_time(); nd_write_byte(ND_EVENT_VIEWER_OBJECT); @@ -1664,7 +1664,7 @@ int newdemo_read_frame_information() if (segnum > Highest_segment_index) segnum = 0; - obj_link(Viewer-Objects,segnum); + obj_link(OBJECT_NUMBER(Viewer), segnum); } } break; @@ -1686,7 +1686,7 @@ int newdemo_read_frame_information() if (segnum > Highest_segment_index) break; - obj_link(obj-Objects,segnum); + obj_link(OBJECT_NUMBER(obj), segnum); #ifdef NETWORK if ((obj->type == OBJ_PLAYER) && (Newdemo_game_mode & GM_MULTI)) { int player; @@ -1837,7 +1837,7 @@ int newdemo_read_frame_information() if (Newdemo_vcr_state != ND_STATE_PAUSED) { segnum = obj->segnum; obj->next = obj->prev = obj->segnum = -1; - obj_link(obj-Objects,segnum); + obj_link(OBJECT_NUMBER(obj), segnum); } } break; diff --git a/main/object.c b/main/object.c index 7506f6d4..b4c07ed4 100644 --- a/main/object.c +++ b/main/object.c @@ -161,7 +161,7 @@ void object_goto_next_viewer() { int i, start_obj = 0; - start_obj = Viewer - Objects; //get viewer object number + start_obj = OBJECT_NUMBER(Viewer); // get viewer object number for (i=0;i<=Highest_object_index;i++) { @@ -183,7 +183,7 @@ void object_goto_prev_viewer() { int i, start_obj = 0; - start_obj = Viewer - Objects; //get viewer object number + start_obj = OBJECT_NUMBER(Viewer); // get viewer object number for (i=0; i<=Highest_object_index; i++) { @@ -240,7 +240,7 @@ void draw_object_blob(object *obj,bitmap_index bmi) if (obj->type == OBJ_FIREBALL) - orientation = (obj-Objects) & 7; + orientation = OBJECT_NUMBER(obj) & 7; orientation = global_orientation; @@ -508,7 +508,7 @@ void draw_polygon_object(object *obj) #endif // Snipers get bright when they fire. - if (Ai_local_info[obj-Objects].next_fire < F1_0/8) { + if (Ai_local_info[OBJECT_NUMBER(obj)].next_fire < F1_0/8) { if (obj->ctype.ai_info.behavior == AIB_SNIPE) light = 2*light + F1_0; } @@ -651,7 +651,7 @@ void create_small_fireball_on_object(object *objp, fix size_scale, int sound_fla if (objp->type == OBJ_ROBOT) vol *= 2; else if (sound_flag) - digi_link_sound_to_object(SOUND_EXPLODING_WALL, objp-Objects, 0, vol); + digi_link_sound_to_object(SOUND_EXPLODING_WALL, OBJECT_NUMBER(objp), 0, vol); } } } @@ -706,7 +706,7 @@ void render_object(object *obj) if ( obj->type==OBJ_NONE ) { #ifndef NDEBUG - mprintf( (1, "ERROR!!!! Bogus obj %d in seg %d is rendering!\n", obj-Objects, obj->segnum )); + mprintf( (1, "ERROR!!!! Bogus obj %d in seg %d is rendering!\n", OBJECT_NUMBER(obj), obj->segnum) ); Int3(); #endif return; @@ -754,9 +754,9 @@ void render_object(object *obj) #ifdef NEWDEMO if ( obj->render_type != RT_NONE ) if ( Newdemo_state == ND_STATE_RECORDING ) { - if (!WasRecorded[obj-Objects]) { + if (!WasRecorded[OBJECT_NUMBER(obj)]) { newdemo_record_render_object(obj); - WasRecorded[obj-Objects]=1; + WasRecorded[OBJECT_NUMBER(obj)] = 1; } } #endif @@ -805,7 +805,7 @@ void render_object(object *obj) //--unused-- int w, h, aw; //--unused-- char s[20], *s1; //--unused-- -//--unused-- s1 = network_get_player_name( obj-Objects ); +//--unused-- s1 = network_get_player_name( OBJECT_NUMBER(obj) ); //--unused-- //--unused-- if (s1) //--unused-- sprintf( s, "%s", s1 ); @@ -903,7 +903,7 @@ void init_objects() ConsoleObject = Viewer = &Objects[0]; init_player_object(); - obj_link(ConsoleObject-Objects,0); //put in the world in segment 0 + obj_link(OBJECT_NUMBER(ConsoleObject), 0); // put in the world in segment 0 num_objects = 1; //just the player Highest_object_index = 0; @@ -1484,7 +1484,7 @@ void dead_player_end(void) Player_is_dead = 0; Player_exploded = 0; - obj_delete(Dead_player_camera-Objects); + obj_delete(OBJECT_NUMBER(Dead_player_camera)); Dead_player_camera = NULL; select_cockpit(Cockpit_mode_save); Cockpit_mode_save = -1; @@ -1538,7 +1538,7 @@ void set_camera_pos(vms_vector *camera_pos, object *objp) fq.p1 = &local_p1; fq.startseg = objp->segnum; fq.rad = 0; - fq.thisobjnum = objp-Objects; + fq.thisobjnum = OBJECT_NUMBER(objp); fq.ignore_obj_list = NULL; fq.flags = 0; find_vector_intersection( &fq, &hit_data); @@ -1735,7 +1735,7 @@ void start_player_death_sequence(object *player) HUD_clear_messages(); Killed_in_frame = FrameCount; - Killed_objnum = player-Objects; + Killed_objnum = OBJECT_NUMBER(player); Death_sequence_aborted = 0; #ifdef NETWORK @@ -1815,7 +1815,7 @@ void obj_delete_all_that_should_be_dead() if ( objp->id == Player_num ) { if (local_dead_player_object == -1) { start_player_death_sequence(objp); - local_dead_player_object = objp-Objects; + local_dead_player_object = OBJECT_NUMBER(objp); } else Int3(); // Contact Mike: Illegal, killed player twice in this frame! // Ok to continue, won't start death sequence again! @@ -1927,7 +1927,7 @@ void object_move_one( object * obj ) case CT_FLYING: #if !defined(NDEBUG) && !defined(NMONO) - if (print_object_info>1) mprintf( (0, "Moving player object #%d\n", obj-Objects )); + if (print_object_info > 1) mprintf( (0, "Moving player object #%d\n", OBJECT_NUMBER(obj)) ); #endif read_flying_controls( obj ); @@ -1947,7 +1947,7 @@ void object_move_one( object * obj ) if (Game_suspended & SUSP_ROBOTS) return; #if !defined(NDEBUG) && !defined(NMONO) if (print_object_info>1) - mprintf( (0, "AI: Moving robot object #%d\n",obj-Objects )); + mprintf( (0, "AI: Moving robot object #%d\n", OBJECT_NUMBER(obj)) ); #endif do_ai_frame(obj); break; @@ -1983,7 +1983,7 @@ void object_move_one( object * obj ) default: - Error("Unknown control type %d in object %li, sig/type/id = %i/%i/%i",obj->control_type, obj-Objects, obj->signature, obj->type, obj->id); + Error("Unknown control type %d in object %li, sig/type/id = %i/%i/%i", obj->control_type, OBJECT_NUMBER(obj), obj->signature, obj->type, obj->id); break; @@ -2026,7 +2026,7 @@ void object_move_one( object * obj ) for (i=0;iid]) { - digi_link_sound_to_object3( sound, obj-Objects, 1, F1_0, i2f(256), -1, -1); + digi_link_sound_to_object3( sound, OBJECT_NUMBER(obj), 1, F1_0, i2f(256), -1, -1 ); lavafall_hiss_playing[obj->id] = 1; } } @@ -2065,7 +2065,7 @@ void object_move_one( object * obj ) } if (!under_lavafall && lavafall_hiss_playing[obj->id]) { - digi_kill_sound_linked_to_object( obj-Objects); + digi_kill_sound_linked_to_object( OBJECT_NUMBER(obj) ); lavafall_hiss_playing[obj->id] = 0; } } @@ -2100,7 +2100,7 @@ void object_move_one( object * obj ) } if ((obj->type == OBJ_WEAPON) && (Weapon_info[obj->id].afterburner_size)) { - int objnum = obj-Objects; + int objnum = OBJECT_NUMBER(obj); fix vel = vm_vec_mag_quick(&obj->mtype.phys_info.velocity); fix delay, lifetime; @@ -2265,7 +2265,7 @@ int update_object_seg(object * obj ) return 0; if ( newseg != obj->segnum ) - obj_relink(obj-Objects, newseg ); + obj_relink( OBJECT_NUMBER(obj), newseg ); return 1; } @@ -2361,15 +2361,15 @@ void obj_attach(object *parent,object *sub) sub->ctype.expl_info.next_attach = parent->attached_obj; if (sub->ctype.expl_info.next_attach != -1) - Objects[sub->ctype.expl_info.next_attach].ctype.expl_info.prev_attach = sub-Objects; + Objects[sub->ctype.expl_info.next_attach].ctype.expl_info.prev_attach = OBJECT_NUMBER(sub); - parent->attached_obj = sub-Objects; + parent->attached_obj = OBJECT_NUMBER(sub); - sub->ctype.expl_info.attach_parent = parent-Objects; + sub->ctype.expl_info.attach_parent = OBJECT_NUMBER(parent); sub->flags |= OF_ATTACHED; - Assert(sub->ctype.expl_info.next_attach != sub-Objects); - Assert(sub->ctype.expl_info.prev_attach != sub-Objects); + Assert(sub->ctype.expl_info.next_attach != OBJECT_NUMBER(sub)); + Assert(sub->ctype.expl_info.prev_attach != OBJECT_NUMBER(sub)); } //dettaches one object @@ -2385,16 +2385,16 @@ void obj_detach_one(object *sub) } if (sub->ctype.expl_info.next_attach != -1) { - Assert(Objects[sub->ctype.expl_info.next_attach].ctype.expl_info.prev_attach=sub-Objects); + Assert(Objects[sub->ctype.expl_info.next_attach].ctype.expl_info.prev_attach = OBJECT_NUMBER(sub)); Objects[sub->ctype.expl_info.next_attach].ctype.expl_info.prev_attach = sub->ctype.expl_info.prev_attach; } if (sub->ctype.expl_info.prev_attach != -1) { - Assert(Objects[sub->ctype.expl_info.prev_attach].ctype.expl_info.next_attach=sub-Objects); + Assert(Objects[sub->ctype.expl_info.prev_attach].ctype.expl_info.next_attach = OBJECT_NUMBER(sub)); Objects[sub->ctype.expl_info.prev_attach].ctype.expl_info.next_attach = sub->ctype.expl_info.next_attach; } else { - Assert(Objects[sub->ctype.expl_info.attach_parent].attached_obj=sub-Objects); + Assert(Objects[sub->ctype.expl_info.attach_parent].attached_obj = OBJECT_NUMBER(sub)); Objects[sub->ctype.expl_info.attach_parent].attached_obj = sub->ctype.expl_info.next_attach; } @@ -2447,7 +2447,7 @@ void wake_up_rendered_objects(object *viewer, int window_num) return; } - Ai_last_missile_camera = viewer-Objects; + Ai_last_missile_camera = OBJECT_NUMBER(viewer); for (i=0; ivelocity.x || pi->velocity.y || pi->velocity.z || pi->thrust.x || pi->thrust.y || pi->thrust.z)) return; - objnum = obj-Objects; + objnum = OBJECT_NUMBER(obj); n_phys_segs = 0; @@ -552,7 +552,7 @@ save_p1 = *fq.p1; #ifndef NDEBUG if (fate == HIT_BAD_P0) { - mprintf((0,"Warning: Bad p0 in physics! Object = %i, type = %i [%s]\n", obj-Objects, obj->type, Object_type_names[obj->type])); + mprintf((0, "Warning: Bad p0 in physics! Object = %i, type = %i [%s]\n", OBJECT_NUMBER(obj), obj->type, Object_type_names[obj->type])); Int3(); } #endif @@ -579,7 +579,7 @@ save_p1 = *fq.p1; if (iseg==-1) { //some sort of horrible error #ifndef NDEBUG - mprintf((1,"iseg==-1 in physics! Object = %i, type = %i (%s)\n", obj-Objects, obj->type, Object_type_names[obj->type])); + mprintf((1, "iseg==-1 in physics! Object = %i, type = %i (%s)\n", OBJECT_NUMBER(obj), obj->type, Object_type_names[obj->type])); #endif //Int3(); //compute_segment_center(&ipos,&Segments[obj->segnum]); @@ -645,7 +645,7 @@ save_p1 = *fq.p1; //don't change position or sim_time -//******* mprintf((0,"Obj %d moved backwards\n",obj-Objects)); +//******* mprintf((0, "Obj %d moved backwards\n", OBJECT_NUMBER(obj))); #ifdef EXTRA_DEBUG if (obj == debug_obj) @@ -723,7 +723,7 @@ save_p1 = *fq.p1; if (!forcefield_bounce && (obj->mtype.phys_info.flags & PF_STICK)) { //stop moving - // mprintf((0, "Object %i stuck at %i:%i\n", obj-Objects, WallHitSeg, WallHitSide)); + // mprintf((0, "Object %i stuck at %i:%i\n", OBJECT_NUMBER(obj), WallHitSeg, WallHitSide)); add_stuck_object(obj, WallHitSeg, WallHitSide); vm_vec_zero(&obj->mtype.phys_info.velocity); @@ -984,7 +984,7 @@ save_p1 = *fq.p1; //--unused-- //--unused-- Assert(obj->movement_type == MT_PHYSICS); //--unused-- -//--unused-- objnum = obj-Objects; +//--unused-- objnum = OBJECT_NUMBER(obj); //--unused-- //--unused-- vm_vec_scale_add(&new_pos, &obj->pos, &obj->mtype.phys_info.velocity, t); //--unused-- diff --git a/main/powerup.c b/main/powerup.c index a25f080f..3125ef64 100644 --- a/main/powerup.c +++ b/main/powerup.c @@ -74,7 +74,7 @@ void do_powerup_frame(object *obj) vclip_info *vci = &obj->rtype.vclip_info; vclip *vc = &Vclip[vci->vclip_num]; - fudge = (FrameTime * ((obj-Objects)&3)) >> 4; + fudge = (FrameTime * (OBJECT_NUMBER(obj)&3)) >> 4; vci->frametime -= FrameTime+fudge; @@ -82,7 +82,7 @@ void do_powerup_frame(object *obj) vci->frametime += vc->frame_time; - if ((obj-Objects)&1) + if (OBJECT_NUMBER(obj)&1) vci->framenum--; else vci->framenum++; @@ -98,7 +98,7 @@ void do_powerup_frame(object *obj) object_create_explosion(obj->segnum, &obj->pos, F1_0*7/2, VCLIP_POWERUP_DISAPPEARANCE ); if ( Vclip[VCLIP_POWERUP_DISAPPEARANCE].sound_num > -1 ) - digi_link_sound_to_object( Vclip[VCLIP_POWERUP_DISAPPEARANCE].sound_num, obj-Objects, 0, F1_0); + digi_link_sound_to_object( Vclip[VCLIP_POWERUP_DISAPPEARANCE].sound_num, OBJECT_NUMBER(obj), 0, F1_0 ); } } @@ -134,7 +134,7 @@ void draw_powerup(object *obj) draw_object_blob(obj, Vclip[obj->rtype.vclip_info.vclip_num].frames[obj->rtype.vclip_info.framenum] ); #ifdef EDITOR - if ((Function_mode == FMODE_EDITOR) && (Cur_object_index == obj-Objects)) + if ((Function_mode == FMODE_EDITOR) && (Cur_object_index == OBJECT_NUMBER(obj))) if (blob_vertices[0] != 0x80000) draw_blob_outline(); #endif @@ -700,7 +700,7 @@ int do_powerup(object *obj) multi_send_play_sound(Powerup_info[id].hit_sound, F1_0); #endif digi_play_sample( Powerup_info[id].hit_sound, F1_0 ); - detect_escort_goal_accomplished(obj-Objects); + detect_escort_goal_accomplished(OBJECT_NUMBER(obj)); } PlayerMessage=1; diff --git a/main/render.c b/main/render.c index 1215c73f..2e98d4ac 100644 --- a/main/render.c +++ b/main/render.c @@ -655,7 +655,7 @@ void render_object_search(object *obj) if (changed) { if (obj->segnum != -1) Cursegp = &Segments[obj->segnum]; - found_seg = -(obj-Objects+1); + found_seg = -(OBJECT_NUMBER(obj)+1); } } #endif @@ -1699,7 +1699,7 @@ void render_frame(fix eye_offset, int window_num) #ifdef NEWDEMO if ( Newdemo_state == ND_STATE_RECORDING && eye_offset >= 0 ) { - // mprintf ((0,"Objnum=%d objtype=%d objid=%d\n",Viewer-Objects,Viewer->type,Viewer->id)); + //mprintf((0, "Objnum=%d objtype=%d objid=%d\n", OBJECT_NUMBER(Viewer), Viewer->type, Viewer->id)); if (RenderingType==0) newdemo_record_start_frame(FrameCount, FrameTime ); @@ -2194,7 +2194,7 @@ void render_mine(int start_seg_num,fix eye_offset, int window_num) (Objects[ObjNumber].lifeleft==Laser_max_time ) && // and its in it's first frame (Hack_nlasers< MAX_HACKED_LASERS) && // and we have space for it (Objects[ObjNumber].laser_info.parent_num>-1) && // and it has a parent - ((Viewer-Objects)==Objects[ObjNumber].laser_info.parent_num) // and it's parent is the viewer + (OBJECT_NUMBER(Viewer) == Objects[ObjNumber].laser_info.parent_num) // and it's parent is the viewer ) { Hack_laser_list[Hack_nlasers++] = ObjNumber; //then make it draw after everything else. //mprintf( (0, "O%d ", ObjNumber )); diff --git a/main/vclip.c b/main/vclip.c index 9a8588a0..4e249739 100644 --- a/main/vclip.c +++ b/main/vclip.c @@ -71,7 +71,7 @@ void draw_weapon_vclip(object *obj) int vclip_num; fix modtime,play_time; - //mprintf( 0, "[Drawing obj %d type %d fireball size %x]\n", obj-Objects, Weapon_info[obj->id].weapon_vclip, obj->size ); + //mprintf( 0, "[Drawing obj %d type %d fireball size %x]\n", OBJECT_NUMBER(obj), Weapon_info[obj->id].weapon_vclip, obj->size ); Assert(obj->type == OBJ_WEAPON); @@ -89,7 +89,7 @@ void draw_weapon_vclip(object *obj) modtime = d_rand(); if (obj->id == PROXIMITY_ID) { //make prox bombs spin out of sync - int objnum = obj-Objects; + int objnum = OBJECT_NUMBER(obj); modtime += (modtime * (objnum&7)) / 16; //add variance to spin rate diff --git a/main/wall.c b/main/wall.c index 74515e34..eeb54437 100644 --- a/main/wall.c +++ b/main/wall.c @@ -1389,7 +1389,7 @@ void add_stuck_object(object *objp, int segnum, int sidenum) for (i=0; isignature; // mprintf((0, "Added wall %i at index %i\n", wallnum, i)); Num_stuck_objects++; @@ -1397,7 +1397,7 @@ void add_stuck_object(object *objp, int segnum, int sidenum) } } if (i == MAX_STUCK_OBJECTS) - mprintf((1, "Warning: Unable to add object %i which got stuck in wall %i to Stuck_objects\n", objp-Objects, wallnum)); + mprintf((1, "Warning: Unable to add object %i which got stuck in wall %i to Stuck_objects\n", OBJECT_NUMBER(objp), wallnum)); } @@ -1470,7 +1470,7 @@ void kill_stuck_objects(int wallnum) // -- unused -- if ((objp->type == OBJ_WEAPON) && (objp->id == FLARE_ID)) { // -- unused -- if (Walls[Stuck_objects[i].wallnum].segnum == segp-Segments) // -- unused -- if (Walls[Stuck_objects[i].wallnum].sidenum == sidenum) -// -- unused -- return objp-Objects; +// -- unused -- return OBJECT_NUMBER(objp); // -- unused -- } // -- unused -- } // -- unused -- -- 2.39.2