Patch as advised. -- James Cameron mailto:quozl at us.netrek.org http://quozl.netrek.org/ -------------- next part -------------- Index: ChangeLog =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/ChangeLog,v retrieving revision 1.15 diff -u -r1.15 ChangeLog --- ChangeLog 10 Apr 2006 10:30:44 -0000 1.15 +++ ChangeLog 10 Apr 2006 10:43:09 -0000 @@ -1,3 +1,32 @@ +Mon Apr 10 20:41:52 2006 James Cameron <quozl at us.netrek.org> + + * struct.h: deprecate p_docked and p_ports in favour of + p_dock_with, p_dock_bay, and p_bays, removing overloaded use. + + * proto.h, bay.c: add functions for starbase bay + maintenance and crosscheck. + + * daemon.c: adopt new starbase bay maintenance, calculate etemp + based on number of bays in use rather than using a separate + counter, change some army count checks to prevent abuse. + + * enter.c, interface.c, orbit.c, redraw.c, socket.c: adopt new + starbase bay maintenance. + + * ntscmds.c: release starbase bay on eject ... vicious eject + prevents the explosion from running through the daemon logic, + resulting in inconsistency. Reported by: William Balcerski + + * xtkill.c: release starbase bay on intervention. + +Mon Apr 10 20:40:32 2006 James Cameron <quozl at us.netrek.org> + + * util.c: remove unnecessary includes. + +Mon Apr 10 20:38:15 2006 James Cameron <quozl at us.netrek.org> + + * main.c: fix compilation error on initialisation of p_ip. + Mon Apr 10 20:12:19 2006 James Cameron <quozl at us.netrek.org> * robots/inl.c (checkmess): fix compilation warning by renaming Index: include/defs.h =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/include/defs.h,v retrieving revision 1.3 diff -u -r1.3 defs.h --- include/defs.h 28 Sep 2005 12:14:05 -0000 1.3 +++ include/defs.h 10 Apr 2006 10:43:11 -0000 @@ -134,7 +134,7 @@ #define DOCKDIST 600 #define DOCKSPEED 2 /* If base is moving, there will be some finesse involved to dock */ -#define NUMPORTS 4 +#define NUMBAYS 4 /* number of docking bays a starbase has */ #define SBFUELMIN 10000 /* If starbase's fuel is less than this, it will not refuel docked vessels */ #define TRACTDIST 6000 /* maximum effective tractor beam range */ Index: include/proto.h =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/include/proto.h,v retrieving revision 1.3 diff -u -r1.3 proto.h --- include/proto.h 15 Jun 2005 22:55:25 -0000 1.3 +++ include/proto.h 10 Apr 2006 10:43:11 -0000 @@ -6,6 +6,15 @@ #ifndef __INCLUDED_proto_h__ #define __INCLUDED_proto_h__ +/* bay.c */ +void bay_consistency_check(struct player *base); +struct player *bay_owner(struct player *me); +void bay_claim(struct player *base, struct player *me, int bay_no); +void bay_release(struct player *me); +void bay_release_all(struct player *base); +void bay_init(struct player *me); +int bay_closest(struct player *base, LONG dx, LONG dy); + /* cluecheck.c */ void clue_check(void); Index: include/struct.h =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/include/struct.h,v retrieving revision 1.3 diff -u -r1.3 struct.h --- include/struct.h 10 Apr 2006 04:24:51 -0000 1.3 +++ include/struct.h 10 Apr 2006 10:43:13 -0000 @@ -370,9 +370,14 @@ short p_planets; /* planets taken this game */ short p_armsbomb; /* armies bombed this game */ int p_ghostbuster; - int p_docked; /* If starbase, # docked to, else pno base host */ - int p_port[4]; /* If starbase, pno of ship docked to that port, - else p_port[0] = port # docked to on host. */ + + /* for starbases, if PFDOCKOK set */ + int p_bays[NUMBAYS]; /* p_no of each docked ship, or VACANT */ + + /* for ships other than starbases, if p_flags PFDOCK set */ + int p_dock_with; /* p_no of starbase we are docked with */ + int p_dock_bay; /* bay of starbase we are docked with */ + short p_tractor; /* What player is in tractor lock */ int p_pos; /* My position in the player file */ int w_queue; /* Waitqueue of my team */ Index: ntserv/Makefile.in =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/ntserv/Makefile.in,v retrieving revision 1.3 diff -u -r1.3 Makefile.in --- ntserv/Makefile.in 28 Sep 2005 12:14:05 -0000 1.3 +++ ntserv/Makefile.in 10 Apr 2006 10:43:15 -0000 @@ -22,14 +22,14 @@ startrobot.o sysdefaults.o timecheck.o torp.o util.o \ warning.o ping.o $(RANDOMO) getpath.o $(STRDUPO) features.o \ distress.o transwarp.o gencmds.o ntscmds.o openmem.o feature.o \ - queue.o slotmaint.o rsa_key.o ltd_stats.o + queue.o slotmaint.o rsa_key.o ltd_stats.o bay.o # daemonII object files D_OBJS = daemonII.o sintab.o sysdefaults.o data.o slotmaint.o \ util.o $(RANDOMO) getpath.o getship.o smessage.o queue.o \ - wander2.o openmem.o solicit.o ltd_stats.o + wander2.o openmem.o solicit.o ltd_stats.o bay.o # Src files @@ -48,7 +48,8 @@ ${srcdir}/features.c ${srcdir}/distress.c ${srcdir}/transwarp.c \ ${srcdir}/gencmds.c ${srcdir}/ntscmds.c ${srcdir}/openmem.c \ ${srcdir}/feature.c ${srcdir}/queue.c ${srcdir}/slotmaint.c \ - ${srcdir}/wander2.c ${srcdir}/sysdefaults.c ${srcdir}/rsa_key.c + ${srcdir}/wander2.c ${srcdir}/sysdefaults.c ${srcdir}/rsa_key.c \ + ${srcdir}/bay.c SRC = $(R_FILES) data.h defs.h planets.h struct.h \ packets.h copyright.h Index: ntserv/daemonII.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/ntserv/daemonII.c,v retrieving revision 1.3 diff -u -r1.3 daemonII.c --- ntserv/daemonII.c 27 Sep 2005 12:26:37 -0000 1.3 +++ ntserv/daemonII.c 10 Apr 2006 10:43:27 -0000 @@ -927,13 +927,9 @@ j->p_explode = 600/PLAYERFUSE; /* set ghost buster */ } - /* At this point, docked ships become removed. */ - if (j->p_flags & PFDOCK) { - players[j->p_docked].p_docked--; - players[j->p_docked].p_port[j->p_port[0]] = VACANT; - j->p_flags &= ~PFDOCK; - } + bay_release(j); if (j->p_ship.s_type == STARBASE) { + bay_release_all(j); if (((j->p_whydead == KSHIP) || (j->p_whydead == KTORP) || (j->p_whydead == KPHASER) || @@ -942,16 +938,9 @@ (j->p_whydead == KGENOCIDE)) && (status->tourn)) teams[j->p_team].s_turns=BUILD_SB_TIME; /* in defs.h */ /* 30 minute reconstruction period for new starbase */ - for (k=0; k<NUMPORTS; k++) - if(j->p_port[k] != VACANT) { - players[j->p_port[k]].p_flags &= ~PFDOCK; - j->p_port[k] = VACANT; - } - j->p_docked = 0; } /* And he is ejected from orbit. */ - if (j->p_flags & PFORBIT) - j->p_flags &= ~PFORBIT; + j->p_flags &= ~PFORBIT; /* Fall through to alive so explosions move */ @@ -1016,10 +1005,13 @@ /* Charge SB's for mass of docked vessels ... */ if (j->p_ship.s_type == STARBASE) { - for (k=0; k<NUMPORTS; k++) - if(j->p_port[k] != VACANT) - j->p_fuel -= players[j->p_port[k]].p_ship.s_warpcost * j->p_speed; - j->p_etemp += .7*(j->p_speed * j->p_docked); + int bays = 0; + for (k=0; k<NUMBAYS; k++) + if(j->p_bays[k] != VACANT) { + j->p_fuel -= players[j->p_bays[k]].p_ship.s_warpcost * j->p_speed; + bays++; + } + j->p_etemp += .7*(j->p_speed * bays); } } #ifdef SB_TRANSWARP @@ -1328,11 +1320,11 @@ j->p_fuel += 6 * j->p_ship.s_recharge; } else if ((j->p_flags & PFDOCK) && (j->p_fuel < j->p_ship.s_maxfuel) && - (players[j->p_docked].p_fuel > SBFUELMIN)) { + (players[j->p_dock_with].p_fuel > SBFUELMIN)) { int fc = MIN(10*j->p_ship.s_recharge, j->p_ship.s_maxfuel - j->p_fuel); j->p_fuel += fc; - players[j->p_docked].p_fuel -= fc; + players[j->p_dock_with].p_fuel -= fc; } #else /* Add fuel */ @@ -1341,9 +1333,9 @@ (!(planets[j->p_planet].pl_owner & j->p_war))) { j->p_fuel += 8 * j->p_ship.s_recharge; } else if ((j->p_flags & PFDOCK) && (j->p_fuel < j->p_ship.s_maxfuel)) { - if (players[j->p_docked].p_fuel > SBFUELMIN) { + if (players[j->p_dock_with].p_fuel > SBFUELMIN) { j->p_fuel += 12*j->p_ship.s_recharge; - players[j->p_docked].p_fuel -= 12*j->p_ship.s_recharge; + players[j->p_dock_with].p_fuel -= 12*j->p_ship.s_recharge; } } else j->p_fuel += 2 * j->p_ship.s_recharge; @@ -1418,8 +1410,8 @@ /* Move Player in dock */ if (j->p_flags & PFDOCK) { - j->p_x = players[j->p_docked].p_x + DOCKDIST*Cos[(j->p_port[0]*90+45)*255/360]; - j->p_y = players[j->p_docked].p_y + DOCKDIST*Sin[(j->p_port[0]*90+45)*255/360]; + j->p_x = players[j->p_dock_with].p_x + DOCKDIST*Cos[(j->p_dock_bay*90+45)*255/360]; + j->p_y = players[j->p_dock_with].p_y + DOCKDIST*Sin[(j->p_dock_bay*90+45)*255/360]; } /* Set player's alert status */ @@ -2939,9 +2931,9 @@ if (l->pl_armies < 5) continue; if (j->p_flags & PFDOCK) - if (players[j->p_docked].p_armies == 0) + if (players[j->p_dock_with].p_armies < 1) continue; - if (j->p_armies == j->p_ship.s_maxarmies) + if (j->p_armies >= j->p_ship.s_maxarmies) continue; /* XXX */ if (j->p_ship.s_type == ASSAULT) { @@ -2969,13 +2961,13 @@ } #endif } else if (j->p_flags & PFDOCK) { - players[j->p_docked].p_armies--; - army_track(AMT_TRANSUP, j, &players[j->p_docked], 1); + struct player *base = bay_owner(j); + base->p_armies--; + army_track(AMT_TRANSUP, j, base, 1); #ifdef LTD_STATS - /* j = player, j->pdocked = friendly SB */ if (status->tourn) { - ltd_update_armies_carried(j, &players[j->p_docked]); + ltd_update_armies_carried(j, base); } #endif @@ -3242,18 +3234,18 @@ } } else if (j->p_flags & PFDOCK) { - if (players[j->p_docked].p_team != j->p_team) + struct player *base = bay_owner(j); + if (base->p_team != j->p_team) continue; - if (players[j->p_docked].p_armies - == players[j->p_docked].p_ship.s_maxarmies) { + if (base->p_armies >= base->p_ship.s_maxarmies) { continue; } else { - army_track(AMT_TRANSDOWN, j, &players[j->p_docked], 1); + army_track(AMT_TRANSDOWN, j, base, 1); j->p_armies--; - players[j->p_docked].p_armies ++; + base->p_armies ++; #ifdef LTD_STATS if (status->tourn) { - ltd_update_armies_ferried(j, &players[j->p_docked]); + ltd_update_armies_ferried(j, base); } #endif /* LTD_STATS */ Index: ntserv/enter.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/ntserv/enter.c,v retrieving revision 1.2 diff -u -r1.2 enter.c --- ntserv/enter.c 21 Mar 2005 10:17:17 -0000 1.2 +++ ntserv/enter.c 10 Apr 2006 10:43:29 -0000 @@ -176,12 +176,10 @@ me->p_lastseenby = VACANT; me->p_kills = 0.0; me->p_armies = 0; - me->p_docked = 0; - me->p_port[0] = VACANT; - me->p_port[1] = VACANT; - me->p_port[2] = VACANT; - me->p_port[3] = VACANT; -/* if (!keeppeace) me->p_hostile = (FED|ROM|KLI|ORI);*/ + bay_init(me); + me->p_dock_with = 0; + me->p_dock_bay = 0; +/* if (!keeppeace) me->p_hostile = (FED|ROM|KLI|ORI); */ if( !(me->p_flags & PFROBOT) && (me->p_team == NOBODY) ) { me->p_hostile = NOBODY; me->p_war = NOBODY; Index: ntserv/interface.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/ntserv/interface.c,v retrieving revision 1.3 diff -u -r1.3 interface.c --- ntserv/interface.c 22 Feb 2006 09:18:30 -0000 1.3 +++ ntserv/interface.c 10 Apr 2006 10:43:30 -0000 @@ -29,21 +29,15 @@ speed=0; } me->p_desspeed = speed; - if (me->p_flags & PFDOCK) { - players[me->p_docked].p_docked--; - players[me->p_docked].p_port[me->p_port[0]] = VACANT; - } - me->p_flags &= ~(PFREPAIR | PFBOMB | PFORBIT | PFDOCK | PFBEAMUP | PFBEAMDOWN); + bay_release(me); + me->p_flags &= ~(PFREPAIR | PFBOMB | PFORBIT | PFBEAMUP | PFBEAMDOWN); } void set_course(u_char dir) { me->p_desdir = dir; - if (me->p_flags & PFDOCK) { - players[me->p_docked].p_docked--; - players[me->p_docked].p_port[me->p_port[0]] = VACANT; - } - me->p_flags &= ~(PFBOMB | PFORBIT | PFDOCK | PFBEAMUP | PFBEAMDOWN); + bay_release(me); + me->p_flags &= ~(PFBOMB | PFORBIT | PFBEAMUP | PFBEAMDOWN); } void shield_up(void) @@ -156,7 +150,7 @@ return; } } else if (me->p_flags & PFDOCK) { - if (me->p_team != players[me->p_docked].p_team) { + if (me->p_team != players[me->p_dock_with].p_team) { new_warning(46,"Comm Officer: We're not authorized to beam foriegn troops on board!"); return; } @@ -185,7 +179,7 @@ #endif if (me->p_flags & PFDOCK) { - if (me->p_team != players[me->p_docked].p_team) { + if (me->p_team != players[me->p_dock_with].p_team) { new_warning(48,"Comm Officer: Starbase refuses permission to beam our troops over."); return; } @@ -312,16 +306,10 @@ if (hypot((double) me->p_x-victim->p_x, (double) me->p_y-victim->p_y) < ((double) TRACTDIST) * me->p_ship.s_tractrng) { - if (victim->p_flags & PFDOCK) { - players[victim->p_docked].p_port[victim->p_port[0]] = VACANT; - players[victim->p_docked].p_docked--; - } - if (me->p_flags & PFDOCK) { - players[me->p_docked].p_docked--; - players[me->p_docked].p_port[me->p_port[0]] = VACANT; - } - victim->p_flags &= ~(PFORBIT | PFDOCK); - me->p_flags &= ~(PFORBIT | PFDOCK); + bay_release(victim); + bay_release(me); + victim->p_flags &= ~PFORBIT; + me->p_flags &= ~PFORBIT; me->p_tractor = player; me->p_flags |= PFTRACT; } else { /* out of range */ @@ -357,14 +345,8 @@ if (hypot((double) me->p_x-victim->p_x, (double) me->p_y-victim->p_y) < ((double) TRACTDIST) * me->p_ship.s_tractrng) { - if (victim->p_flags & PFDOCK) { - players[victim->p_docked].p_port[victim->p_port[0]] = VACANT; - players[victim->p_docked].p_docked--; - } - if (me->p_flags & PFDOCK) { - players[me->p_docked].p_docked--; - players[me->p_docked].p_port[me->p_port[0]] = VACANT; - } + bay_release(victim); + bay_release(me); victim->p_flags &= ~(PFORBIT | PFDOCK); me->p_flags &= ~(PFORBIT | PFDOCK); me->p_tractor = target; @@ -408,21 +390,18 @@ sendwarn("Orions", mask & ORI, ORI); } if (me->p_flags & PFDOCK) { - if (players[me->p_docked].p_team & mask) { - players[me->p_docked].p_port[me->p_port[0]] = VACANT; - players[me->p_docked].p_docked--; - me->p_flags &= ~PFDOCK; + if (players[me->p_dock_with].p_team & mask) { + /* release ship from starbase that is now hostile */ + bay_release(me); } - } else if (me->p_ship.s_type == STARBASE) { - if (me->p_docked > 0) { - for(i=0; i<NUMPORTS; i++) { - if (me->p_port[i] == VACANT) /* isae -- Ted's fix */ - continue; - if (mask & players[me->p_port[i]].p_team) { - players[me->p_port[i]].p_flags &= ~PFDOCK; - me->p_docked--; - me->p_port[i] = VACANT; - } + } + if (me->p_ship.s_type == STARBASE) { + for(i=0; i<NUMBAYS; i++) { + if (me->p_bays[i] == VACANT) + continue; + if (mask & players[me->p_bays[i]].p_team) { + /* release docked ships that are now hostile */ + bay_release(&players[me->p_bays[i]]); } } } @@ -486,7 +465,7 @@ new_warning(52,"Can only refit to starbase on your home planet."); return; } - if (players[me->p_docked].p_team != me->p_team) { + if (players[me->p_dock_with].p_team != me->p_team) { new_warning(53,"You must dock YOUR starbase to apply for command reassignment!"); return; } @@ -573,12 +552,7 @@ /* Reset kills to 0.0 */ me->p_kills=0; /* bump all docked ships */ - for (i=0; i<NUMPORTS; i++) - if (me->p_port[i] != VACANT) { - players[me->p_port[i]].p_flags &= ~PFDOCK; - me->p_docked--; - me->p_port[i] = VACANT; - } + bay_release_all(me); me->p_flags |= PFDOCKOK; } @@ -622,8 +596,7 @@ me->p_etime = 0; me->p_ship.s_type = type; if (type == STARBASE) { - me->p_docked = 0; - for (i=0; i<4; i++) me->p_port[i] = VACANT; + bay_init(me); me->p_flags |= PFDOCKOK; } Index: ntserv/ntscmds.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/ntserv/ntscmds.c,v retrieving revision 1.4 diff -u -r1.4 ntscmds.c --- ntserv/ntscmds.c 10 Apr 2006 04:24:51 -0000 1.4 +++ ntserv/ntscmds.c 10 Apr 2006 10:43:33 -0000 @@ -297,8 +297,10 @@ j->p_ship.s_type = STARBASE; j->p_whydead=KQUIT; j->p_explode=10; + /* note VICIOUS_EJECT prevents animation of ship explosion */ j->p_status=PEXPLODE; j->p_whodead=me->p_no; + bay_release(j); } #endif /* ALLOW_EJECT */ Index: ntserv/orbit.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/ntserv/orbit.c,v retrieving revision 1.2 diff -u -r1.2 orbit.c --- ntserv/orbit.c 21 Mar 2005 10:17:17 -0000 1.2 +++ ntserv/orbit.c 10 Apr 2006 10:43:34 -0000 @@ -29,27 +29,10 @@ #define TRUE 1 #endif -/* - * If there are bugs in this docking code and/or possibly other places - * in the code, then conceivably a base my have p_docked < 4 while - * all ports are non-VACANT. That is inconsistent, and this code - * will check for that eventuality on the fly. - */ -#if 1 -#define RETURN_IF_VACANT(base, port) -#else -#define RETURN_IF_VACANT(base, port) \ - if (base->p_port[port] != VACANT) { \ - ERROR(1, ("Starbase %d has no ports vacant but p_docked==%d\n", \ - base->p_id, base->p_docked)); \ - return FALSE; \ - } -#endif - void de_lock(struct player *me) { me->p_flags &= ~(PFPLOCK | PFPLLOCK | PFTRACT | PFPRESS); - #ifdef SB_TRANSWARP +#ifdef SB_TRANSWARP if (me->p_flags & PFTWARP){ me->p_flags &= ~PFTWARP; me->p_flags |= PFREFITTING; @@ -64,14 +47,14 @@ * (If one or more of these is not true, various nasty things happen.) */ -#define DOCK_NO_BASE 0 -#define DOCK_FAILURE 1 -#define DOCK_SUCCESS 2 +#define DOCK_NO_BASE 0 /* no base is close enough */ +#define DOCK_FAILURE 1 /* dock failed due to some condition */ +#define DOCK_SUCCESS 2 /* dock was successful */ static int dock(struct player *base) { LONG dx, dy; - int port_id; + int bay_no; u_char dir_from_base; /* @@ -124,90 +107,28 @@ } /* - * Make sure the base's docking ports are not already full: */ - if (base->p_docked >= NUMPORTS) { + * Make sure the base's docking bays are not already full: */ + bay_no = bay_closest(base, dx, dy); + if (bay_no == -1) { if (send_short) swarning(SBDOCKDENIED_TEXT, base->p_no, 0); else - new_warning(UNDEF, "Starbase %s: Permission to dock denied, all ports currently occupied.", base->p_name); + new_warning(UNDEF, "Starbase %s: Permission to dock denied, all bays currently occupied.", base->p_name); de_lock(me); return DOCK_FAILURE; } /* - * Dock on closest port. - * A starbase's ports are 3 0 - * numbered as in this () - * picture: 2 1 */ - if (dx > 0) { - /* We are to the left of the base: */ - if (dy > 0) { - /* Above and to left of base: */ - if (base->p_port[3] == VACANT) - port_id = 3; - else if (base->p_port[2] == VACANT) - port_id = 2; - else if (base->p_port[0] == VACANT) - port_id = 0; - else { - RETURN_IF_VACANT(base, 1); - port_id = 1; - } - } else { - /* Below and to left of base: */ - if (base->p_port[2] == VACANT) - port_id = 2; - else if (base->p_port[3] == VACANT) - port_id = 3; - else if (base->p_port[1] == VACANT) - port_id = 1; - else { - RETURN_IF_VACANT(base, 0); - port_id = 0; - } - } - } else { - /* We are to the right of the base: */ - if (dy > 0) { - /* Above and to right of base: */ - if (base->p_port[0] == VACANT) - port_id = 0; - else if (base->p_port[1] == VACANT) - port_id = 1; - else if (base->p_port[3] == VACANT) - port_id = 3; - else { - RETURN_IF_VACANT(base, 2); - port_id = 2; - } - } else { - /* Below and to right of base: */ - if (base->p_port[1] == VACANT) - port_id = 1; - else if (base->p_port[2] == VACANT) - port_id = 2; - else if (base->p_port[0] == VACANT) - port_id = 0; - else { - RETURN_IF_VACANT(base, 3); - port_id = 3; - } - } - } - - /* * Adjust player structures of myself and the base. */ - dir_from_base = ((port_id * 90 + 45) * 256) / 360; - me->p_flags &= ~(PFPLOCK | PFPLLOCK | PFTRACT | PFPRESS); - me->p_flags |= PFDOCK; - me->p_dir = 64 + dir_from_base; - me->p_desdir = me->p_dir; - me->p_x = base->p_x + DOCKDIST * Cos[dir_from_base]; - me->p_y = base->p_y + DOCKDIST * Sin[dir_from_base]; - me->p_speed = 0; - me->p_desspeed = 0; - me->p_docked = base->p_no; - me->p_port[0] = port_id; + dir_from_base = ((bay_no * 90 + 45) * 256) / 360; + me->p_flags &= ~(PFPLOCK | PFPLLOCK | PFTRACT | PFPRESS); + me->p_flags |= PFDOCK; + me->p_dir = 64 + dir_from_base; + me->p_desdir = me->p_dir; + me->p_x = base->p_x + DOCKDIST * Cos[dir_from_base]; + me->p_y = base->p_y + DOCKDIST * Sin[dir_from_base]; + me->p_speed = 0; + me->p_desspeed = 0; #ifdef SB_TRANSWARP if (me->p_flags & PFTWARP){ me->p_flags &= ~PFTWARP; @@ -216,15 +137,14 @@ } #endif - base->p_docked++; - base->p_port[port_id] = me->p_no; + bay_claim(base, me, bay_no); /* * Notify player of success. */ if (send_short) - swarning(ONEARG_TEXT, 2, port_id); + swarning(ONEARG_TEXT, 2, bay_no); else - new_warning(UNDEF,"Helmsman: Docking manuever completed Captain. All moorings secured at port %d.", port_id); + new_warning(UNDEF,"Helmsman: Docking manuever completed Captain. All moorings secured at bay %d.", bay_no); return DOCK_SUCCESS; } Index: ntserv/redraw.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/ntserv/redraw.c,v retrieving revision 1.1 diff -u -r1.1 redraw.c --- ntserv/redraw.c 21 Mar 2005 05:23:44 -0000 1.1 +++ ntserv/redraw.c 10 Apr 2006 10:43:36 -0000 @@ -213,14 +213,12 @@ #define NOOBSMASK (PFSELFDEST|PFPLOCK|PFPLLOCK|PFOBSERV) me->p_flags = (pl->p_flags & ~NOOBSMASK) | (me->p_flags & NOOBSMASK); - /* always cloaked, state of person watched will be obvious */ - /* me->p_flags |= PFCLOAK; */ me->p_dir = pl->p_dir; me->p_tractor = pl->p_tractor; - me->p_docked = pl->p_docked; + me->p_dock_with = pl->p_dock_with; + me->p_dock_bay = pl->p_dock_bay; me->p_planet = pl->p_planet; me->p_speed = pl->p_speed; - /* me->p_kills = pl->p_kills; Very bad: will confuse enemies */ } return; } /* end if I am locked onto a player */ @@ -439,10 +437,11 @@ planets[me->p_planet].pl_armies); } else if (me->p_flags & PFDOCK) { - if (players[me->p_docked].p_armies == 0) { + struct player *base = bay_owner(me); + if (base->p_armies <= 0) { txt = "Too few armies to beam up"; me->p_flags &= ~PFBEAMUP; - } else if (me->p_armies == troop_capacity) { + } else if (me->p_armies >= troop_capacity) { txt = "No more room on board for armies"; me->p_flags &= ~PFBEAMUP; } else { @@ -452,8 +451,8 @@ txt, me->p_armies, troop_capacity, - players[me->p_docked].p_name, - players[me->p_docked].p_armies); + base->p_name, + base->p_armies); } } @@ -475,13 +474,13 @@ planets[me->p_planet].pl_armies); } else if (me->p_flags & PFDOCK) { - if (me->p_armies == 0) { + struct player *base = bay_owner(me); + if (me->p_armies <= 0) { txt = "No more armies to beam down"; me->p_flags &= ~PFBEAMDOWN; - } else if (players[me->p_docked].p_armies == - players[me->p_docked].p_ship.s_maxarmies) { - txt = "All troop bunkers are full"; - me->p_flags &= ~PFBEAMDOWN; + } else if (base->p_armies >= base->p_ship.s_maxarmies) { + txt = "All troop bunkers are full"; + me->p_flags &= ~PFBEAMDOWN; } else { txt = "Transfering ground units"; } @@ -489,8 +488,8 @@ txt, me->p_armies, troop_capacity, - players[me->p_docked].p_name, - players[me->p_docked].p_armies); + base->p_name, + base->p_armies); } } Index: ntserv/socket.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/ntserv/socket.c,v retrieving revision 1.4 diff -u -r1.4 socket.c --- ntserv/socket.c 10 Apr 2006 04:24:51 -0000 1.4 +++ ntserv/socket.c 10 Apr 2006 10:43:45 -0000 @@ -1213,12 +1213,8 @@ if (packet->state) { orbit(); } else { + bay_release(me); me->p_flags &= ~PFORBIT; - if (me->p_flags & PFDOCK) { - players[me->p_docked].p_docked--; - players[me->p_docked].p_port[me->p_port[0]] = VACANT; - me->p_flags &= ~PFDOCK; - } } } @@ -1402,21 +1398,15 @@ return; } if (target<0 || target>=MAXPLAYER || target==me->p_no) return; - player= &players[target]; + player = &players[target]; if (player->p_flags & PFCLOAK) return; if (hypot((double) me->p_x-player->p_x, (double) me->p_y-player->p_y) < ((double) TRACTDIST) * me->p_ship.s_tractrng) { - if (player->p_flags & PFDOCK) { - players[player->p_docked].p_port[player->p_port[0]] = VACANT; - players[player->p_docked].p_docked--; - } - if (me->p_flags & PFDOCK) { - players[me->p_docked].p_docked--; - players[me->p_docked].p_port[me->p_port[0]] = VACANT; - } - player->p_flags &= ~(PFORBIT | PFDOCK); - me->p_flags &= ~(PFORBIT | PFDOCK); + bay_release(player); + bay_release(me); + player->p_flags &= ~PFORBIT; + me->p_flags &= ~PFORBIT; me->p_tractor = target; me->p_flags |= PFTRACT; } else { @@ -1448,16 +1438,10 @@ if (hypot((double) me->p_x-player->p_x, (double) me->p_y-player->p_y) < ((double) TRACTDIST) * me->p_ship.s_tractrng) { - if (player->p_flags & PFDOCK) { - players[player->p_docked].p_port[player->p_port[0]] = VACANT; - players[player->p_docked].p_docked--; - } - if (me->p_flags & PFDOCK) { - players[me->p_docked].p_docked--; - players[me->p_docked].p_port[me->p_port[0]] = VACANT; - } - player->p_flags &= ~(PFORBIT | PFDOCK); - me->p_flags &= ~(PFORBIT | PFDOCK); + bay_release(player); + bay_release(me); + player->p_flags &= ~PFORBIT; + me->p_flags &= ~PFORBIT; me->p_tractor = target; me->p_flags |= (PFTRACT | PFPRESS); } else { @@ -1736,16 +1720,12 @@ int i; if (me->p_ship.s_type == STARBASE) { - me->p_docked = 0; - for (i=0; i<NUMPORTS; i++) { - if (me->p_port[i] != VACANT) - players[me->p_port[i]].p_flags &= ~PFDOCK; - me->p_port[i] = VACANT; - } - if (packet->state) - me->p_flags |= PFDOCKOK; - else - me->p_flags &= ~PFDOCKOK; + if (packet->state) { + me->p_flags |= PFDOCKOK; + } else { + me->p_flags &= ~PFDOCKOK; + bay_release_all(me); + } } } Index: robotd/defs.h =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/robotd/defs.h,v retrieving revision 1.2 diff -u -r1.2 defs.h --- robotd/defs.h 28 Sep 2005 12:14:05 -0000 1.2 +++ robotd/defs.h 10 Apr 2006 10:43:45 -0000 @@ -40,7 +40,6 @@ #define DOCKDIST 600 #define DOCKSPEED 2 /* If base is moving, there will be some finesse involved to dock */ -#define NUMPORTS 4 #define SBFUELMIN 10000 /* If starbase's fuel is less than this, it will not refuel docked vessels */ #define TRACTDIST 6000 /* maximum effective tractor beam range */ Index: robotd/struct.h =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/robotd/struct.h,v retrieving revision 1.1 diff -u -r1.1 struct.h --- robotd/struct.h 21 Mar 2005 05:23:45 -0000 1.1 +++ robotd/struct.h 10 Apr 2006 10:43:46 -0000 @@ -199,9 +199,6 @@ short p_planets; /* planets taken this game */ short p_armsbomb; /* armies bombed this game */ int p_ghostbuster; - int p_docked; /* If starbase, # docked to, else pno base host */ - int p_port[4]; /* If starbase, pno of ship docked to that port, - else p_port[0] = port # docked to on host. */ short p_tractor; /* What player is in tractor lock */ int p_pos; /* My position in the player file */ }; Index: robots/Makefile.in =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/robots/Makefile.in,v retrieving revision 1.2 diff -u -r1.2 Makefile.in --- robots/Makefile.in 21 Mar 2005 10:17:18 -0000 1.2 +++ robots/Makefile.in 10 Apr 2006 10:43:46 -0000 @@ -30,7 +30,8 @@ ../ntserv/orbit.o ../ntserv/phaser.o ../ntserv/sintab.o \ ../ntserv/openmem.o sysdefaults.o ../ntserv/torp.o \ ../ntserv/util.o $(RANDOMO) ../ntserv/getpath.o ../ntserv/smessage.o \ - roboshar.o ../ntserv/slotmaint.o ../ntserv/distress.o ../ntserv/ltd_stats.o + roboshar.o ../ntserv/slotmaint.o ../ntserv/distress.o \ + ../ntserv/ltd_stats.o ../ntserv/bay.o # Puck Objects Index: tools/Makefile.in =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/tools/Makefile.in,v retrieving revision 1.4 diff -u -r1.4 Makefile.in --- tools/Makefile.in 22 Feb 2006 09:18:30 -0000 1.4 +++ tools/Makefile.in 10 Apr 2006 10:43:47 -0000 @@ -21,14 +21,10 @@ TOOLDIR= $(LIBDIR)/tools -GETPATH = ../ntserv/getpath.o ../ntserv/data.o - LINTFLAGS = -habxc $(EXTRAINCS) $(FLAGS) -# Memory Objects - -M_OBJS = ../ntserv/data.o ../ntserv/openmem.o ../ntserv/ltd_stats.o - +OBJS_SHM = ../ntserv/data.o ../ntserv/openmem.o ../ntserv/ltd_stats.o +OBJS_PATH = ../ntserv/getpath.o ../ntserv/data.o SRCS = ${srcdir}/blotpassword.c ${srcdir}/loadchecker.c ${srcdir}/mess.c \ ${srcdir}/mergescores.c \ @@ -43,7 +39,7 @@ ${srcdir}/conq_vert.c ${srcdir}/../ntserv/slotmaint.c $(RANDOMC) \ ${srcdir}/sortdb.c ${srcdir}/../robots/roboshar.c \ ${srcdir}/../ntserv/smessage.c ${srcdir}/ntpasswd.c \ - ${srcdir}/../ntserv/salt.c + ${srcdir}/../ntserv/salt.c ${srcdir}/../ntserv/bay.c EXECS = blotpassword loadchecker mess message newscores planets players \ scores \ @@ -93,85 +89,80 @@ # cb_sock.o: packets.h ../ntserv/socket.c # $(CC) -o ./cb_sock.o -g $(CFLAGS) -DCAMBOT -c ../ntserv/socket.c -cambot: cambot.o $(M_OBJS) $(GETPATH) - $(CC) -o $@ $(CFLAGS) ${LDFLAGS} cambot.o ../ntserv/genspkt.o ../ntserv/sysdefaults.o ../ntserv/getship.o ../ntserv/warning.o ../ntserv/smessage.o ../ntserv/distress.o ../ntserv/util.o $(M_OBJS) ../ntserv/getpath.o $(RSA_LIB) +cambot: cambot.o $(OBJS_SHM) $(OBJS_PATH) + $(CC) -o $@ $(CFLAGS) ${LDFLAGS} cambot.o ../ntserv/genspkt.o ../ntserv/sysdefaults.o ../ntserv/getship.o ../ntserv/warning.o ../ntserv/smessage.o ../ntserv/distress.o ../ntserv/util.o $(OBJS_SHM) ../ntserv/getpath.o $(RSA_LIB) sortdb: sortdb.o $(CC) -o $@ $(CFLAGS) ${LDFLAGS} sortdb.o -ntpasswd: ntpasswd.o $(GETPATH) ../ntserv/salt.o - $(CC) -o $@ $(CFLAGS) ${LDFLAGS} ntpasswd.o $(GETPATH) ../ntserv/salt.o $(LIBCRYPT) +ntpasswd: ntpasswd.o $(OBJS_PATH) ../ntserv/salt.o + $(CC) -o $@ $(CFLAGS) ${LDFLAGS} ntpasswd.o $(OBJS_PATH) ../ntserv/salt.o $(LIBCRYPT) -loadchecker: loadchecker.o $(M_OBJS) - $(CC) -o $@ $(CFLAGS) ${LDFLAGS} loadchecker.o $(M_OBJS) $(LIBS) +loadchecker: loadchecker.o $(OBJS_SHM) + $(CC) -o $@ $(CFLAGS) ${LDFLAGS} loadchecker.o $(OBJS_SHM) $(LIBS) -mess: mess.o $(M_OBJS) - $(CC) -o $@ $(CFLAGS) ${LDFLAGS} mess.o $(M_OBJS) $(LIBS) +mess: mess.o $(OBJS_SHM) + $(CC) -o $@ $(CFLAGS) ${LDFLAGS} mess.o $(OBJS_SHM) $(LIBS) -message: message.o $(M_OBJS) - $(CC) -o $@ $(CFLAGS) ${LDFLAGS} message.o $(M_OBJS) $(LIBS) +message: message.o $(OBJS_SHM) + $(CC) -o $@ $(CFLAGS) ${LDFLAGS} message.o $(OBJS_SHM) $(LIBS) -mergescores: mergescores.o $(GETPATH) - $(CC) -o $@ $(CFLAGS) ${LDFLAGS} mergescores.o $(GETPATH) $(LIBS) +mergescores: mergescores.o $(OBJS_PATH) + $(CC) -o $@ $(CFLAGS) ${LDFLAGS} mergescores.o $(OBJS_PATH) $(LIBS) -newscores: newscores.o $(GETPATH) - $(CC) -o $@ $(CFLAGS) ${LDFLAGS} newscores.o $(GETPATH) $(LIBS) +newscores: newscores.o $(OBJS_PATH) + $(CC) -o $@ $(CFLAGS) ${LDFLAGS} newscores.o $(OBJS_PATH) $(LIBS) -planets: planets.o $(M_OBJS) - $(CC) -o $@ $(CFLAGS) ${LDFLAGS} planets.o $(M_OBJS) $(LIBS) +planets: planets.o $(OBJS_SHM) + $(CC) -o $@ $(CFLAGS) ${LDFLAGS} planets.o $(OBJS_SHM) $(LIBS) -players: players.o $(M_OBJS) $(RANDOMO) - $(CC) -o $@ $(CFLAGS) ${LDFLAGS} players.o $(M_OBJS) $(RANDOMO) $(LIBS) +players: players.o $(OBJS_SHM) $(RANDOMO) + $(CC) -o $@ $(CFLAGS) ${LDFLAGS} players.o $(OBJS_SHM) $(RANDOMO) $(LIBS) -nuke: nuke.o $(M_OBJS) $(RANDOMO) - $(CC) -o $@ $(CFLAGS) ${LDFLAGS} nuke.o $(M_OBJS) $(RANDOMO) $(LIBS) +nuke: nuke.o $(OBJS_SHM) $(RANDOMO) + $(CC) -o $@ $(CFLAGS) ${LDFLAGS} nuke.o $(OBJS_SHM) $(RANDOMO) $(LIBS) -# some weird problem with the MIPS RISC compiler for DECstations... -# gcc seems to compile working executables (TC) -# -scores: scores.o $(GETPATH) - $(CC) -o $@ $(CFLAGS) ${LDFLAGS} scores.o $(GETPATH) $(LIBS) ../ntserv/ltd_stats.o -# gcc -o $@ $(CFLAGS) -g scores.o -L/usr/users/terence/lib -# cp scores /usr/users/terence/bin/trekscores +scores: scores.o $(OBJS_PATH) + $(CC) -o $@ $(CFLAGS) ${LDFLAGS} scores.o $(OBJS_PATH) $(LIBS) ../ntserv/ltd_stats.o -setgalaxy: setgalaxy.o $(RANDOMO) $(M_OBJS) - $(CC) -o $@ $(CFLAGS) ${LDFLAGS} setgalaxy.o $(RANDOMO) $(M_OBJS) $(LIBS) +setgalaxy: setgalaxy.o $(RANDOMO) $(OBJS_SHM) + $(CC) -o $@ $(CFLAGS) ${LDFLAGS} setgalaxy.o $(RANDOMO) $(OBJS_SHM) $(LIBS) -showgalaxy: showgalaxy.o ../ntserv/distress.o $(M_OBJS) - $(CC) -o $@ $(CFLAGS) ${LDFLAGS} showgalaxy.o ../ntserv/distress.o $(M_OBJS) $(LIBS) $(LIBCURSES) $(LIBTERMCAP) +showgalaxy: showgalaxy.o ../ntserv/distress.o $(OBJS_SHM) + $(CC) -o $@ $(CFLAGS) ${LDFLAGS} showgalaxy.o ../ntserv/distress.o $(OBJS_SHM) $(LIBS) $(LIBCURSES) $(LIBTERMCAP) -stat: stat.o $(M_OBJS) - $(CC) -o $@ $(CFLAGS) ${LDFLAGS} stat.o $(M_OBJS) $(LIBS) +stat: stat.o $(OBJS_SHM) + $(CC) -o $@ $(CFLAGS) ${LDFLAGS} stat.o $(OBJS_SHM) $(LIBS) blotpassword: blotpassword.o - $(CC) -o $@ $(CFLAGS) ${LDFLAGS} blotpassword.o $(GETPATH) $(LIBS) + $(CC) -o $@ $(CFLAGS) ${LDFLAGS} blotpassword.o $(OBJS_PATH) $(LIBS) -trimscores: trimscores.o $(GETPATH) - $(CC) -o $@ $(CFLAGS) ${LDFLAGS} trimscores.o $(GETPATH) $(LIBS) +trimscores: trimscores.o $(OBJS_PATH) + $(CC) -o $@ $(CFLAGS) ${LDFLAGS} trimscores.o $(OBJS_PATH) $(LIBS) -watchmes: watchmes.o ../ntserv/distress.o $(M_OBJS) - $(CC) $(CFLAGS) ${LDFLAGS} watchmes.o ../ntserv/distress.o $(M_OBJS) $(LIBS) -o $@ +watchmes: watchmes.o ../ntserv/distress.o $(OBJS_SHM) + $(CC) $(CFLAGS) ${LDFLAGS} watchmes.o ../ntserv/distress.o $(OBJS_SHM) $(LIBS) -o $@ -xtkill: xtkill.o $(GETPATH) ../ntserv/getship.o ../ntserv/openmem.o ../ntserv/slotmaint.o ../ntserv/ltd_stats.o - $(CC) -o $@ $(CFLAGS) ${LDFLAGS} xtkill.o ../ntserv/getship.o ../ntserv/openmem.o ../ntserv/slotmaint.o ../ntserv/ltd_stats.o $(GETPATH) $(LIBS) +xtkill: xtkill.o $(OBJS_SHM) $(OBJS_PATH) ../ntserv/getship.o ../ntserv/slotmaint.o ../ntserv/ltd_stats.o ../ntserv/bay.o + $(CC) -o $@ $(CFLAGS) ${LDFLAGS} xtkill.o ../ntserv/getship.o ../ntserv/openmem.o ../ntserv/slotmaint.o ../ntserv/ltd_stats.o ../ntserv/bay.o $(OBJS_PATH) $(LIBS) -keyman: keyman.o $(GETPATH) - $(CC) -o $@ $(CFLAGS) ${LDFLAGS} keyman.o $(GETPATH) $(LIBS) +keyman: keyman.o $(OBJS_PATH) + $(CC) -o $@ $(CFLAGS) ${LDFLAGS} keyman.o $(OBJS_PATH) $(LIBS) -fun: $(RANDOMO) fun.o $(M_OBJS) - $(CC) -o $@ $(CFLAGS) ${LDFLAGS} fun.o $(RANDOMO) $(M_OBJS) $(LIBS) +fun: $(RANDOMO) fun.o $(OBJS_SHM) + $(CC) -o $@ $(CFLAGS) ${LDFLAGS} fun.o $(RANDOMO) $(OBJS_SHM) $(LIBS) -convert: $(GETPATH) convert.o - $(CC) -o $@ $(CFLAGS) ${LDFLAGS} convert.o $(GETPATH) $(LIBS) +convert: $(OBJS_PATH) convert.o + $(CC) -o $@ $(CFLAGS) ${LDFLAGS} convert.o $(OBJS_PATH) $(LIBS) -updated: update.o $(GETPATH) - $(CC) $(CFLAGS) ${LDFLAGS} -o updated update.o ../ntserv/ltd_stats.o $(GETPATH) $(EXTRALIBS) +updated: update.o $(OBJS_PATH) + $(CC) $(CFLAGS) ${LDFLAGS} -o updated update.o ../ntserv/ltd_stats.o $(OBJS_PATH) $(EXTRALIBS) ltd_dump: ltd_dump.o - $(CC) $(CFLAGS) ${LDFLAGS} -o ltd_dump ltd_dump.o ../ntserv/ltd_stats.o $(GETPATH) + $(CC) $(CFLAGS) ${LDFLAGS} -o ltd_dump ltd_dump.o ../ntserv/ltd_stats.o $(OBJS_PATH) ltd_convert: ltd_convert.o - $(CC) $(CFLAGS) ${LDFLAGS} -o ltd_convert ltd_convert.o ../ntserv/ltd_stats.o $(GETPATH) + $(CC) $(CFLAGS) ${LDFLAGS} -o ltd_convert ltd_convert.o ../ntserv/ltd_stats.o $(OBJS_PATH) conq_vert: conq_vert.o $(CC) -o $@ $(CFLAGS) ${LDFLAGS} conq_vert.o Index: tools/xtkill.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/tools/xtkill.c,v retrieving revision 1.4 diff -u -r1.4 xtkill.c --- tools/xtkill.c 10 Apr 2006 04:24:51 -0000 1.4 +++ tools/xtkill.c 10 Apr 2006 10:43:48 -0000 @@ -34,14 +34,8 @@ me->p_desspeed = me->p_ship.s_maxspeed; /* bump all docked ships */ - for (i=0; i<NUMPORTS; i++) - if (me->p_port[i] != VACANT) { - players[me->p_port[i]].p_flags &= ~PFDOCK; - me->p_docked--; - me->p_port[i] = VACANT; - me->p_flags |= PFDOCKOK; - } - + bay_release_all(me); + me->p_flags |= PFDOCKOK; } int main(int argc, char **argv) @@ -258,11 +252,8 @@ me->p_flags &= ~PFCLOAK; /* set speed 0 */ me->p_desspeed = 0; - if (me->p_flags & PFDOCK) { - players[me->p_docked].p_docked--; - players[me->p_docked].p_port[me->p_port[0]] = VACANT; - } - me->p_flags &= ~(PFREPAIR | PFBOMB | PFORBIT | PFDOCK | PFBEAMUP | PFBEAMDOWN); + bay_release(me); + me->p_flags &= ~(PFREPAIR | PFBOMB | PFORBIT | PFBEAMUP | PFBEAMDOWN); /* make unable to act */ players[player].p_flags |= PFTWARP; /* show as puck */ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : http://mailman.us.netrek.org/pipermail/netrek-dev/attachments/20060410/18b7f918/attachment-0001.pgp