From: Ketmar Dark Date: Fri, 1 Sep 2017 04:21:11 +0000 (+0300) Subject: made some class' properties published for Holmes X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=a4f25c41dfd783a925aa2dab4b9b84753d5c3f18;p=d2df-sdl.git made some class' properties published for Holmes --- diff --git a/src/game/g_holmes.pas b/src/game/g_holmes.pas index 566cd19..54dc90b 100644 --- a/src/game/g_holmes.pas +++ b/src/game/g_holmes.pas @@ -101,6 +101,7 @@ var implementation uses + {rttiobj,} typinfo, SysUtils, Classes, GL, SDL2, MAPDEF, g_main, g_options, utils, hashtable, xparser; @@ -247,7 +248,86 @@ end; // ////////////////////////////////////////////////////////////////////////// // -//FIXME +function typeKind2Str (t: TTypeKind): AnsiString; +begin + case t of + tkUnknown: result := 'Unknown'; + tkInteger: result := 'Integer'; + tkChar: result := 'Char'; + tkEnumeration: result := 'Enumeration'; + tkFloat: result := 'Float'; + tkSet: result := 'Set'; + tkMethod: result := 'Method'; + tkSString: result := 'SString'; + tkLString: result := 'LString'; + tkAString: result := 'AString'; + tkWString: result := 'WString'; + tkVariant: result := 'Variant'; + tkArray: result := 'Array'; + tkRecord: result := 'Record'; + tkInterface: result := 'Interface'; + tkClass: result := 'Class'; + tkObject: result := 'Object'; + tkWChar: result := 'WChar'; + tkBool: result := 'Bool'; + tkInt64: result := 'Int64'; + tkQWord: result := 'QWord'; + tkDynArray: result := 'DynArray'; + tkInterfaceRaw: result := 'InterfaceRaw'; + tkProcVar: result := 'ProcVar'; + tkUString: result := 'UString'; + tkUChar: result := 'UChar'; + tkHelper: result := 'Helper'; + tkFile: result := 'File'; + tkClassRef: result := 'ClassRef'; + tkPointer: result := 'Pointer'; + else result := ''; + end; +end; + + +procedure dumpPublishedProperties (obj: TObject); +var + pt: PTypeData; + pi: PTypeInfo; + i, j: Integer; + pp: PPropList; +begin + if (obj = nil) then exit; + e_LogWritefln('Object of type ''%s'':', [obj.ClassName]); + pi := obj.ClassInfo; + pt := GetTypeData(pi); + e_LogWritefln('property count: %s', [pt.PropCount]); + GetMem(pp, pt^.PropCount*sizeof(Pointer)); + try + j := GetPropList(pi, [tkInteger, tkBool, tkSString, tkLString, tkAString, tkSet, tkEnumeration], pp); + //e_LogWritefln('ordinal property count: %s', [j]); + for i := 0 to j-1 do + begin + if (typinfo.PropType(obj, pp^[i].name) in [tkSString, tkLString, tkAString]) then + begin + e_LogWritefln(' #%s: <%s>; type: %s; value: <%s>', [i+1, pp^[i].name, typeKind2Str(typinfo.PropType(obj, pp^[i].name)), GetStrProp(obj, pp^[i])]); + end + else if (typinfo.PropType(obj, pp^[i].name) = tkSet) then + begin + e_LogWritefln(' #%s: <%s>; type: %s; value: %s', [i+1, pp^[i].name, typeKind2Str(typinfo.PropType(obj, pp^[i].name)), GetSetProp(obj, pp^[i], true)]); + end + else if (typinfo.PropType(obj, pp^[i].name) = tkEnumeration) then + begin + e_LogWritefln(' #%s: <%s>; type: %s; value: <%s>', [i+1, pp^[i].name, typeKind2Str(typinfo.PropType(obj, pp^[i].name)), GetEnumProp(obj, pp^[i])]); + end + else + begin + e_LogWritefln(' #%s: <%s>; type: %s; value: %s', [i+1, pp^[i].name, typeKind2Str(typinfo.PropType(obj, pp^[i].name)), GetOrdProp(obj, pp^[i])]); + end; + end; + finally + FreeMem(pp); + end; +end; + + +//FIXME: autogenerate function trigType2Str (ttype: Integer): AnsiString; begin result := ''; @@ -1223,9 +1303,25 @@ procedure cbAtcurSelectMonster (); result := true; // stop e_WriteLog(Format('monster #%d (UID:%u) (proxyid:%d)', [mon.arrIdx, mon.UID, mon.proxyId]), MSG_NOTIFY); monMarkedUID := mon.UID; + dumpPublishedProperties(mon); end; +var + plr: TPlayer; + x, y, w, h: Integer; begin monMarkedUID := -1; + if (Length(gPlayers) > 0) then + begin + plr := gPlayers[0]; + if (plr <> nil) then + begin + plr.getMapBox(x, y, w, h); + if (pmsCurMapX >= x) and (pmsCurMapY >= y) and (pmsCurMapX < x+w) and (pmsCurMapY < y+h) then + begin + dumpPublishedProperties(plr); + end; + end; + end; //e_WriteLog('===========================', MSG_NOTIFY); monsGrid.forEachAtPoint(pmsCurMapX, pmsCurMapY, monsAtDump); //e_WriteLog('---------------------------', MSG_NOTIFY); @@ -1247,7 +1343,8 @@ procedure cbAtcurDumpWalls (); function wallToggle (pan: TPanel; tag: Integer): Boolean; begin result := false; // don't stop - e_WriteLog(Format('wall #%d(%d); enabled=%d (%d); (%d,%d)-(%d,%d)', [pan.arrIdx, pan.proxyId, Integer(pan.Enabled), Integer(mapGrid.proxyEnabled[pan.proxyId]), pan.X, pan.Y, pan.Width, pan.Height]), MSG_NOTIFY); + e_LogWritefln('wall #%d(%d); enabled=%d (%d); (%d,%d)-(%d,%d)', [pan.arrIdx, pan.proxyId, Integer(pan.Enabled), Integer(mapGrid.proxyEnabled[pan.proxyId]), pan.X, pan.Y, pan.Width, pan.Height]); + dumpPublishedProperties(pan); end; var hasTrigs: Boolean = false; diff --git a/src/game/g_map.pas b/src/game/g_map.pas index a4b2064..0df83bb 100644 --- a/src/game/g_map.pas +++ b/src/game/g_map.pas @@ -85,8 +85,6 @@ function g_Map_HaveFlagPoints(): Boolean; procedure g_Map_ResetFlag(Flag: Byte); procedure g_Map_DrawFlags(); -function g_Map_PanelForPID(PanelID: Integer; var PanelArrayID: Integer): PPanel; - procedure g_Map_SaveState(Var Mem: TBinMemoryWriter); procedure g_Map_LoadState(Var Mem: TBinMemoryReader); @@ -3231,17 +3229,6 @@ begin ///// ///// end; -function g_Map_PanelForPID(PanelID: Integer; var PanelArrayID: Integer): PPanel; -var - Arr: TPanelArray; -begin - Result := nil; - if (PanelID < 0) or (PanelID > High(PanelByID)) then Exit; - Arr := PanelByID[PanelID].PWhere^; - PanelArrayID := PanelByID[PanelID].PArrID; - Result := Addr(Arr[PanelByID[PanelID].PArrID]); -end; - // trace liquid, stepping by `dx` and `dy` // return last seen liquid coords, and `false` if we're started outside of the liquid diff --git a/src/game/g_monsters.pas b/src/game/g_monsters.pas index 79e3be3..006d3c8 100644 --- a/src/game/g_monsters.pas +++ b/src/game/g_monsters.pas @@ -14,6 +14,7 @@ * along with this program. If not, see . *) {$INCLUDE ../shared/a_modes.inc} +{$M+} {.$DEFINE D2F_DEBUG_MONS_MOVE} unit g_monsters; @@ -136,6 +137,13 @@ type procedure getMapBox (out x, y, w, h: Integer); inline; + public + property Obj: TObj read FObj; + + property proxyId: Integer read mProxyId; + property arrIdx: Integer read mArrIdx; + + published property MonsterType: Byte read FMonsterType; property MonsterHealth: Integer read FHealth write FHealth; property MonsterAmmo: Integer read FAmmo write FAmmo; @@ -148,7 +156,6 @@ type property MonsterPain: Integer read FPain write FPain; property MonsterAnim: Byte read FCurAnim write FCurAnim; - property Obj: TObj read FObj; property UID: Word read FUID write FUID; property SpawnTrigger: Integer read FSpawnTrigger write FSpawnTrigger; @@ -161,9 +168,6 @@ type property GameDirection: TDirection read FDirection write FDirection; property StartID: Integer read FStartID; - - property proxyId: Integer read mProxyId; - property arrIdx: Integer read mArrIdx; end; diff --git a/src/game/g_panel.pas b/src/game/g_panel.pas index 5eec8e7..7f3e35f 100644 --- a/src/game/g_panel.pas +++ b/src/game/g_panel.pas @@ -14,6 +14,7 @@ * along with this program. If not, see . *) {$INCLUDE ../shared/a_modes.inc} +{$M+} unit g_panel; interface @@ -50,15 +51,15 @@ type FCurTexture: Integer; // Íîìåð òåêóùåé òåêñòóðû FCurFrame: Integer; FCurFrameCount: Byte; - X, Y: Integer; - Width, Height: Word; - PanelType: Word; - SaveIt: Boolean; // Ñîõðàíÿòü ïðè SaveState? - Enabled: Boolean; - Door: Boolean; - Moved: Boolean; - LiftType: Byte; - LastAnimLoop: Byte; + FX, FY: Integer; + FWidth, FHeight: Word; + FPanelType: Word; + FSaveIt: Boolean; // Ñîõðàíÿòü ïðè SaveState? + FEnabled: Boolean; + FDoor: Boolean; + FMoved: Boolean; + FLiftType: Byte; + FLastAnimLoop: Byte; arrIdx: Integer; // index in one of internal arrays; sorry tag: Integer; // used in coldets and such; sorry proxyId: Integer; // proxy id in map grid (DO NOT USE!) @@ -81,14 +82,27 @@ type procedure SaveState(var Mem: TBinMemoryWriter); procedure LoadState(var Mem: TBinMemoryReader); - property x0: Integer read X; - property y0: Integer read Y; + public + property visvalid: Boolean read getvisvalid; // panel is "visvalid" when it's width and height are positive + + published + property x0: Integer read FX; + property y0: Integer read FY; property x1: Integer read getx1; // inclusive! property y1: Integer read gety1; // inclusive! - property visvalid: Boolean read getvisvalid; // panel is "visvalid" when it's width and height are positive + property x: Integer read FX write FX; + property y: Integer read FY write FY; + property width: Word read FWidth write FWidth; + property height: Word read FHeight write FHeight; + property panelType: Word read FPanelType write FPanelType; + property saveIt: Boolean read FSaveIt write FSaveIt; // Ñîõðàíÿòü ïðè SaveState? + property enabled: Boolean read FEnabled write FEnabled; // Ñîõðàíÿòü ïðè SaveState? + property door: Boolean read FDoor write FDoor; // Ñîõðàíÿòü ïðè SaveState? + property moved: Boolean read FMoved write FMoved; // Ñîõðàíÿòü ïðè SaveState? + property liftType: Byte read FLiftType write FLiftType; // Ñîõðàíÿòü ïðè SaveState? + property lastAnimLoop: Byte read FLastAnimLoop write FLastAnimLoop; // Ñîõðàíÿòü ïðè SaveState? end; - PPanel = ^TPanel; TPanelArray = Array of TPanel; implementation @@ -530,14 +544,14 @@ begin sig := PANEL_SIGNATURE; // 'PANL' Mem.WriteDWORD(sig); // Îòêðûòà/çàêðûòà, åñëè äâåðü: - Mem.WriteBoolean(Enabled); + Mem.WriteBoolean(FEnabled); // Íàïðàâëåíèå ëèôòà, åñëè ëèôò: - Mem.WriteByte(LiftType); + Mem.WriteByte(FLiftType); // Íîìåð òåêóùåé òåêñòóðû: Mem.WriteInt(FCurTexture); // Êîîðäû - Mem.WriteInt(X); - Mem.WriteInt(Y); + Mem.WriteInt(FX); + Mem.WriteInt(FY); // Àíèìèðîâàííàÿ ëè òåêóùàÿ òåêñòóðà: if (FCurTexture >= 0) and (FTextureIDs[FCurTexture].Anim) then begin @@ -568,14 +582,14 @@ begin raise EBinSizeError.Create('TPanel.LoadState: Wrong Panel Signature'); end; // Îòêðûòà/çàêðûòà, åñëè äâåðü: - Mem.ReadBoolean(Enabled); + Mem.ReadBoolean(FEnabled); // Íàïðàâëåíèå ëèôòà, åñëè ëèôò: - Mem.ReadByte(LiftType); + Mem.ReadByte(FLiftType); // Íîìåð òåêóùåé òåêñòóðû: Mem.ReadInt(FCurTexture); // Êîîðäû - Mem.ReadInt(X); - Mem.ReadInt(Y); + Mem.ReadInt(FX); + Mem.ReadInt(FY); // Àíèìèðîâàííàÿ ëè òåêóùàÿ òåêñòóðà: Mem.ReadBoolean(anim); // Åñëè äà - çàãðóæàåì àíèìàöèþ: diff --git a/src/game/g_player.pas b/src/game/g_player.pas index 2d53dc5..04719fc 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -14,6 +14,7 @@ * along with this program. If not, see . *) {$INCLUDE ../shared/a_modes.inc} +{$M+} unit g_player; interface @@ -321,6 +322,11 @@ type procedure getMapBox (out x, y, w, h: Integer); inline; + public + property Vel: TPoint2i read FObj.Vel; + property Obj: TObj read FObj; + + published property Name: String read FName write FName; property Model: TPlayerModel read FModel; property Health: Integer read FHealth write FHealth; @@ -347,8 +353,6 @@ type property GameVelY: Integer read FObj.Vel.Y write FObj.Vel.Y; property GameAccelX: Integer read FObj.Accel.X write FObj.Accel.X; property GameAccelY: Integer read FObj.Accel.Y write FObj.Accel.Y; - property Vel: TPoint2i read FObj.Vel; - property Obj: TObj read FObj; property IncCam: Integer read FIncCam write FIncCam; property UID: Word read FUID write FUID; property JustTeleported: Boolean read FJustTeleported write FJustTeleported; diff --git a/src/game/g_playermodel.pas b/src/game/g_playermodel.pas index 72f5fb2..9e42436 100644 --- a/src/game/g_playermodel.pas +++ b/src/game/g_playermodel.pas @@ -14,6 +14,7 @@ * along with this program. If not, see . *) {$INCLUDE ../shared/a_modes.inc} +{$M+} unit g_playermodel; interface @@ -114,11 +115,14 @@ type procedure Update(); procedure Draw(X, Y: Integer; Alpha: Byte = 0); + published property Fire: Boolean read FFire; property Direction: TDirection read FDirection write FDirection; property Animation: Byte read FCurrentAnimation; property Weapon: Byte read FCurrentWeapon; property Name: String read FName; + + public property Color: TRGB read FColor write FColor; end; diff --git a/src/shared/utils.pas b/src/shared/utils.pas index c01287f..f61035e 100644 --- a/src/shared/utils.pas +++ b/src/shared/utils.pas @@ -1361,7 +1361,7 @@ var xpos := High(strbuf); strbuf[xpos] := #0; Dec(xpos); repeat - if hex then + if not hex then begin strbuf[xpos] := AnsiChar((n mod 10)+48); Dec(xpos); @@ -1391,7 +1391,7 @@ var xpos := High(strbuf); strbuf[xpos] := #0; Dec(xpos); repeat - if hex then + if not hex then begin strbuf[xpos] := AnsiChar((n mod 10)+48); Dec(xpos);