hcodedb::MECHObject Class Reference

Inheritance diagram for hcodedb::MECHObject:

Inheritance graph
[legend]
Collaboration diagram for hcodedb::MECHObject:

Collaboration graph
[legend]

Public Member Functions

def __init__
def parsedata

Data Fields

 key
 type
 format
 data
 tic
 ud
 pd
 rd

Detailed Description

Definition at line 273 of file hcodedb.py.


Member Function Documentation

def hcodedb::MECHObject::__init__ (   self,
  key,
  type,
  size,
  data 
)

Reimplemented from hcodedb::HCodeObject.

Definition at line 274 of file hcodedb.py.

00274                                              :
00275         self.key = key
00276         self.type = type
00277 
00278         header_format = "iii2sb" + 4*3*"L" + 16*"16s" + "16i" + "16i"
00279         critslot_format = "HbHb0H"
00280         section_format = "BBBBBBbbb" + critslot_format*12
00281         ud_format = ("31s 15s bbiHbbb" + section_format*8 +
00282                     "bbiifbbbii8i0H" )
00283         pd_format = "ibHbbHibHHHHHfffii4i3i0H"
00284         rd_format = ("ffff HbHHfHHfffHHHHH bbHb iiiiii " "cffffiii"
00285                     "ci2bbiHHiiiiii" 
00286                     "iiiiiibibiiHHiifiiibbHiiii7i0H")
00287 
00288         self.format = ("@" + header_format + ud_format +
00289                        pd_format + rd_format)
00290 
00291         self.data = data
00292         self.parsedata(data, size)
00293 
    def parsedata(self, data, size):        

def hcodedb::MECHObject::parsedata (   self,
  data,
  size 
)

Definition at line 294 of file hcodedb.py.

