[btech-checkins] CVS: btechmux/src/hcode/btech aero.move.c,1.3.2.6,1.3.2.7 autogun.c,1.1.1.1.2.1,1.1
Brought to you by:
twouters
Update of /cvsroot/btech/btechmux/src/hcode/btech In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12777/src/hcode/btech Modified Files: Tag: btmux_1_4-branch aero.move.c autogun.c bsuit.c crit.c econ.c hudinfo.c map.bits.c map.build.functions.c map.c map.conditions.c mech.advanced.c mech.ammodump.c mech.bth.c mech.combat.c mech.combat.misc.c mech.h mech.ice.c mech.maps.c mech.move.c mech.notify.c mech.physical.c mech.pickup.c mech.scan.c mech.update.c mech.utils.c p.aero.move.h p.mech.utils.h template.c Log Message: Annual (ahem) sync with the BitKeeper btechmux-stable tree (at btechmux.bkbits.net/btechmux-stable). I should sync more often but I've been short on time. If you want to keep in touch with the changes, consider using BK directly. This sync contains these BK changesets: # -------------------------------------------- # 03/09/30 th...@st... 1.26 # Skip sections that have no internals, when calculating weight of a unit. The MUX treats these sections as 'nonexistant' in all other places, too, but it's still possible (albeit difficult) to get something into those sections, eating up phantom weight. # # -------------------------------------------- # 03/10/01 th...@st... 1.27 # Safeguard against a 'shouldn't-happen' scenario that seems to have happened several times now on 3030MUX. (but was probably just generic memory corruption.) # -------------------------------------------- # 03/10/01 th...@st... 1.28.1.1 # Rather than safeguard against something, do the proper fix :) wcAmmoItems was incremented twice, in some circumstances. That's not very healthy. Remove the safeguard, it serves no purpose other than protect against hardware errors or memory corruption, both of which would cause other problems anyhow. # -------------------------------------------- # 03/10/01 th...@st... 1.30 # Merge stalker.xs4all.nl:/home/thomas/btsrc/bitkeeper/btechmux-stable # into stalker.xs4all.nl:/home/thomas/btsrc/btechmux-stable # -------------------------------------------- # 03/10/01 th...@ce... 1.31 # Ice glitchfixes: break through it while standing, and don't survive as tank breaking ice. # -------------------------------------------- # 03/10/01 th...@ce... 1.32 # More ice glitch fixes: properly break ice when picking a unit (but not a MechWarrior) up through it. # -------------------------------------------- # 03/10/01 th...@ce... 1.33 # Wups... don't sink hovertows. # -------------------------------------------- # 03/10/05 th...@st... 1.34 # Make MUX function 'btgetdbrefbyid' accept a map as well as a 'mech as its first argument. # -------------------------------------------- # 03/10/12 th...@st... 1.35 # - Fix bug in MechPrefs (MUX +bug #1152) and make sure it doesn't happen again. # - Add MechPrefs to xcodevalues. # # -------------------------------------------- # 03/10/12 th...@st... 1.36 # - Consider OOD-ing 'mechs as Jumping 'mechs where appropriate. # -------------------------------------------- # 03/10/14 th...@st... 1.37 # Add new 'c' option to LRS, for colorized terrain. # -------------------------------------------- # 03/10/14 th...@st... 1.38 # Don't cliff hovers that go from l0 bridge to l1 bridge. # -------------------------------------------- # 03/10/14 th...@st... 1.39 # Don't drown vehicles that manage to break l0 ice. # -------------------------------------------- # 03/10/15 th...@st... 1.40 # Add tactical/lrs-like argument handling to navigate. You can now say 'navigate 120 1' to see the hex bearing 120 of you as if you were in it, or 'navigate qq' to see the navigate for 'Mech 'qq'. Max range is the same as for 'tactical'. # -------------------------------------------- # 03/10/18 th...@st... 1.41 # - Add 'tactical b', for displaying valid DropShip landing zones # - Add the ability to run 'checklz x y' for hexes in TacRange. # -------------------------------------------- # 03/10/19 th...@st... 1.42 # - Add new 'btmechfreqs' function, returning the radio freqs on a 'Mech. It returns a comma separated list of entries, each of which is: # # <freqnum> | <frequency> | <freqflags> | <colorcode> # # Where freqnum starts at 1, frequency is the actual frequency set, colormode is the color setting for that channel (captial letters meaning bold), and freqflags is a bitvector-string with the following meaning: # # - 'a': Freq is digital # - 'b': Freq is muted # - 'c': Freq is set Relay # - 'd': Freq is set Info # - 'e': Freq is set Scan # # Comtitles are not returned because of escaping issues. # -------------------------------------------- # 03/10/19 th...@st... 1.43 # Make second argument to 'btstores' optional. When not passed, 'btstores' will return partname:amount pairs, separated by |'s, for all parts in the inventory of the object. # -------------------------------------------- # 03/10/19 th...@st... 1.44 # Patch from Tony to make tel() and @tel 'teleport' exits the same way the 'drop' command does. # -------------------------------------------- # 03/10/21 th...@st... 1.45 # Fix eternal loop when calling btdamagemech() with a 'clustersize' of 0. # -------------------------------------------- # 03/10/31 th...@st... 1.46 # Glitchfix. # -------------------------------------------- # 03/10/31 th...@st... 1.47 # Possibly fix memory corruption problems 3030 has been having, by fixing around tprintf (as suggested by Null @ 3029.) # -------------------------------------------- # 03/11/14 th...@ce... 1.44.1.1 # Fix buglet in btlostohex(): use proper range. # -------------------------------------------- # 03/11/15 th...@st... 1.48 # Fix possibly malicious crashing bug in macros. # -------------------------------------------- # 03/11/15 th...@ce... 1.49 # Merge http://btechmux.bkbits.net/btechmux-stable # into centurion.xs4all.nl:/home/thomas/btsrc/btechmux-stable # -------------------------------------------- # 03/11/20 th...@st... 1.50 # Misc cleanup fixes. Stuff that probably didn't cause any real-world bugs, but should be fixed anyway. # -------------------------------------------- # 03/11/23 th...@st... 1.51 # - Facilitate debugging by not closing stdin/stdout. Old behaviour can be had by defining CLOSE_STDIN somewhere, but I have no use for it yet. # - Zap rediculous 'filedecriptor caching' that just re-used fd0 for everything, brutally closing it if needed. I'm suprised this hasn't caused odd bugs where data went to the wrong file. Totally unnecessary. # - Various memory buglets found by Valgrind. Some things were obviously wrong but never went wrong thanks to the reliability of stack layout in GCC. Others were potentially wrong but probably never did any harm -- but I could be wrong. # # -------------------------------------------- # 04/02/09 th...@st... 1.52 # Fix off-by-one error in reading maps with an X size of MAPX (1000 by default.) # -------------------------------------------- # 04/02/10 th...@st... 1.53 # Open help/news files for reading, not writing. Oopsie from last changeset. # -------------------------------------------- # 04/02/12 th...@st... 1.54 # remove unused file. # -------------------------------------------- # 04/03/05 th...@ce... 1.49.1.1 # foobar changeset # -------------------------------------------- # 04/03/05 th...@ce... 1.49.1.2 # foobar2 # -------------------------------------------- # 04/05/08 th...@st... 1.55 # Properly display valid/invalid LZ's in 'tactical b' even when not using colours. Previously, the characters \240 and \241 (inverted exclamation mark and non-break space, respectively, in ISO 8859-1 and -15) were displayed. # # -------------------------------------------- # 04/05/08 th...@st... 1.56 # Protect some xcodevalues from being changed, to avoid memory corruption and the like. # -------------------------------------------- # 04/05/09 th...@st... 1.57 # Fix some buglets in previous fixes: don't close fd's that weren't opened, and when using memmove instead of strcpy, include the terminating NUL manually. # -------------------------------------------- # 04/05/09 th...@st... 1.58 # Fix typo in previous checkin, and compile before checking in. # -------------------------------------------- # 04/05/11 th...@ce... 1.59 # Merge http://btechmux.bkbits.net/btechmux-stable # into centurion.xs4all.nl:/home/thomas/btsrc/btechmux-stable # -------------------------------------------- # 04/05/11 th...@ce... 1.60 # Fix compiler warnings: # - Add a few missing include files # - Remove unused variables # -------------------------------------------- # 04/05/11 th...@ce... 1.61 # Fix small loophole where you could tell an out-of-LOS unit's approximate location by triangulating 'out of arc' messages. Always give the same 'out of los' message for mechID's that are not in LOS, even if the mechID's don't exist or if they are out of range or out of arc. # -------------------------------------------- # 04/05/11 th...@st... 1.62 # Fix off-by-one error in the kick-decision range check in autopilots. # -------------------------------------------- # 04/07/29 th...@st... 1.63 # Attempt to improve the dieroll's randomness somewhat. # -------------------------------------------- Index: aero.move.c =================================================================== RCS file: /cvsroot/btech/btechmux/src/hcode/btech/aero.move.c,v retrieving revision 1.3.2.6 retrieving revision 1.3.2.7 diff -C2 -d -r1.3.2.6 -r1.3.2.7 *** aero.move.c 23 May 2003 23:20:13 -0000 1.3.2.6 --- aero.move.c 8 Aug 2004 23:48:16 -0000 1.3.2.7 *************** *** 246,249 **** --- 246,291 ---- } + enum { + NO_ERROR, INVALID_TERRAIN, UNEVEN_TERRAIN, BLOCKED_LZ + }; + + char *reasons[] = { + "Improper terrain", + "Uneven ground", + "Blocked landing zone" + }; + + static int improper_lz_status; + static int improper_lz_height; + + static void ImproperLZ_callback(MAP *map, int x, int y) + { + if (Elevation(map, x, y) != improper_lz_height) + improper_lz_status = 0; + else + improper_lz_status++; + } + + #define MechCheckLZ(m) ImproperLZ((m), MechX((m)), MechY((m))) + + int ImproperLZ(MECH * mech, int x, int y) + { + MAP * map = getMap(mech->mapindex); + + if (GetRTerrain(map, x, y) != GRASSLAND && + GetRTerrain(map, x, y) != ROAD) + return INVALID_TERRAIN; + + improper_lz_status = 0; + improper_lz_height = Elevation(map, x, y); + visit_neighbor_hexes(map, x, y, ImproperLZ_callback); + + if (improper_lz_status != 6) + return UNEVEN_TERRAIN; + if (is_blocked_lz(mech, map, x, y)) + return BLOCKED_LZ; + return NO_ERROR; + } + void aero_land(dbref player, void *data, char *buffer) { *************** *** 310,314 **** && t == BUILDING)), "You can't land on this type of terrain."); ! if (MechType(mech) != CLASS_VTOL && ImproperLZ(mech)) { mech_notify(mech, MECHALL, "This location is no good for landing!"); --- 352,356 ---- && t == BUILDING)), "You can't land on this type of terrain."); ! if (MechType(mech) != CLASS_VTOL && MechCheckLZ(mech)) { mech_notify(mech, MECHALL, "This location is no good for landing!"); *************** *** 636,678 **** } - enum { - NO_ERROR, INVALID_TERRAIN, UNEVEN_TERRAIN, BLOCKED_LZ - }; - - char *reasons[] = { - "Improper terrain", - "Uneven ground", - "Blocked landing zone" - }; - - static int improper_lz_status; - static int improper_lz_height; - - static void ImproperLZ_callback(MAP *map, int x, int y) - { - if (Elevation(map, x, y) != improper_lz_height) - improper_lz_status = 0; - else - improper_lz_status++; - } - - int ImproperLZ(MECH *mech) - { - MAP *map = getMap(mech->mapindex); - int x = MechX(mech), y = MechY(mech); - - if (GetRTerrain(map, x, y) != GRASSLAND && - GetRTerrain(map, x, y) != ROAD) - return INVALID_TERRAIN; - improper_lz_status = 0; - improper_lz_height = Elevation(map, x, y); - visit_neighbor_hexes(map, x, y, ImproperLZ_callback); - if (improper_lz_status != 6) - return UNEVEN_TERRAIN; - if (is_blocked_lz(mech, map, x, y)) - return BLOCKED_LZ; - return NO_ERROR; - } - static char *colorstr(int serious) { --- 678,681 ---- *************** *** 686,690 **** void DS_LandWarning(MECH * mech, int serious) { ! int ilz = ImproperLZ(mech); if (!ilz) --- 689,693 ---- void DS_LandWarning(MECH * mech, int serious) { ! int ilz = MechCheckLZ(mech); if (!ilz) *************** *** 700,716 **** void aero_checklz(dbref player, MECH * mech, char *buffer) { ! int ilz; cch(MECH_USUAL); ! DOCHECK(Landed(mech), ! "You are landed already.. it looks good, doesn't it?"); ! ilz = ImproperLZ(mech); DOCHECKMA(!ilz, ! tprintf("The hex (%d,%d) looks good enough for a landing.", ! MechX(mech), MechY(mech) ! )); ilz--; mech_notify(mech, MECHALL, tprintf("The hex (%d,%d) doesn't look good for landing: %s.", ! MechX(mech), MechY(mech), reasons[ilz])); } --- 703,740 ---- void aero_checklz(dbref player, MECH * mech, char *buffer) { ! int ilz, argc; ! char *args[3]; ! int x, y; cch(MECH_USUAL); ! ! argc = mech_parseattributes(buffer, args, 3); ! switch(argc) { ! case 2: ! x = atoi(args[0]); ! y = atoi(args[1]); ! if (!MechIsObservator(mech)) { ! float fx, fy; ! MapCoordToRealCoord(x, y, &fx, &fy); ! DOCHECK(FindHexRange(MechFX(mech), MechFY(mech), fx, fy) > ! MechTacRange(mech), "Out of range!"); ! } ! break; ! case 0: ! x = MechX(mech); ! y = MechY(mech); ! break; ! default: ! notify(player, "Invalid number of parameters!"); ! return; ! } ! ! ilz = ImproperLZ(mech, x, y); DOCHECKMA(!ilz, ! tprintf("The hex (%d,%d) looks good enough for a landing.", ! x, y)); ilz--; mech_notify(mech, MECHALL, tprintf("The hex (%d,%d) doesn't look good for landing: %s.", ! x, y, reasons[ilz])); } Index: autogun.c =================================================================== RCS file: /cvsroot/btech/btechmux/src/hcode/btech/autogun.c,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.1.1.1.2.2 diff -C2 -d -r1.1.1.1.2.1 -r1.1.1.1.2.2 *** autogun.c 30 Sep 2003 01:38:35 -0000 1.1.1.1.2.1 --- autogun.c 8 Aug 2004 23:48:16 -0000 1.1.1.1.2.2 *************** *** 177,181 **** if (t->mynum == MechTarget(mech)) locktarg_num = target_count; ! targets[target_count++] = t; if (MechType(mech) == CLASS_MECH && (targetrange[target_count] <= 1.0) && --- 177,181 ---- if (t->mynum == MechTarget(mech)) locktarg_num = target_count; ! targets[target_count] = t; if (MechType(mech) == CLASS_MECH && (targetrange[target_count] <= 1.0) && *************** *** 186,189 **** --- 186,190 ---- mech_kick(a->mynum, mech, tb); } + target_count++; } MechNumSeen(mech) = ttarget_count; Index: bsuit.c =================================================================== RCS file: /cvsroot/btech/btechmux/src/hcode/btech/bsuit.c,v retrieving revision 1.5.2.2 retrieving revision 1.5.2.3 diff -C2 -d -r1.5.2.2 -r1.5.2.3 *** bsuit.c 4 Apr 2002 13:13:08 -0000 1.5.2.2 --- bsuit.c 8 Aug 2004 23:48:16 -0000 1.5.2.3 *************** *** 288,292 **** targetID[1] = args[0][1]; targetnum = FindTargetDBREFFromMapNumber(mech, targetID); ! DOCHECK1(targetnum <= 0, "That is not a valid target ID!"); t = getMech(targetnum); DOCHECK1(!(t), "Invalid default target!"); --- 288,292 ---- targetID[1] = args[0][1]; targetnum = FindTargetDBREFFromMapNumber(mech, targetID); ! DOCHECK1(targetnum <= 0, "Target is not in line of sight!"); t = getMech(targetnum); DOCHECK1(!(t), "Invalid default target!"); *************** *** 296,301 **** return 1; } ! DOCHECK1((range = ! FaMechRange(mech, t)) >= 1.0, "Target out of range!"); DOCHECK1(Jumping(t), "That target's unreachable right now!"); DOCHECK1(MechType(t) != CLASS_MECH, "That target is of invalid type."); --- 296,303 ---- return 1; } ! range = FaMechRange(mech, t); ! DOCHECK1(!InLineOfSight_NB(mech, t, MechX(t), MechY(t), range), ! "Target is not in line of sight!"); ! DOCHECK1(range >= 1.0, "Target out of range!"); DOCHECK1(Jumping(t), "That target's unreachable right now!"); DOCHECK1(MechType(t) != CLASS_MECH, "That target is of invalid type."); Index: crit.c =================================================================== RCS file: /cvsroot/btech/btechmux/src/hcode/btech/crit.c,v retrieving revision 1.5.2.4 retrieving revision 1.5.2.5 diff -C2 -d -r1.5.2.4 -r1.5.2.5 *** crit.c 24 Jun 2002 15:34:40 -0000 1.5.2.4 --- crit.c 8 Aug 2004 23:48:16 -0000 1.5.2.5 *************** *** 1685,1692 **** int weapindx, damage, loop, destroycrit, weapon_slot; int temp; - int wWeapDestroyed = 0; - int wFirstCrit = 0; - int wMaxCrits; - int wAmmoSection, wAmmoCritSlot; char locname[30]; char msgbuf[MBUF_SIZE]; --- 1685,1688 ---- *************** *** 1695,1699 **** int tLocIsLeg = ((hitloc == LLEG || hitloc == RLEG) || ((hitloc == LARM || hitloc == RARM) && MechIsQuad(wounded))); - int firstCrit = 0; char partBuf[100]; --- 1691,1694 ---- Index: econ.c =================================================================== RCS file: /cvsroot/btech/btechmux/src/hcode/btech/econ.c,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** econ.c 3 Jan 2002 01:01:03 -0000 1.1.1.1 --- econ.c 8 Aug 2004 23:48:16 -0000 1.1.1.1.2.1 *************** *** 35,45 **** return; j++; ! if (*j) ! strcpy(entry, j + 1); ! else { if (entry == alku) ! strcpy(alku, ""); else ! strcpy(entry - 1, ""); } } --- 35,48 ---- return; j++; ! if (*j) { ! /* Move the remainder of the string, including the terminating NUL, ! but not including the separating comma */ ! j++; ! memmove(entry, j, strlen(j) + 1); ! } else { if (entry == alku) ! *alku = '\0'; else ! *(entry - 1) = '\0'; } } *************** *** 51,55 **** sprintf(to + strlen(to), ",[%s]", data); else ! sprintf(to + strlen(to), "[%s]", data); } --- 54,58 ---- sprintf(to + strlen(to), ",[%s]", data); else ! sprintf(to, "[%s]", data); } Index: hudinfo.c =================================================================== RCS file: /cvsroot/btech/btechmux/src/hcode/btech/hudinfo.c,v retrieving revision 1.8.2.9 retrieving revision 1.8.2.10 diff -C2 -d -r1.8.2.9 -r1.8.2.10 *** hudinfo.c 10 Dec 2002 14:21:02 -0000 1.8.2.9 --- hudinfo.c 8 Aug 2004 23:48:16 -0000 1.8.2.10 *************** *** 239,243 **** { static char wstatus[12]; - int tempstat; if (PartIsBroken(mech, sect, crit)) --- 239,242 ---- *************** *** 493,497 **** { int i; - int spec; char firemodes[30] = ""; char ammomodes[20] = ""; --- 492,495 ---- *************** *** 1037,1043 **** { char response[LBUF_SIZE]; ! int sect, dummy; MECH *targ; - float range; targ = hud_scantarget(d, mech, msgclass, args); --- 1035,1040 ---- { char response[LBUF_SIZE]; ! int sect; MECH *targ; targ = hud_scantarget(d, mech, msgclass, args); Index: map.bits.c =================================================================== RCS file: /cvsroot/btech/btechmux/src/hcode/btech/map.bits.c,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** map.bits.c 3 Jan 2002 01:01:38 -0000 1.1.1.1 --- map.bits.c 8 Aug 2004 23:48:16 -0000 1.1.1.1.2.1 *************** *** 75,79 **** c = 0; if (foo[i]) { ! for (j = 0; j < xs; j++) if (foo[i][j]) c++; --- 75,79 ---- c = 0; if (foo[i]) { ! for (j = 0; j < realnum(xs); j++) if (foo[i][j]) c++; Index: map.build.functions.c =================================================================== RCS file: /cvsroot/btech/btechmux/src/hcode/btech/map.build.functions.c,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** map.build.functions.c 6 Dec 2002 14:28:41 -0000 1.1.2.4 --- map.build.functions.c 8 Aug 2004 23:48:16 -0000 1.1.2.5 *************** *** 1,509 **** - - /* - * $Id$ - * - * Author: Cord Awtry <ki...@bs...> - * - * Copyright (c) 2002 Cord Awtry - * All rights reserved - */ - - #include "mech.h" - #include "p.mech.build.h" - #include "p.mechfile.h" - #include "p.mech.maps.h" - #include "p.template.h" - - /* Convert some of the roads to bridges */ - - /* Logic: OPPOSITE sides must have water, within r<=3 of each other */ - - extern int dirs[6][2]; - - int water_distance(MAP * map, int x, int y, int dir, int max) - { - int i; - int x2, y2; - - for (i = 1; i < max; i++) { - x = x + dirs[dir][0]; - y = y + dirs[dir][1]; - if (!x && dirs[dir][0]) - y--; - x2 = BOUNDED(0, x, map->map_width - 1); - y2 = BOUNDED(0, y, map->map_height - 1); - if (x != x2 || y != y2) - return max; - if (GetHexTerrain(map, x, y) == WATER || - GetHexTerrain(map, x, y) == ICE) - return i; - if (GetHexTerrain(map, x, y) != BRIDGE && - GetHexTerrain(map, x, y) != ROAD) - return max; - } - return max; - } - - static int eligible_bridge_hex(MAP * map, int x, int y) - { - int i, j, k; - - for (k = 0; k < 3; k++) - if ((i = water_distance(map, x, y, k, 4)) < 4) - if ((j = water_distance(map, x, y, k + 3, 4)) < 4) { - if ((i - j) > 3) - continue; - - return 1; - } - - return 0; - } - - static void make_bridges(MAP * map) - { - int x, y; - - for (x = 0; x < map->map_width; x++) - for (y = 0; y < map->map_height; y++) - if (GetHexTerrain(map, x, y) == ROAD) - if (eligible_bridge_hex(map, x, y)) - SetHexTerrain(map, x, y, BRIDGE); - } - - static void repairBrokenLayer(MAP * map, int x, int y) - { - int layers = GetHexLayers(map, x, y); - int data = GetHexLayerData(map, x, y); - - if ((layers & HEXLAYER_SNOW) || (layers & HEXLAYER_DEEP_SNOW)) { - if (data <= 0) { - if (layers & HEXLAYER_SNOW) - data = Number(1, 1000); - else - data = Number(1001, 2000); - - SetHexLayerData(map, x, y, data); - SendDebug(tprintf("Repairing the snow depth at %d %d", x, y)); - } - } else - data = 0; - } - - void loadMap(dbref player, void *data, char *buffer) - { - MAP *map; - char *args[1]; - char openfile[50]; - char terr, elev; - int i1, i2, i3, i4, i5; - FILE *fp; - char row[MAPX * 2 + 2]; - int i, j = 0, height, width, filemode; - char line[100]; - int wordsRead = 0; - - map = (MAP *) data; - - if (!CheckData(player, map)) - return; - - DOCHECK(mech_parseattributes(buffer, args, 1) != 1, - "Invalid number of arguments!"); - if (strlen(args[0]) >= MAP_NAME_SIZE) - args[MAP_NAME_SIZE] = 0; - sprintf(openfile, "%s/", MAP_PATH); - strcat(openfile, args[0]); - DOCHECK(!(fp = - my_open_file(openfile, "r", &filemode)), - tprintf("Unable to read %s!", args[0])); - del_mapobjs(map); /* Just in case */ - notify(player, tprintf("Loading %s", args[0])); - - if (fscanf(fp, "%d %d\n", &height, &width) != 2 || height < 1 || - height > MAPY || width < 1 || width > MAPX) { - SendError(tprintf("Map #%d: Invalid height and/or width", - map->mynum)); - width = DEFAULT_MAP_WIDTH; - height = DEFAULT_MAP_HEIGHT; - } - - freeOldMap(map); - initializeMap(map, width, height); - - /* Now we start to build it... */ - for (i = 0; i < height; i++) { - if (feof(fp) || fgets(row, 2 * MAPX + 1, fp) == NULL || - strlen(row) < (2 * width)) { - break; - } - - for (j = 0; j < width; j++) { - terr = row[2 * j]; - elev = row[2 * j + 1] - '0'; - - switch (terr) { - case FIRE: - map->flags |= MAPFLAG_FIRES; - break; - case TFIRE: - case SMOKE: - case '.': - terr = GRASSLAND; - break; - case '\'': - terr = LIGHT_FOREST; - break; - } - - if (!strcmp(GetTerrainName_base(terr), "Unknown")) { - SendError(tprintf - ("Map #%d: Invalid terrain at %d,%d: '%c'", map->mynum, - j, i, terr)); - terr = GRASSLAND; - } - - SetMapHexData(map, j, i, terr, elev, 0, 0); - } - } - - if (i != height) { - SendError(tprintf - ("Error: EOF reached prematurely. (x%d != %d || y%d != %d)", j, - width, i, height)); - my_close_file(fp, &filemode); - return; - } - - map->grav = 100; - map->temp = 20; - - if (!feof(fp)) { - while (fgets(line, 100, fp)) { - if ((wordsRead = - sscanf(line, "LAYER: %d %d %d %d", &i1, &i2, &i3, - &i4)) == 4) { - if (wordsRead > 2) { - SetHexLayers(map, i1, i2, i3); - - if (wordsRead > 3) - SetHexLayerData(map, i1, i2, i4); - else - SetHexLayerData(map, i1, i2, 0); - - repairBrokenLayer(map, i1, i2); - } - } else if ((wordsRead = sscanf(line, "FLAGS: %d", &i1)) == 1) { - map->flags = i1; - } else if ((wordsRead = sscanf(line, "GRAVITY: %d", &i1)) == 1) { - map->grav = i1; - } else if ((wordsRead = - sscanf(line, "TEMPERATURE: %d", &i1)) == 1) { - map->temp = i1; - } else { - SendDebug(tprintf("Invalid data read during map load: %s.", - line)); - } - } - } - - map->map_height = height; - map->map_width = width; - if (!MapNoBridgify(map)) - make_bridges(map); - sprintf(map->mapname, args[0]); - notify(player, "Loading complete!"); - my_close_file(fp, &filemode); - - notify(player, "Clearing Mechs off Newly Loaded Map"); - - if (player != 1) - map_clearmechs(player, data, ""); - } - - void saveMap(dbref player, void *data, char *buffer) - { - MAP *map; - char *args[1]; - FILE *fp; - char openfile[50]; - int i, j; - char row[MAPX * 2 + 1]; - char terrain; - int filemode; - int layer, layerData; - - map = (MAP *) data; - - if (!CheckData(player, map)) - return; - - DOCHECK(mech_parseattributes(buffer, args, 1) != 1, - "Invalid number of arguments!"); - - if (strlen(args[0]) >= MAP_NAME_SIZE) - args[MAP_NAME_SIZE] = 0; - - notify(player, tprintf("Saving %s", args[0])); - sprintf(openfile, "%s/", MAP_PATH); - strcat(openfile, args[0]); - - DOCHECK(!(fp = my_open_file(openfile, "w", &filemode)), - "Unable to open the map file!"); - - fprintf(fp, "%d %d\n", map->map_height, map->map_width); - - for (i = 0; i < map->map_height; i++) { - mapobj *mo; - - row[0] = 0; - - for (j = 0; j < map->map_width; j++) { - terrain = GetHexTerrain(map, j, i); - - switch (terrain) { - case ' ': - terrain = '.'; - break; - case FIRE: - /* check if we're burnin', if so, alter terrain type */ - if ((mo = find_mapobj(map, j, i, TYPE_FIRE))) - terrain = TFIRE; - else if (!(map->flags & MAPFLAG_FIRES)) { - SetHexTerrain(map, j, i, ' '); - SendEvent(tprintf - ("[lost?] fire event noticed on map #%d (%s) at %d,%d", - map->mynum, map->mapname, j, i)); - terrain = '.'; - } - break; - case SMOKE: - terrain = GetRTerrain(map, j, i); - - if (terrain == ' ') - terrain = '.'; - - if (terrain == SMOKE) { - SetHexTerrain(map, j, i, ' '); - SendEvent(tprintf - ("[lost?] smoke event noticed on map #%d (%s) at %d,%d", - map->mynum, map->mapname, j, i)); - terrain = '.'; - } - break; - } - - row[j * 2] = terrain; - row[j * 2 + 1] = GetHexElevation(map, j, i) + '0'; - } - - row[j * 2] = 0; - fprintf(fp, "%s\n", row); - } - - /* Write out our map data */ - fprintf(fp, "FLAGS: %d\n", map->flags); - fprintf(fp, "GRAVITY: %d\n", map->grav); - fprintf(fp, "TEMPERATURE: %d\n", map->temp); - - /* Write out our layer data */ - for (i = 0; i < map->map_height; i++) { - for (j = 0; j < map->map_width; j++) { - layer = GetHexLayers(map, j, i); - layerData = GetHexLayerData(map, j, i); - - if (layer & HEXLAYERS_TERRAIN) - fprintf(fp, "LAYER: %d %d %d %d\n", j, i, layer, - layerData); - } - } - - notify(player, "Saving complete!"); - my_close_file(fp, &filemode); - } - - void freeOldMap(MAP * map) - { - int i; - - if (!map) - return; - - if (map->hexdata) { - for (i = map->map_height - 1; i >= 0; i--) - if (map->hexdata[i]) - free(map->hexdata[i]); - - free(map->hexdata); - } - } - - HEXDATA *GetMapHexData(MAP * map, int x, int y) - { - HEXDATA *d = NULL; - - if (!map) - return NULL; - - if (x < 0 || y < 0 || x >= map->map_width || y >= map->map_height) - return NULL; - - *d = map->hexdata[x][y]; - - return d; - } - - void SetMapHexData(MAP * map, int x, int y, char terrain, char elevation, - int layers, int layerData) - { - map->hexdata[x][y].terrain = terrain; - map->hexdata[x][y].elevation = elevation; - map->hexdata[x][y].layers = layers; - map->hexdata[x][y].layerData = layerData; - } - - void ClearTerrainLayers(MAP * map, int x, int y) - { - if (!map) - return; - - map->hexdata[x][y].layers &= ~HEXLAYERS_TERRAIN; - map->hexdata[x][y].layerData = 0; - } - - void AddTerrainLayer(MAP * map, int x, int y, int layer, int layerData) - { - map->hexdata[x][y].layers |= layer; - map->hexdata[x][y].layerData = layerData; - } - - static int validateLayers(MAP * map, int x, int y, int layers) - { - int terr = UNKNOWN_TERRAIN; - int elev = 0; - - if (map) { - terr = GetHexTerrain(map, x, y); - elev = GetHexElevation(map, x, y); - } - - if (!(layers & HEXLAYERS_TERRAIN)) - return layers; - - if ((layers & HEXLAYER_SNOW) || (layers & HEXLAYER_DEEP_SNOW)) { - layers &= ~(HEXLAYER_MUD | HEXLAYER_SWAMP | HEXLAYER_RAPIDS); - - if (IsIce(terr) || IsRealWater(terr)) - layers &= ~(HEXLAYER_SNOW | HEXLAYER_DEEP_SNOW); - - if (layers & HEXLAYER_DEEP_SNOW) - layers &= ~HEXLAYER_SNOW; - } - - if (layers & HEXLAYER_MUD) { - if (IsRealWater(terr)) - layers &= ~HEXLAYER_MUD; - else - layers &= ~(HEXLAYER_SWAMP | HEXLAYER_RAPIDS); - } - - if (layers & HEXLAYER_SWAMP) { - if (!(IsGrassland(terr) || (IsRealWater(terr) && !elev))) - layers &= ~HEXLAYER_SWAMP; - else - layers &= ~HEXLAYER_RAPIDS; - } - - if (layers & HEXLAYER_RAPIDS) { - if (!(IsRealWater(terr) && (elev > 0))) - layers &= ~HEXLAYER_RAPIDS; - } - - return layers; - } - - void validateExistingLayers(MAP * map, int x, int y) - { - int curLayers, newLayers; - - curLayers = GetHexLayers(map, x, y); - newLayers = validateLayers(map, x, y, curLayers); - - if (newLayers != curLayers) - map->hexdata[x][y].layers = newLayers; - } - - void validateSnowDepth(MAP * map, int x, int y) - { - int hasSnow = HexHasSnow(map, x, y); - int hasDeepSnow = HexHasDeepSnow(map, x, y); - int data = GetHexLayerData(map, x, y); - int layers = GetHexLayers(map, x, y); - - if (data <= 0) { - layers &= ~(HEXLAYER_SNOW | HEXLAYER_DEEP_SNOW); - map->hexdata[x][y].layers = layers; - map->hexdata[x][y].layerData = 0; - - return; - } - - if (!hasSnow && !hasDeepSnow) - return; - - if ((data <= 1000) && hasDeepSnow) { - layers &= ~HEXLAYER_DEEP_SNOW; - layers |= HEXLAYER_SNOW; - - map->hexdata[x][y].layers = layers; - } else if ((data > 1000) && hasSnow) { - layers &= ~HEXLAYER_SNOW; - layers |= HEXLAYER_DEEP_SNOW; - - map->hexdata[x][y].layers = layers; - } - } - - /* Getters and Setters for the various hex related data */ - char GetHexTerrain(MAP * map, int x, int y) - { - return map->hexdata[x][y].terrain; - } - - char GetHexElevation(MAP * map, int x, int y) - { - return map->hexdata[x][y].elevation; - } - - int GetHexLayers(MAP * map, int x, int y) - { - return map->hexdata[x][y].layers; - } - - int GetHexLayerData(MAP * map, int x, int y) - { - return map->hexdata[x][y].layerData; - } - - void SetHexTerrain(MAP * map, int x, int y, char terrain) - { - map->hexdata[x][y].terrain = terrain; - } - - void SetHexElevation(MAP * map, int x, int y, char elevation) - { - map->hexdata[x][y].elevation = elevation; - } - - void SetHexLayers(MAP * map, int x, int y, int layers) - { - if (GetHexLayers(map, x, y) == layers) - return; - - map->hexdata[x][y].layers = validateLayers(map, x, y, layers); - } - - void SetHexLayerData(MAP * map, int x, int y, int layerData) - { - map->hexdata[x][y].layerData = layerData; - } --- 0 ---- Index: map.c =================================================================== RCS file: /cvsroot/btech/btechmux/src/hcode/btech/map.c,v retrieving revision 1.1.1.1.2.6 retrieving revision 1.1.1.1.2.7 diff -C2 -d -r1.1.1.1.2.6 -r1.1.1.1.2.7 *** map.c 30 Sep 2003 01:38:36 -0000 1.1.1.1.2.6 --- map.c 8 Aug 2004 23:48:16 -0000 1.1.1.1.2.7 *************** *** 235,239 **** int i1, i2, i3; FILE *fp; ! char row[MAPX * 2 + 2]; int i, j = 0, height, width, filemode; --- 235,239 ---- int i1, i2, i3; FILE *fp; ! char row[MAPX * 2 + 3]; int i, j = 0, height, width, filemode; *************** *** 265,269 **** for (i = 0; i < height; i++) { if (feof(fp) ! || fgets(row, 2 * MAPX + 1, fp) == NULL || strlen(row) < (2 * width)) { break; --- 265,269 ---- for (i = 0; i < height; i++) { if (feof(fp) ! || fgets(row, 2 * MAPX + 2, fp) == NULL || strlen(row) < (2 * width)) { break; Index: map.conditions.c =================================================================== RCS file: /cvsroot/btech/btechmux/src/hcode/btech/map.conditions.c,v retrieving revision 1.2.2.4 retrieving revision 1.2.2.5 diff -C2 -d -r1.2.2.4 -r1.2.2.5 *** map.conditions.c 18 Jul 2002 18:42:57 -0000 1.2.2.4 --- map.conditions.c 8 Aug 2004 23:48:16 -0000 1.2.2.5 *************** *** 170,174 **** int critType; int nhs = 0; - int z; int tDoAutoFall = 0; int tNormalizeAllCrits = 0; --- 170,173 ---- *************** *** 177,182 **** || hitloc == LARM) && (MechIsQuad(wounded)))); - MAP *map; - if (!(MechType(wounded) == CLASS_MECH || MechType(wounded) == CLASS_MW || MechType(wounded) == CLASS_BSUIT)) { --- 176,179 ---- Index: mech.advanced.c =================================================================== RCS file: /cvsroot/btech/btechmux/src/hcode/btech/mech.advanced.c,v retrieving revision 1.3.2.6 retrieving revision 1.3.2.7 diff -C2 -d -r1.3.2.6 -r1.3.2.7 *** mech.advanced.c 30 Sep 2003 01:38:36 -0000 1.3.2.6 --- mech.advanced.c 8 Aug 2004 23:48:16 -0000 1.3.2.7 *************** *** 860,864 **** int needed = 2 * (1 + (MechSChargeCounter(mech)++)); int roll = PRoll(mech); ! int i, j, count = 0; int maxspeed, newmaxspeed = 0; int critType; --- 860,864 ---- int needed = 2 * (1 + (MechSChargeCounter(mech)++)); int roll = PRoll(mech); ! int j, count = 0; int maxspeed, newmaxspeed = 0; int critType; *************** *** 1762,1765 **** --- 1762,1769 ---- char * state; + if (!target_mech) { + SendError("Invalid target_mech in display_mechpref!"); + return "Unknown error; contact a Wizard."; + } if (((MechPrefs(target_mech) & info.bit) && (info.flags & MECHPREF_FLAG_INVERTED)) || *************** *** 1797,1800 **** --- 1801,1805 ---- ShowCoolMenu(player, c); KillCoolMenu(c); + target_mech = NULL; } else { int i; *************** *** 1816,1822 **** MechPrefs(mech) |= (info.bit); ! if (((MechPrefs(target_mech) & info.bit) && (info.flags & MECHPREF_FLAG_INVERTED)) || ! (!(MechPrefs(target_mech) & info.bit) && !(info.flags & MECHPREF_FLAG_INVERTED))) { if (info.flags & MECHPREF_FLAG_NEGATIVE) --- 1821,1827 ---- MechPrefs(mech) |= (info.bit); ! if (((MechPrefs(mech) & info.bit) && (info.flags & MECHPREF_FLAG_INVERTED)) || ! (!(MechPrefs(mech) & info.bit) && !(info.flags & MECHPREF_FLAG_INVERTED))) { if (info.flags & MECHPREF_FLAG_NEGATIVE) Index: mech.ammodump.c =================================================================== RCS file: /cvsroot/btech/btechmux/src/hcode/btech/mech.ammodump.c,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.1.1.1.2.2 diff -C2 -d -r1.1.1.1.2.1 -r1.1.1.1.2.2 *** mech.ammodump.c 11 Dec 2002 00:44:59 -0000 1.1.1.1.2.1 --- mech.ammodump.c 8 Aug 2004 23:48:16 -0000 1.1.1.1.2.2 *************** *** 349,354 **** } } - - wcAmmoItems++; } else { /* crit specific dump */ wSecIter = ((wEventData >> 16) & 0xFF) - 1; --- 349,352 ---- Index: mech.bth.c =================================================================== RCS file: /cvsroot/btech/btechmux/src/hcode/btech/mech.bth.c,v retrieving revision 1.4.2.6 retrieving revision 1.4.2.7 diff -C2 -d -r1.4.2.6 -r1.4.2.7 *** mech.bth.c 17 Jul 2002 12:32:47 -0000 1.4.2.6 --- mech.bth.c 8 Aug 2004 23:48:16 -0000 1.4.2.7 *************** *** 623,627 **** float target_speed = 0.0; int returnValue = 0; - int i; float m = 1.0; MAP *map = FindObjectsData(target->mapindex); --- 623,626 ---- Index: mech.combat.c =================================================================== RCS file: /cvsroot/btech/btechmux/src/hcode/btech/mech.combat.c,v retrieving revision 1.7.2.12 retrieving revision 1.7.2.13 diff -C2 -d -r1.7.2.12 -r1.7.2.13 *** mech.combat.c 30 Sep 2003 01:38:36 -0000 1.7.2.12 --- mech.combat.c 8 Aug 2004 23:48:16 -0000 1.7.2.13 *************** *** 480,488 **** "You do not have a default target set!"); - if (MechType(mech) != CLASS_BSUIT) { - ARCCHECK(mech, enemyX, enemyY, section, critical, - "Default target is not in your weapons arc!"); - } - if (MechTarget(mech) != -1) { tempMech = getMech(MechTarget(mech)); --- 480,483 ---- *************** *** 537,540 **** --- 532,541 ---- } } + + if (MechType(mech) != CLASS_BSUIT) { + ARCCHECK(mech, enemyX, enemyY, section, critical, + "Default target is not in your weapons arc!"); + } + break; case 2: *************** *** 543,547 **** targetID[1] = args[1][1]; target = FindTargetDBREFFromMapNumber(mech, targetID); ! DOCHECK0(target == -1, "That is not a valid target ID!"); tempMech = getMech(target); DOCHECK0(!tempMech, "Error in FireWeaponNumber routine!"); --- 544,548 ---- targetID[1] = args[1][1]; target = FindTargetDBREFFromMapNumber(mech, targetID); ! DOCHECK0(target == -1, "That target is not in your line of sight!"); tempMech = getMech(target); DOCHECK0(!tempMech, "Error in FireWeaponNumber routine!"); *************** *** 552,560 **** mapy = MechY(tempMech); - if (MechType(mech) != CLASS_BSUIT) { - ARCCHECK(mech, enemyX, enemyY, section, critical, - "That target is not in your weapons arc!"); - } - range = FindRange(MechFX(mech), MechFY(mech), MechFZ(mech), enemyX, --- 553,556 ---- *************** *** 564,567 **** --- 560,568 ---- range); DOCHECK0(!LOS, "That target is not in your line of sight!"); + + if (MechType(mech) != CLASS_BSUIT) { + ARCCHECK(mech, enemyX, enemyY, section, critical, + "That target is not in your weapons arc!"); + } break; case 3: Index: mech.combat.misc.c =================================================================== RCS file: /cvsroot/btech/btechmux/src/hcode/btech/mech.combat.misc.c,v retrieving revision 1.5.2.3 retrieving revision 1.5.2.4 diff -C2 -d -r1.5.2.3 -r1.5.2.4 *** mech.combat.misc.c 30 Sep 2003 01:38:36 -0000 1.5.2.3 --- mech.combat.misc.c 8 Aug 2004 23:48:16 -0000 1.5.2.4 *************** *** 148,152 **** return; ! for (i = 0; i < NUM_CRITICALS; i++) { cl = CritsInLoc(mech, i); for (j = 0; j < cl; j++) --- 148,152 ---- return; ! for (i = 0; i < NUM_SECTIONS; i++) { cl = CritsInLoc(mech, i); for (j = 0; j < cl; j++) Index: mech.h =================================================================== RCS file: /cvsroot/btech/btechmux/src/hcode/btech/mech.h,v retrieving revision 1.9.2.9 retrieving revision 1.9.2.10 diff -C2 -d -r1.9.2.9 -r1.9.2.10 *** mech.h 30 Sep 2003 01:38:36 -0000 1.9.2.9 --- mech.h 8 Aug 2004 23:48:16 -0000 1.9.2.10 *************** *** 1,3 **** --- 1,4 ---- + /* * $Id$ Index: mech.ice.c =================================================================== RCS file: /cvsroot/btech/btechmux/src/hcode/btech/mech.ice.c,v retrieving revision 1.2.2.4 retrieving revision 1.2.2.5 diff -C2 -d -r1.2.2.4 -r1.2.2.5 *** mech.ice.c 6 Dec 2002 14:28:42 -0000 1.2.2.4 --- mech.ice.c 8 Aug 2004 23:48:16 -0000 1.2.2.5 *************** *** 33,56 **** if (!(Elevation(map, x, y))) return; ! for (i = 0; i < map->first_free; i++) ! if ((j = map->mechsOnMap[i]) > 0) ! if ((t = getMech(j))) ! if (t != mech) { ! if (MechX(t) != x || MechY(t) != y) ! continue; ! MechTerrain(t) = WATER; ! if ((!isbridge && (MechZ(t) == 0) && ! (MechMove(t) != MOVE_HOVER)) || (isbridge && ! MechZ(t) == MechElev(t))) { ! MechLOSBroadcast(t, msg); ! MechFalls(t, MechElev(t) + isbridge, 0); ! if (MechType(t) == CLASS_VEH_GROUND) ! if (!Destroyed(t)) { ! mech_notify(t, MECHALL, ! "Water renders your vehicle inoperational."); ! Destroy(t); ! } ! } ! } } --- 33,59 ---- if (!(Elevation(map, x, y))) return; ! for (i = 0; i < map->first_free; i++) { ! j = map->mechsOnMap[i]; ! if (j < 0) ! continue; ! t = getMech(j); ! if (!t || t == mech) ! continue; ! if (MechX(t) != x || MechY(t) != y) ! continue; ! MechTerrain(t) = WATER; ! if ((!isbridge && (MechZ(t) == 0) && (MechMove(t) != MOVE_HOVER)) || ! (isbridge && MechZ(t) == MechElev(t))) { ! MechLOSBroadcast(t, msg); ! MechFalls(t, MechElev(t) + isbridge, 0); ! if (MechType(t) == CLASS_VEH_GROUND && !Destroyed(t)) { ! mech_notify(t, MECHALL, ! "Water renders your vehicle inoperable."); ! MechLOSBroadcast(t, ! "fizzles and pops as water renders it inoperable."); ! Destroy(t); ! } ! } ! } } *************** *** 82,85 **** --- 85,95 ---- MechFalls(mech, MechElev(mech), 0); } + if (MechElev(mech) > 0 && MechType(mech) == CLASS_VEH_GROUND && + !Destroyed(mech)) { + mech_notify(mech, MECHALL, "Water renders your vehicle inoperable."); + MechLOSBroadcast(mech, + "fizzles and pops as water renders it inoperable."); + Destroy(mech); + } } *************** *** 90,94 **** MarkForLOSUpdate(mech); ! mech_notify(mech, MECHALL, "You break thru the ice on your way up!"); MechLOSBroadcast(mech, "breaks through the ice!"); break_sub(map, mech, MechX(mech), MechY(mech), "goes swimming!"); --- 100,104 ---- MarkForLOSUpdate(mech); ! mech_notify(mech, MECHALL, "You break through the ice!"); MechLOSBroadcast(mech, "breaks through the ice!"); break_sub(map, mech, MechX(mech), MechY(mech), "goes swimming!"); Index: mech.maps.c =================================================================== RCS file: /cvsroot/btech/btechmux/src/hcode/btech/mech.maps.c,v retrieving revision 1.7.2.8 retrieving revision 1.7.2.9 diff -C2 -d -r1.7.2.8 -r1.7.2.9 *** mech.maps.c 10 Dec 2002 14:21:03 -0000 1.7.2.8 --- mech.maps.c 8 Aug 2004 23:48:16 -0000 1.7.2.9 *************** *** 31,34 **** --- 31,35 ---- #include "p.ds.bay.h" #include "p.bsuit.h" + #include "p.mech.utils.h" void mech_findcenter(dbref player, void *data, char *buffer) *************** *** 48,51 **** --- 49,92 ---- } + static int parse_tacargs(dbref player, MECH *mech, char ** args, int argc, + int maxrange, short * x, short * y) + { + int bearing; + float range, fx, fy; + MECH * tempMech; + MAP * map; + + switch (argc) { + case 2: + bearing = atoi(args[0]); + range = atof(args[1]); + DOCHECK0(!MechIsObservator(mech) && + abs((int) range) > maxrange, + "Those coordinates are out of sensor range!"); + FindXY(MechFX(mech), MechFY(mech), bearing, range, &fx, &fy); + RealCoordToMapCoord(x, y, fx, fy); + return 1; + case 1: + map = getMap(mech->mapindex); + tempMech = getMech(FindMechOnMap(map, args[0])); + DOCHECK0(!tempMech, "No such target."); + range = FlMechRange(mech_map, mech, tempMech); + DOCHECK0(!InLineOfSight(mech, tempMech, MechX(tempMech), + MechY(tempMech), range), "No such target."); + DOCHECK0(abs((int) range) > maxrange, + "Target is out of scanner range."); + *x = MechX(tempMech); + *y = MechY(tempMech); + return 1; + case 0: + *x = MechX(mech); + *y = MechY(mech); + return 1; + default: + notify(player, "Invalid number of parameters!"); + return 0; + } + } + const char *GetTerrainName_base(int t) { *************** *** 93,97 **** FIRE_IDX, ICE_IDX, WALL_IDX, SNOW_IDX, SMOKE_IDX, LWOOD_IDX, HWOOD_IDX, UNKNOWN_IDX, CLIFF_IDX, SELF_IDX, FRIEND_IDX, ENEMY_IDX, DS_IDX, ! NUM_COLOR_IDX }; --- 134,138 ---- FIRE_IDX, ICE_IDX, WALL_IDX, SNOW_IDX, SMOKE_IDX, LWOOD_IDX, HWOOD_IDX, UNKNOWN_IDX, CLIFF_IDX, SELF_IDX, FRIEND_IDX, ENEMY_IDX, DS_IDX, ! GOODLZ_IDX, BADLZ_IDX, NUM_COLOR_IDX }; *************** *** 99,104 **** /* internal rep has H instead of h and \0 instead of n */ ! #define DEFAULT_COLOR_STRING "BbWnYyRWWWXGgbRhYRn" ! #define DEFAULT_COLOR_SCHEME "BbW\0YyRWWWXGgbRHYR\0" static char custom_color_str[NUM_COLOR_IDX + 1] = DEFAULT_COLOR_SCHEME; --- 140,145 ---- /* internal rep has H instead of h and \0 instead of n */ ! #define DEFAULT_COLOR_STRING "BbWnYyRWWWXGgbRhYRnGR" ! #define DEFAULT_COLOR_SCHEME "BbW\0YyRWWWXGgbRHYR\0GR" static char custom_color_str[NUM_COLOR_IDX + 1] = DEFAULT_COLOR_SCHEME; *************** *** 109,114 **** int i; ! if (*str && strlen(str) == NUM_COLOR_IDX) { ! strncpy(custom_color_str, str, NUM_COLOR_IDX); for (i = 0; i < NUM_COLOR_IDX; i++) { switch (custom_color_str[i]) { --- 150,156 ---- int i; ! if (*str && strlen(str) <= NUM_COLOR_IDX) { ! strncpy(custom_color_str, DEFAULT_COLOR_STRING, NUM_COLOR_IDX); ! strncpy(custom_color_str, str, strlen(str)); for (i = 0; i < NUM_COLOR_IDX; i++) { switch (custom_color_str[i]) { *************** *** 163,168 **** char mybuff[NAVIGATE_LINES][MBUF_SIZE]; MAP *mech_map; ! char **maptext; ! int i, dolos; cch(MECH_USUAL); --- 205,211 ---- char mybuff[NAVIGATE_LINES][MBUF_SIZE]; MAP *mech_map; ! char **maptext, *args[3]; ! int i, dolos, argc; ! short x, y; cch(MECH_USUAL); *************** *** 173,189 **** mudconf.btech_mw_losmap); ! if (mech_map->map_width > 0 && mech_map->map_height > 0) { ! set_colorscheme(player); ! maptext = MakeMapText(player, mech, mech_map, MechX(mech), ! MechY(mech), 5, 5, 4, dolos); ! } else { ! static char dummy[] = ""; ! static char *dummy2[12] = ! { dummy, dummy, dummy, dummy, dummy, dummy, ! dummy, dummy, dummy, dummy, dummy, NULL ! }; ! maptext = dummy2; ! } sprintf(mybuff[0], --- 216,228 ---- mudconf.btech_mw_losmap); ! DOCHECK(mech_map->map_width <= 0 || mech_map->map_height <= 0, ! "Nothing to see on this map, move along."); ! argc = mech_parseattributes(buffer, args, 3); ! if (!parse_tacargs(player, mech, args, argc, MechTacRange(mech), &x, &y)) ! return; ! ! set_colorscheme(player); ! maptext = MakeMapText(player, mech, mech_map, x, y, 5, 5, 4, dolos); sprintf(mybuff[0], *************** *** 223,227 **** sprintf(mybuff[12], " 180"); ! navigate_sketch_mechs(mech, mech_map, MechX(mech), MechY(mech), mybuff); for (i = 0; i < NAVIGATE_LINES; i++) notify(player, mybuff[i]); --- 262,266 ---- sprintf(mybuff[12], " 180"); ! navigate_sketch_mechs(mech, mech_map, x, y, mybuff); for (i = 0; i < NAVIGATE_LINES; i++) notify(player, mybuff[i]); *************** *** 381,386 **** char c = GetTerrain(map, x, y); ! int e = GetElev(map, x, y); ! char newc = TerrainColorChar(c, e); if (!c || !docolor || c == ' ') { --- 420,424 ---- char c = GetTerrain(map, x, y); ! char newc; if (!c || !docolor || c == ' ') { *************** *** 388,392 **** buf[1] = '\0'; return buf; ! } return add_color(newc, prevc, c); --- 426,449 ---- buf[1] = '\0'; return buf; ! } else ! newc = TerrainColorChar(c, GetElev(map, x, y)); ! ! return add_color(newc, prevc, c); ! } ! ! static char *LRSElevation(MAP * map, int x, int y, int docolor, char *prevc) ! { ! static char buf[2]; /* Won't be filled with more than 1 character */ ! ! int e = GetElev(map, x, y); ! char c = (e || docolor) ? '0' + e : ' '; ! char newc; ! ! if (!docolor) { ! buf[0] = c; ! buf[1] = '\0'; ! return buf; ! } else ! newc = TerrainColorChar(GetTerrain(map, x, y), e); return add_color(newc, prevc, c); *************** *** 398,401 **** --- 455,459 ---- #define LRS_LOSMODE 8 #define LRS_COLORMODE 16 + #define LRS_ELEVCOLORMODE 32 static char *get_lrshexstr(MECH * mech, MAP *map, int x, int y, *************** *** 404,409 **** { int losflag = MAPLOSHEX_SEE | MAPLOSHEX_SEEN; - char c; - static char buf[5]; if (mode & LRS_MECHMODE) { --- 462,465 ---- *************** *** 429,443 **** return add_color(TerrainColorChar(UNKNOWN_TERRAIN, 0), prevc, '?'); ! if (mode & LRS_ELEVMODE) { ! c = GetElev(map, x, y) + '0'; ! if (c == '0') ! c = ' '; ! if (*prevc) { ! sprintf(buf, "%%cn%c", c); ! *prevc = '\0'; ! } else ! sprintf(buf, "%c", c); ! return buf; ! } if (mode & LRS_TERRAINMODE) return LRSTerrain(map, x, y, mode & LRS_COLORMODE, prevc); --- 485,490 ---- return add_color(TerrainColorChar(UNKNOWN_TERRAIN, 0), prevc, '?'); ! if (mode & LRS_ELEVMODE) ! return LRSElevation(map, x, y, mode & LRS_ELEVCOLORMODE, prevc); if (mode & LRS_TERRAINMODE) return LRSTerrain(map, x, y, mode & LRS_COLORMODE, prevc); *************** *** 570,574 **** } ! if (mode & LRS_COLORMODE) { if (prevct) { strcat(topbuff, "%cn"); --- 617,621 ---- } ! if (mode & (LRS_COLORMODE|LRS_ELEVCOLORMODE)) { if (prevct) { strcat(topbuff, "%cn"); *************** *** 589,598 **** { MECH *mech = (MECH *) data; - MECH *tempMech; MAP *map; ! int argc, bearing, mode = 0; short x, y; char *args[5], *str; - float fx, fy, range; int displayHeight = LRS_DISPLAY_HEIGHT; --- 636,643 ---- { MECH *mech = (MECH *) data; MAP *map; ! int argc, mode = 0; short x, y; char *args[5], *str; int displayHeight = LRS_DISPLAY_HEIGHT; *************** *** 606,639 **** argc = mech_parseattributes(buffer, args, 4); DOCHECK(!MechLRSRange(mech), "Your system seems to be inoperational."); ! switch (argc) { ! case 3: ! bearing = atoi(args[1]); ! range = atof(args[2]); ! DOCHECK(!MechIsObservator(mech) && ! abs((int) range) > MechLRSRange(mech), ! "Those coordinates are out of sensor range!"); ! FindXY(MechFX(mech), MechFY(mech), bearing, range, &fx, &fy); ! RealCoordToMapCoord(&x, &y, fx, fy); ! break; ! case 2: ! tempMech = getMech(FindTargetDBREFFromMapNumber(mech, args[1])); ! DOCHECK(!tempMech, "No such target."); ! range = FlMechRange(map, mech, tempMech); ! DOCHECK(!InLineOfSight(mech, tempMech, MechX(tempMech), ! MechY(tempMech), range), "No such target."); ! DOCHECK(abs((int) range) > MechLRSRange(mech), ! "Target is out of scanner range."); ! x = MechX(tempMech); ! y = MechY(tempMech); ! break; ! case 1: ! x = MechX(mech); ! y = MechY(mech); ! break; ! default: ! notify(player, "Invalid number of parameters!"); return; - } - switch(args[0][0]) { case 'M': --- 651,657 ---- argc = mech_parseattributes(buffer, args, 4); DOCHECK(!MechLRSRange(mech), "Your system seems to be inoperational."); ! if (!parse_tacargs(player, mech, &args[1], argc - 1, ! MechLRSRange(mech), &x, &y)) return; switch(args[0][0]) { case 'M': *************** *** 645,648 **** --- 663,670 ---- mode |= LRS_ELEVMODE; break; + case 'C': + case 'c': + mode |= LRS_ELEVMODE | LRS_ELEVCOLORMODE; + break; case 'T': case 't': *************** *** 1037,1040 **** --- 1059,1087 ---- } } + static void sketch_tac_dslz(char *buf, MAP * map, MECH * mech, int sx, + int sy, int wx, int wy, int dispcols, + int top_offset, int left_offset, int cliff_size, + int docolour) + { + char *pos = buf + top_offset * dispcols + left_offset; + int y, x; + int oddcol1 = is_oddcol(sx); + + wx = MIN(wx, map->map_width - sx); + wy = MIN(wy, map->map_height - sy); + for (y = MAX(0, -sy); y < wy; y++) { + int ty = sy + y; + + for (x = MAX(0, -sx); x < wx; x++) { + int tx = sx + x; + char *base = pos + tac_hex_offset(x, y, dispcols, oddcol1); + + if (ImproperLZ(mech, tx, ty)) + base[dispcols] = docolour ? '\241' : 'X'; + else + base[dispcols] = docolour ? '\240' : 'O'; + } + } + } /* *************** *** 1098,1101 **** --- 1145,1156 ---- break; + case (unsigned char) '\241': /* Colour Hack: improper LZ */ + c = 'X'; + new_colour = custom_color_str[BADLZ_IDX]; + break; + case (unsigned char) '\240': /* Colour Hack: proper LZ */ + c = 'O'; + new_colour = custom_color_str[GOODLZ_IDX]; + break; case '?': c = '?'; *************** *** 1206,1209 **** --- 1261,1265 ---- * 8 = show mech cliffs * 16 = show tank cliffs + * 32 = show DS LZ's * * If navigate mode, wx and wy should be equal and odd. Navigate maps *************** *** 1347,1350 **** --- 1403,1413 ---- sketch_tac_cliffs(sketch_buf, map, sx, sy, wx, wy, dispcols, top_offset, left_offset, 2); + } else if (labels & 32) { + if (mech != NULL) { + sketch_tac_ownmech(sketch_buf, map, mech, sx, sy, wx, wy, + dispcols, top_offset, left_offset); + } + sketch_tac_dslz(sketch_buf, map, mech, sx, sy, wx, wy, dispcols, + top_offset, left_offset, 2, docolour); } else if (mech != NULL) { sketch_tac_mechs(sketch_buf, map, mech, sx, sy, wx, wy, dispcols, *************** *** 1416,1427 **** short x, y; int mapx, mapy; - MECH *tempMech; char *args_vec[4]; char **args = args_vec; MAP *mech_map; - float fx, fy; - float range; - int bearing; - int target; int displayHeight; char *str; --- 1479,1485 ---- *************** *** 1455,1458 **** --- 1513,1520 ---- break; + case 'b': + flags |= 32; + break; + default: notify(player, "Invalid tactical map flag."); *************** *** 1463,1498 **** } ! DOCHECK(dohexlos && (flags & (8|16)), "You can't see cliffs here!"); ! switch (argc) { ! case 2: ! bearing = atoi(args[0]); ! range = atof(args[1]); ! DOCHECK(!MechIsObservator(mech) && ! abs((int) range) > MechTacRange(mech), ! "Those coordinates are out of sensor range!"); ! FindXY(MechFX(mech), MechFY(mech), bearing, range, &fx, &fy); ! RealCoordToMapCoord(&x, &y, fx, fy); ! break; ! case 1: ! target = FindTargetDBREFFromMapNumber(mech, args[0]); ! tempMech = getMech(target); ! DOCHECK(!tempMech, "No such target."); ! range = FlMechRange(mech_map, mech, tempMech); ! DOCHECK(!InLineOfSight(mech, tempMech, MechX(tempMech), ! MechY(tempMech), range), "No such target."); ! DOCHECK(abs((int) range) > MechTacRange(mech), ! "Target is out of scanner range."); ! x = MechX(tempMech); ! y = MechY(tempMech); ! break; ! case 0: ! x = MechX(mech); ! y = MechY(mech); ! break; ! default: ! notify(player, "Invalid number of parameters!"); return; ! } str = silly_atr_get(player, A_TACHEIGHT); if (!*str) --- 1525,1533 ---- } ! DOCHECK(dohexlos && (flags & (8|16|32)), "You can't see that much here!"); ! if (!parse_tacargs(player, mech, args, argc, MechTacRange(mech), &x, &y)) return; ! str = silly_atr_get(player, A_TACHEIGHT); if (!*str) Index: mech.move.c =================================================================== RCS file: /cvsroot/btech/btechmux/src/hcode/btech/mech.move.c,v retrieving revision 1.5.2.16 retrieving revision 1.5.2.17 diff -C2 -d -r1.5.2.16 -r1.5.2.17 *** mech.move.c 30 Sep 2003 01:38:36 -0000 1.5.2.16 --- mech.move.c 8 Aug 2004 23:48:16 -0000 1.5.2.17 *************** *** 488,491 **** --- 488,494 ---- MechLOSBroadcast(mech, "attempts to stand up."); + if (MechRTerrain(mech) == ICE && MechZ(mech) == -1) + break_thru_ice(mech); + if (tNeedsPSkill) { if (!MadePilotSkillRoll(mech, 0)) { *************** *** 860,864 **** int limbs = 4; int aLimbs[] = { RARM, LARM, LLEG, RLEG }; ! int i, j; int tempLoc; char locName[50]; --- 863,867 ---- int limbs = 4; int aLimbs[] = { RARM, LARM, LLEG, RLEG }; ! int i; int tempLoc; char locName[50]; *************** *** 927,931 **** continue; ! if (Jumping(target)) continue; --- 930,934 ---- continue; ! if (Jumping(target) || OODing(target)) continue; *************** *** 1590,1594 **** if (MechType(mech) != CLASS_MECH) continue; ! if (Jumping(mech)) continue; if (friendly < 0 || ((MechTeam(mech) == team) == friendly)) --- 1593,1597 ---- if (MechType(mech) != CLASS_MECH) continue; ! if (Jumping(mech) || OODing(mech)) continue; if (friendly < 0 || ((MechTeam(mech) == team) == friendly)) *************** *** 1657,1661 **** if (MechType(mech) != CLASS_MECH) continue; ! if (Jumping(mech)) continue; if (friendly < 0 || ((MechTeam(mech) == team) == friendly)) --- 1660,1664 ---- if (MechType(mech) != CLASS_MECH) continue; ! if (Jumping(mech) || OODing(mech)) continue; if (friendly < 0 || ((MechTeam(mech) == team) == friendly)) Index: mech.notify.c =================================================================== RCS file: /cvsroot/btech/btechmux/src/hcode/btech/mech.notify.c,v retrieving revision 1.3.2.12 retrieving revision 1.3.2.13 diff -C2 -d -r1.3.2.12 -r1.3.2.13 *** mech.notify.c 30 Sep 2003 01:38:36 -0000 1.3.2.12 --- mech.notify.c 8 Aug 2004 23:48:16 -0000 1.3.2.13 *************** *** 512,516 **** /* 1234567890123456 */ ! const char tempc[] = "xrgybmcwXRGYBMCW"; static char *ccode(MECH * m, int i) --- 512,516 ---- /* 1234567890123456 */ ! const char radio_colorstr[] = "xrgybmcwXRGYBMCW"; static char *ccode(MECH * m, int i) *************** *** 524,531 **** }; if (t < 9) { ! sprintf(buf, "%%c%c", tempc[t - 1]); return buf; } ! sprintf(buf, "%%ch%%c%c", ToLower(tempc[t - 1])); return buf; } --- 524,531 ---- }; if (t < 9) { ! sprintf(buf, "%%c%c", radio_colorstr[t - 1]); return buf; } ! sprintf(buf, "%%ch%%c%c", ToLower(radio_colorstr[t - 1])); return buf; } *************** *** 585,594 **** break; default: ! for (i = 0; tempc[i]; i++) ! if (*buffer == tempc[i]) { nm = nm % FREQ_REST + FREQ_REST * (i + 1); break; } ! if (!tempc[i]) buffer = NULL; break; --- 585,594 ---- break; default: ! for (i = 0; radio_colorstr[i]; i++) ! if (*buffer == radio_colorstr[i]) { ... [truncated message content] |