From 83c4959bc572c0288f7cb059edeed9fe6954bff4 Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Fri, 24 Dec 2004 05:17:09 +0000 Subject: [PATCH] Use macros to use Segment2s when necessary. --- ChangeLog | 8 ++++++++ main/editor/centers.c | 34 +++++++++++++++++++--------------- main/editor/editor.h | 4 +++- main/editor/eswitch.c | 7 ++++--- main/editor/group.c | 10 +++++----- main/editor/med.c | 18 +++++++++--------- main/editor/meddraw.c | 7 ++++--- main/editor/medwall.c | 10 +++++----- main/editor/mine.c | 32 ++++++++++++++++---------------- main/editor/seguvs.c | 16 ++++++++-------- main/segment.h | 5 ++++- 11 files changed, 85 insertions(+), 66 deletions(-) diff --git a/ChangeLog b/ChangeLog index 244526b2..4559d697 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-12-23 Bradley Bell + + * main/editor/centers.c, main/editor/editor.h, + main/editor/eswitch.c, main/editor/group.c, main/editor/med.c, + main/editor/meddraw.h, main/editor/medwall.c, main/editor/mine.c, + main/editor/seguvs.c, main/segment.h: Use macros to use Segment2s + when necessary. + 2004-12-21 Chris Taylor * main/bmread.c: don't duplicate the period in the filename diff --git a/main/editor/centers.c b/main/editor/centers.c index 78468ce6..602b7037 100644 --- a/main/editor/centers.c +++ b/main/editor/centers.c @@ -1,4 +1,4 @@ -/* $Id: centers.c,v 1.3 2004-12-19 15:21:11 btb Exp $ */ +/* $Id: centers.c,v 1.4 2004-12-24 05:17:09 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -19,7 +19,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ #ifdef RCS -static char rcsid[] = "$Id: centers.c,v 1.3 2004-12-19 15:21:11 btb Exp $"; +static char rcsid[] = "$Id: centers.c,v 1.4 2004-12-24 05:17:09 btb Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -145,15 +145,15 @@ void do_centers_window() CenterFlag[i]->status = 1; // Tells ui to redraw button } - Assert(Cursegp->special < MAX_CENTER_TYPES); - CenterFlag[Cursegp->special]->flag = 1; + Assert(Curseg2p->special < MAX_CENTER_TYPES); + CenterFlag[Curseg2p->special]->flag = 1; - mprintf((0, "Cursegp->matcen_num = %i\n", Cursegp->matcen_num)); + mprintf((0, "Curseg2p->matcen_num = %i\n", Curseg2p->matcen_num)); // Read materialization center robot bit flags for ( i=0; i < N_robot_types; i++ ) { RobotMatFlag[i]->status = 1; // Tells ui to redraw button - if (RobotCenters[Cursegp->matcen_num].robot_flags & (1 << i)) + if (RobotCenters[Curseg2p->matcen_num].robot_flags[0] & (1 << i)) RobotMatFlag[i]->flag = 1; // Tells ui that this button is checked else RobotMatFlag[i]->flag = 0; // Tells ui that this button is not checked @@ -172,7 +172,8 @@ void do_centers_window() { if ( i == 0) fuelcen_delete(Cursegp); - else if ( Cursegp->special != i ) { + else if (Curseg2p->special != i) + { fuelcen_delete(Cursegp); redraw_window = 1; fuelcen_activate( Cursegp, i ); @@ -182,13 +183,16 @@ void do_centers_window() for ( i=0; i < N_robot_types; i++ ) { if ( RobotMatFlag[i]->flag == 1 ) { - if (!(RobotCenters[Cursegp->matcen_num].robot_flags & (1<matcen_num].robot_flags |= (1<matcen_num, RobotCenters[Cursegp->matcen_num].robot_flags)); + if (!(RobotCenters[Curseg2p->matcen_num].robot_flags[0] & (1 << i))) + { + RobotCenters[Curseg2p->matcen_num].robot_flags[0] |= (1 << i); + mprintf((0, "Segment %i, matcen = %i, Robot_flags %d\n", Cursegp - Segments, Curseg2p->matcen_num, RobotCenters[Curseg2p->matcen_num].robot_flags[0])); } - } else if (RobotCenters[Cursegp->matcen_num].robot_flags & 1<matcen_num].robot_flags &= ~(1<matcen_num, RobotCenters[Cursegp->matcen_num].robot_flags)); + } + else if (RobotCenters[Curseg2p->matcen_num].robot_flags[0] & 1 << i) + { + RobotCenters[Curseg2p->matcen_num].robot_flags[0] &= ~(1 << i); + mprintf((0, "Segment %i, matcen = %i, Robot_flags %d\n", Cursegp - Segments, Curseg2p->matcen_num, RobotCenters[Curseg2p->matcen_num].robot_flags[0])); } } @@ -206,8 +210,8 @@ void do_centers_window() // temp_text[i] = ' '; // temp_text[i] = 0; -// Assert(Cursegp->special < MAX_CENTER_TYPES); -// strncpy(temp_text, Center_names[Cursegp->special], strlen(Center_names[Cursegp->special])); +// Assert(Curseg2p->special < MAX_CENTER_TYPES); +// strncpy(temp_text, Center_names[Curseg2p->special], strlen(Center_names[Curseg2p->special])); // ui_wprintf_at( MainWindow, 12, 23, " Type: %s", temp_text ); Update_flags |= UF_WORLD_CHANGED; } diff --git a/main/editor/editor.h b/main/editor/editor.h index 397f4346..21884374 100644 --- a/main/editor/editor.h +++ b/main/editor/editor.h @@ -1,4 +1,4 @@ -/* $Id: editor.h,v 1.4 2004-12-19 14:52:48 btb Exp $ */ +/* $Id: editor.h,v 1.5 2004-12-24 05:17:09 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -163,6 +163,8 @@ extern int gamestate_not_restored; extern segment *Cursegp; // Pointer to current segment in the mine, the one to which things happen. +#define Curseg2p s2s2(Cursegp) // Pointer to segment2 for Cursegp + extern vms_vector Ed_view_target; // what editor is looking at // -- extern segment New_segment; // The segment which can be added to the mine. diff --git a/main/editor/eswitch.c b/main/editor/eswitch.c index d06852e3..79e56274 100644 --- a/main/editor/eswitch.c +++ b/main/editor/eswitch.c @@ -1,4 +1,4 @@ -/* $Id: eswitch.c,v 1.3 2004-12-19 15:21:11 btb Exp $ */ +/* $Id: eswitch.c,v 1.4 2004-12-24 05:17:09 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -19,7 +19,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ #ifdef RCS -static char rcsid[] = "$Id: eswitch.c,v 1.3 2004-12-19 15:21:11 btb Exp $"; +static char rcsid[] = "$Id: eswitch.c,v 1.4 2004-12-24 05:17:09 btb Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -190,7 +190,8 @@ int bind_matcen_to_trigger() { return 0; } - if (!(Cursegp->special & SEGMENT_IS_ROBOTMAKER)) { + if (!(Curseg2p->special & SEGMENT_IS_ROBOTMAKER)) + { editor_status("No Matcen at Cursegp."); return 0; } diff --git a/main/editor/group.c b/main/editor/group.c index 9169efb1..daf610ef 100644 --- a/main/editor/group.c +++ b/main/editor/group.c @@ -1,4 +1,4 @@ -/* $Id: group.c,v 1.3 2004-12-19 15:21:11 btb Exp $ */ +/* $Id: group.c,v 1.4 2004-12-24 05:17:09 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -19,7 +19,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ #ifdef RCS -static char rcsid[] = "$Id: group.c,v 1.3 2004-12-19 15:21:11 btb Exp $"; +static char rcsid[] = "$Id: group.c,v 1.4 2004-12-24 05:17:09 btb Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -628,8 +628,8 @@ int med_copy_group(int delta_flag, segment *base_seg, int base_side, segment *gr for (s=0; sspecial = SEGMENT_IS_FUELCEN; - fuelcen_activate( Cursegp, Cursegp->special); + Curseg2p->special = SEGMENT_IS_FUELCEN; + fuelcen_activate(Cursegp, Curseg2p->special); return 1; } int repaircen_create_from_curseg() { Int3(); // -- no longer supported! -// Cursegp->special = SEGMENT_IS_REPAIRCEN; -// fuelcen_activate( Cursegp, Cursegp->special); +// Curseg2p->special = SEGMENT_IS_REPAIRCEN; +// fuelcen_activate(Cursegp, Curseg2p->special); return 1; } int controlcen_create_from_curseg() { - Cursegp->special = SEGMENT_IS_CONTROLCEN; - fuelcen_activate( Cursegp, Cursegp->special); + Curseg2p->special = SEGMENT_IS_CONTROLCEN; + fuelcen_activate(Cursegp, Curseg2p->special); return 1; } int robotmaker_create_from_curseg() { - Cursegp->special = SEGMENT_IS_ROBOTMAKER; - fuelcen_activate( Cursegp, Cursegp->special); + Curseg2p->special = SEGMENT_IS_ROBOTMAKER; + fuelcen_activate(Cursegp, Curseg2p->special); return 1; } diff --git a/main/editor/meddraw.c b/main/editor/meddraw.c index 45faae01..6eb32d17 100644 --- a/main/editor/meddraw.c +++ b/main/editor/meddraw.c @@ -1,4 +1,4 @@ -/* $Id: meddraw.c,v 1.3 2004-12-19 15:21:11 btb Exp $ */ +/* $Id: meddraw.c,v 1.4 2004-12-24 05:17:09 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -19,7 +19,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ #ifdef RCS -static char rcsid[] = "$Id: meddraw.c,v 1.3 2004-12-19 15:21:11 btb Exp $"; +static char rcsid[] = "$Id: meddraw.c,v 1.4 2004-12-24 05:17:09 btb Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -693,7 +693,8 @@ void draw_special_segments(void) // Highlight matcens, fuelcens, etc. for (seg=0;seg<=Highest_segment_index;seg++) if (Segments[seg].segnum != -1) - switch( Segments[seg].special ) { + switch(Segment2s[seg].special) + { case SEGMENT_IS_FUELCEN: color = BM_XRGB( 29, 27, 13 ); gr_setcolor(color); diff --git a/main/editor/medwall.c b/main/editor/medwall.c index 0f5f00bc..3db81306 100644 --- a/main/editor/medwall.c +++ b/main/editor/medwall.c @@ -1,4 +1,4 @@ -/* $Id: medwall.c,v 1.3 2004-12-19 15:21:11 btb Exp $ */ +/* $Id: medwall.c,v 1.4 2004-12-24 05:17:09 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -19,7 +19,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ #ifdef RCS -static char rcsid[] = "$Id: medwall.c,v 1.3 2004-12-19 15:21:11 btb Exp $"; +static char rcsid[] = "$Id: medwall.c,v 1.4 2004-12-24 05:17:09 btb Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -1027,11 +1027,11 @@ int check_walls() for (seg=0;seg<=Highest_segment_index;seg++) if (Segments[seg].segnum != -1) { // Check fuelcenters - matcen_num = Segments[seg].matcen_num; + matcen_num = Segment2s[seg].matcen_num; if (matcen_num == 0) if (RobotCenters[0].segnum != seg) { mprintf((0,"Fixing Matcen 0\n")); - Segments[seg].matcen_num = -1; + Segment2s[seg].matcen_num = -1; } if (matcen_num > -1) @@ -1123,7 +1123,7 @@ int check_walls() mprintf((0,"No valid links on Matcen Trigger %d\n", t)); else for (l=0;lchildren[s] == con_seg-Segments) propagate_tmaps_to_segment_sides(base_seg, s, con_seg, find_connect_side(base_seg, con_seg), uv_only_flag); - con_seg->static_light = base_seg->static_light; + s2s2(con_seg)->static_light = s2s2(base_seg)->static_light; validate_uv_coordinates(con_seg); } @@ -1116,7 +1116,7 @@ void copy_uvs_seg_to_seg(segment *destseg,segment *srcseg) destseg->sides[s].tmap_num2 = srcseg->sides[s].tmap_num2; } - destseg->static_light = srcseg->static_light; + s2s2(destseg)->static_light = s2s2(srcseg)->static_light; } // _________________________________________________________________________________________________________________________ @@ -1328,7 +1328,7 @@ void calim_zero_light_values(void) for (vertnum=0; vertnum<4; vertnum++) sidep->uvls[vertnum].l = F1_0/64; // Put a tiny bit of light here. } - Segments[segnum].static_light = F1_0/64; + Segment2s[segnum].static_light = F1_0 / 64; } } @@ -1395,9 +1395,9 @@ void cast_light_from_side_to_center(segment *segp, int light_side, fix light_int light_at_point = fixmul(light_at_point, light_intensity); if (light_at_point >= F1_0) light_at_point = F1_0-1; - rsegp->static_light += light_at_point; - if (segp->static_light < 0) // if it went negative, saturate - segp->static_light = 0; + s2s2(rsegp)->static_light += light_at_point; + if (s2s2(segp)->static_light < 0) // if it went negative, saturate + s2s2(segp)->static_light = 0; break; case HIT_WALL: break; diff --git a/main/segment.h b/main/segment.h index cc70ce8b..560847f4 100644 --- a/main/segment.h +++ b/main/segment.h @@ -1,4 +1,4 @@ -/* $Id: segment.h,v 1.5 2004-08-28 23:17:45 schaffner Exp $ */ +/* $Id: segment.h,v 1.6 2004-12-24 05:17:09 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -174,6 +174,9 @@ extern segment2 Segment2s[]; extern int Num_segments; extern int Num_vertices; +// Get pointer to the segment2 for the given segment pointer +#define s2s2(segp) (&Segment2s[(segp) - Segments]) + extern sbyte Side_to_verts[MAX_SIDES_PER_SEGMENT][4]; // Side_to_verts[my_side] is list of vertices forming side my_side. extern int Side_to_verts_int[MAX_SIDES_PER_SEGMENT][4]; // Side_to_verts[my_side] is list of vertices forming side my_side. extern char Side_opposite[]; // Side_opposite[my_side] returns side opposite cube from my_side. -- 2.39.2