00294                                    :        
00295 
00296         class _Dummy:
00297             pass
00298 
00299         def _cull(s):
00300             return s[:string.find(s, "\000")]
00301 
00302         pdata = struct.unpack(self.format, data)
00303         (self.mynum, self.mapnumber, self.mapindex, self.ID,
00304          self.brief), pdata = pdata[:5], pdata[5:]
00305         self.tic = []
00306         for i in range(4):
00307             self.tic.append(pdata[:3])
00308             pdata = pdata[3:]
00309 
00310         self.chantitles, pdata = list(pdata[:16]), pdata[16:]
00311         for i in range(16):
00312             self.chantitles[i] = _cull(self.chantitles[i])
00313         self.freqs, pdata = pdata[:16], pdata[16:]
00314         self.freqmodes, pdata = pdata[:16], pdata[16:]
00315 
00316         ud = _Dummy()
00317         (ud.mech_name, ud.mech_type, type, move, tons, radio_range,
00318          tac_range, lrs_range, scan_range), pdata = pdata[:9], pdata[9:]
00319         ud.mech_name = _cull(ud.mech_name)
00320         ud.mech_type = _cull(ud.mech_type)
00321         ud.sections = []
00322         for i in range(8):
00323             section = _Dummy()
00324             (section.armor, section.internal, section.rear,
00325              section.armor_orig, section.internal_orig,
00326              section.rear_orig, section.basetohit, section.config,
00327              section.recycle), pdata = pdata[:9], pdata[9:]
00328             section.crits = []
00329             for i in range(12):
00330                 crit = _Dummy()
00331                 (crit.type, crit.data, crit.mode, crit.brand
00332                  ), pdata = pdata[:4], pdata[4:]
00333                 section.crits.append(crit)
00334             ud.sections.append(section)
00335         (ud.si, ud.si_orig, ud.fuel, ud.fuel_orig, ud.maxspeed,
00336          ud.computer, ud.radio, ud.radioinfo, ud.mechbv, ud.cargospace,
00337          ), pdata = pdata[:10], pdata[10:]
00338         ud.unused, pdata = pdata[:8], pdata[8:]
00339         self.ud = ud
00340 
00341         pd = _Dummy()
00342         (pd.pilot, pd.pilotstatus, pd.hexes_walked, pd.terrain,
00343          pd.elev, pd.facing, pd.master_c3_node, pd.team, pd.x,
00344          pd.y, pd.z, pd.last_x, pd.last_y, pd.fx, pd.fy, pd.fz,
00345          pd.unusable_arcs, pd.stall), pdata = pdata[:18], pdata[18:]
00346         pd.bays, pdata = pdata[:4], pdata[4:]
00347         pd.turrets, pdata = pdata[:4], pdata[4:]
00348         self.pd = pd
00349 
00350         rd = _Dummy()
00351         (rd.startfx, rd.startfy, rd.startfz, rd.endfz, rd.jumplength,
00352          rd.jumptop, rd.goingx, rd.goingy, rd.verticalspeed,
00353          rd.desiredfacing, rd.angle, rd.speed, rd.desired_speed,
00354          rd.jumpspeed, rd.jumpheading, rd.targx, rd.targy, rd.targz,
00355          rd.turretfacing, rd.aim, rd.pilotskillbase, rd.turndamage,
00356          rd.basetohit, rd.chgtarget, rd.dfatarget, rd.target,
00357          rd.swarming, rd.carrying, rd.spotter, rd.engineheat, rd.heat,
00358          rd.weapheat, rd.plus_heat, rd.minus_heat, rd.critstatus,
00359          rd.status, rd.specials, rd.masc_value, rd.last_weapon_recycle,
00360          rd.sensor, rd.fire_adjustment, rd.cargo_weight, rd.lateral,
00361          rd.num_seen, rd.lastrndu, rd.rnd, rd.last_ds_msg, rd.boom_start,
00362          rd.maxfuel, rd.lastused, rd.cocoon, rd.commconv,
00363          rd.commconv_last, rd.onumsinks, rd.disabled_hs,
00364          rd.autopilot_num, rd.aim_type, rd.heatboom_last, rd.vis_mod,
00365          rd.sspin, rd.can_see, rd.lx, rd.ly, rd.row, rd.rcw, rd.rspd,
00366          rd.erat, rd.per, rd.wxf, rd.chargetimer, rd.chargedist,
00367          rd.mech_prefs, rd.last_startup, rd.specialstatus,
00368          rd.tankcritstatus, rd.specials2), pdata = pdata[:76],pdata[76:]
00369 
00370         rd.unused, pdata = pdata[:7], pdata[7:]
00371         self.rd = rd
00372 
00373         if pdata:
00374             sys.stderr.write("pdata left! %s\n"%(pdata,))
00375             sys.stderr.write("length of data: %s\n"%size)
00376 
00377 
00378 # MAP struct is:
00379 # dbref mynum (4 bytes)
00380 # unsigned char * map[] (4 bytes)
00381 # char mapname[31] (31 bytes)
00382 # short map_width (2 bytes)
00383 # short map_height (2 bytes)
00384 # char temp ( 1 byte)
00385 # unsigned char grav (1 byte)
00386 # short cloudbase (2 bytes)
00387 # char unused_char (1 byte)
00388 # char mapvis (1 byte)
00389 # short maxvis (2 bytes)
00390 # char maplight (1 byte)
00391 # short winddir (2 bytes)
00392 # short windspeed (2 bytes)
00393 # unsigned char flags (1 byte)
00394 # struct mapobj * mapobj (4 bytes)
00395 # short cf (2 bytes)
00396 # short cfmax (2 bytes)
00397 # dbref onmap (4 bytes)
00398 # char buildflag (1 byte)
00399 # unsigned char first_free (1 byte)
00400 # dbref * mechsOnMap (4 bytes)
00401 # unsigned short * LOSInfo[] (4 bytes)
00402 # char * mechflags[] (4 bytes)
00403 # short moves (1 byte)
00404 # short movemod (1 byte)
00405 #
00406 # Resulting in:
00407 # @ii31sHHbBHbbHbHHbiHHibBiiiHH
00408 


Field Documentation

hcodedb::MECHObject::data

Reimplemented from hcodedb::HCodeObject.

Definition at line 291 of file hcodedb.py.

hcodedb::MECHObject::format

Definition at line 288 of file hcodedb.py.

hcodedb::MECHObject::key

Reimplemented from hcodedb::HCodeObject.

Definition at line 275 of file hcodedb.py.

hcodedb::MECHObject::pd

Definition at line 348 of file hcodedb.py.

hcodedb::MECHObject::rd

Definition at line 371 of file hcodedb.py.

hcodedb::MECHObject::tic

Definition at line 305 of file hcodedb.py.

hcodedb::MECHObject::type

Reimplemented from hcodedb::HCodeObject.

Definition at line 276 of file hcodedb.py.

hcodedb::MECHObject::ud

Definition at line 339 of file hcodedb.py.


The documentation for this class was generated from the following file:
Generated on Mon May 28 04:25:49 2007 for BattletechMUX by  doxygen 1.4.7