From c8c1489837cc63320dcd121aa0b2ccdc6a308baf Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 23 Mar 2013 18:46:12 +0000 Subject: [PATCH] Create struct reactor analogous to D2X --- main/bm.c | 6 +++--- main/bmread.c | 8 ++++---- main/cntrlcen.c | 17 ++++++++--------- main/cntrlcen.h | 13 ++++++++++--- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/main/bm.c b/main/bm.c index 9808b4517..faa0a6355 100644 --- a/main/bm.c +++ b/main/bm.c @@ -217,12 +217,12 @@ void properties_read_cmp(PHYSFS_file * fp) ObjStrength[i] = PHYSFSX_readFix(fp); First_multi_bitmap_num = PHYSFSX_readInt(fp); - N_controlcen_guns = PHYSFSX_readInt(fp); + Reactors[0].n_guns = PHYSFSX_readInt(fp); for (i = 0; i < MAX_CONTROLCEN_GUNS; i++) - PHYSFSX_readVector(&controlcen_gun_points[i], fp); + PHYSFSX_readVector(&Reactors[0].gun_points[i], fp); for (i = 0; i < MAX_CONTROLCEN_GUNS; i++) - PHYSFSX_readVector(&controlcen_gun_dirs[i], fp); + PHYSFSX_readVector(&Reactors[0].gun_dirs[i], fp); exit_modelnum = PHYSFSX_readInt(fp); destroyed_exit_modelnum = PHYSFSX_readInt(fp); diff --git a/main/bmread.c b/main/bmread.c index 96f4d395f..379d8c7fb 100644 --- a/main/bmread.c +++ b/main/bmread.c @@ -1224,7 +1224,7 @@ void bm_read_object(int skip) model_num = load_polygon_model(model_name,n_normal_bitmaps,first_bitmap_num,NULL); if (type == OL_CONTROL_CENTER) - N_controlcen_guns = read_model_guns(model_name,controlcen_gun_points,controlcen_gun_dirs,NULL); + Reactors[0].n_guns = read_model_guns(model_name,Reactors[0].gun_points,Reactors[0].gun_dirs,NULL); if ( model_name_dead ) Dead_modelnums[model_num] = load_polygon_model(model_name_dead,N_ObjBitmapPtrs-first_bitmap_num_dead,first_bitmap_num_dead,NULL); @@ -1846,9 +1846,9 @@ void bm_write_all(PHYSFS_file *fp) PHYSFS_write( fp, &First_multi_bitmap_num, sizeof(int), 1); - PHYSFS_write( fp, &N_controlcen_guns, sizeof(int), 1); - PHYSFS_write( fp, controlcen_gun_points, sizeof(vms_vector), MAX_CONTROLCEN_GUNS); - PHYSFS_write( fp, controlcen_gun_dirs, sizeof(vms_vector), MAX_CONTROLCEN_GUNS); + PHYSFS_write( fp, &Reactors[0].n_guns, sizeof(int), 1); + PHYSFS_write( fp, Reactors[0].gun_points, sizeof(vms_vector), MAX_CONTROLCEN_GUNS); + PHYSFS_write( fp, Reactors[0].gun_dirs, sizeof(vms_vector), MAX_CONTROLCEN_GUNS); PHYSFS_write( fp, &exit_modelnum, sizeof(int), 1); PHYSFS_write( fp, &destroyed_exit_modelnum, sizeof(int), 1); } diff --git a/main/cntrlcen.c b/main/cntrlcen.c index 9489ae9bc..149e4f56c 100644 --- a/main/cntrlcen.c +++ b/main/cntrlcen.c @@ -32,12 +32,10 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "endlevel.h" #include "byteswap.h" -vms_vector controlcen_gun_points[MAX_CONTROLCEN_GUNS]; -vms_vector controlcen_gun_dirs[MAX_CONTROLCEN_GUNS]; +reactor Reactors[MAX_REACTORS]; control_center_triggers ControlCenterTriggers; -int N_controlcen_guns; int Control_center_been_hit; int Control_center_player_been_seen; int Control_center_next_fire_time; @@ -51,20 +49,21 @@ void do_countdown_frame(); //return the position & orientation of a gun on the control center object void calc_controlcen_gun_point(vms_vector *gun_point,vms_vector *gun_dir,object *obj,int gun_num) { + reactor *reactor = &Reactors[0]; vms_matrix m; Assert(obj->type == OBJ_CNTRLCEN); Assert(obj->render_type==RT_POLYOBJ); - Assert(gun_num < N_controlcen_guns); + Assert(gun_num < reactor->n_guns); //instance gun position & orientation vm_copy_transpose_matrix(&m,&obj->orient); - vm_vec_rotate(gun_point,&controlcen_gun_points[gun_num],&m); + vm_vec_rotate(gun_point,&reactor->gun_points[gun_num],&m); vm_vec_add2(gun_point,&obj->pos); - vm_vec_rotate(gun_dir,&controlcen_gun_dirs[gun_num],&m); + vm_vec_rotate(gun_dir,&reactor->gun_dirs[gun_num],&m); } // ----------------------------------------------------------------------------- @@ -290,9 +289,9 @@ void do_controlcen_frame(object *obj) if ((Control_center_next_fire_time < 0) && !(controlcen_death_silence > F1_0*2)) { if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) - best_gun_num = calc_best_gun(N_controlcen_guns, Gun_pos, Gun_dir, &Believed_player_pos); + best_gun_num = calc_best_gun(Reactors[0].n_guns, Gun_pos, Gun_dir, &Believed_player_pos); else - best_gun_num = calc_best_gun(N_controlcen_guns, Gun_pos, Gun_dir, &ConsoleObject->pos); + best_gun_num = calc_best_gun(Reactors[0].n_guns, Gun_pos, Gun_dir, &ConsoleObject->pos); if (best_gun_num != -1) { vms_vector vec_to_goal; @@ -395,7 +394,7 @@ void init_controlcen_for_level(void) } else { // Compute all gun positions. objp = &Objects[cntrlcen_objnum]; - for (i=0; i