Freelancer Community Network
Reminder: Internet Explorer 6 or below are NOT supported.
HomeHome
ForumForum
WikiWiki
DownloadsDownloads
ForgeForge
Multiplayer Connection Tutorial
Collapse/Expand Random Image
Collapse/Expand Login
Username:

Password:

Remember me



Lost Password?

Register now!
Collapse/Expand Chat
Collapse/Expand Who's Online
295 user(s) are online (248 user(s) are browsing Forum)

Members: 0
Guests: 295

more...
Collapse/Expand Donations
Monthly costs: -30€
Income (ads): +5€
Donations (last month): +0€

Current balance: 55€
(last updated 04/2021)

Please make a donation if you want to help keeping The-Starport online:

Thanks!
Collapse/Expand Links
Collapse/Expand Advertisement
There are currently 76 users playing Freelancer on 45 servers.
May. 31, 2023

Browsing this Thread:   1 Anonymous Users



 Bottom   Previous Topic   Next Topic  Register To Post



Solar Spawning
Home away from home
Joined:
2008/7/8 21:15
From Germany
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 605
Offline
Since we are now capable of spawning ships I reversed the SolarInfo struct:

Code:
struct SolarInfo{
int iFlag; //0x290; ShipInfo has this too, no clue whether actually a flag
int iArchID;
int iSystemID;
Vector vPos;
Matrix mOrientation;
int iLoadoutID;
struct structCostume
{
  UINT head;
  UINT body;
  UINT lefthand;
  UINT righthand;
  UINT accessory[8];
  int  accessories;
};
structCostume Costume;
int iRep;
int iUnk7; //0
int iUnk8; //0
int iUnk9; //Boolean, only last byte is used
int iHitPointsLeft;
char cNickName[64]; //Has to be unique
int iUnk11; //0
int iUnk12; //0
};


Something with the loadouts seems to be wrong as the weapons/guns don't appear. This seems to be in general the case, if you e.g. accept a mission which contains solars to be destroyed you don't see any of them either.

You can spawn any solarobject of solararch.ini. Even planets work.

Posted on: 2010/8/26 18:37
Top
Re: Solar Spawning
Home away from home
Joined:
2009/8/16 2:58
From Qld, Aus.
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 2035
Offline
sUnk1 is a costume, but you've missed one:

Code:
struct Costume
{
  UINT head;
  UINT body;
  UINT lefthand;
  UINT righthand;
  UINT accessory[8];
  int  accessories;
};

That makes iUnk6 disappear into the Costume. iUnk8 is set by pub::Reputation::Alloc. iUnk9 is bool, initialised to true, but later copied from something.

Posted on: 2010/8/27 7:23
Top
Re: Solar Spawning
Home away from home
Joined:
2008/7/8 21:15
From Germany
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 605
Offline
Well the sub which initializes this struct:
Code:
 mov     eax, ecx
xor     ecx, ecx
mov     [eax], ecx
mov     [eax+4], ecx
mov     [eax+8], ecx
mov     [eax+0Ch], ecx
mov     [eax+30h], ecx
retn


Does only use 5 values. That's why I got only 5 and did not include iUnk6. But I now calculated the end and noticed it just does not initialize the array.

Concerning iUnk8: I can not confirm that (at least in the sub I analyzed). There only iRep is used by ...::Alloc.

Concerning iUnk9: I checked and yes it is initialized with 1, but still uses 4 bytes instead of 1. In CreateSolar only one byte is read. So one can assume it is indeed boolean, but 4 byte aligned.

Posted on: 2010/8/27 12:28
Top
Re: Solar Spawning
Just can't stay away
Joined:
2008/6/20 0:27
From Russia, GMT+4
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 278
Offline
Care to reverse the loot struct? IMO it can have more applications...

Posted on: 2010/8/27 15:05
Top
Re: Solar Spawning
Home away from home
Joined:
2008/7/8 21:15
From Germany
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 605
Offline
I disagree. You can use Server.MineAsteroid anyway for this purpose.

Posted on: 2010/8/27 15:19
Top
Re: Solar Spawning
Starport Admin
Joined:
2009/2/21 21:42
Group:
Webmasters
Registered Users
Posts: 3520
Offline
I think all of FL's structs are 4-byte aligned.

Nice stuff Schmack

Does it work properly with all the struct filled?

Posted on: 2010/8/27 15:34
"Cynicism is not realistic and tough. It's unrealistic and kind of cowardly because it means you don't have to try."
-Peggy Noonan
Top
Re: Solar Spawning
Home away from home
Joined:
2009/8/16 2:58
From Qld, Aus.
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 2035
Offline
Quote:
Does only use 5 values. That's why I got only 5 and did not include iUnk6.

Count again. It initialises five values.

Quote:
Concerning iUnk8: I can not confirm that (at least in the sub I analyzed). There only iRep is used by ...::Alloc.

iRep is set by pub::Reputation::SetAffiliation.

Quote:
So one can assume it is indeed boolean, but 4 byte aligned.

Not quite - the alignment is for the following int. bool = 1 byte, int = 4 bytes, so to keep the int DWORD aligned, 3 padding bytes are added after the bool.

I should point out I'm doing all this from the disassembly of content.dll, not from debugging.

Posted on: 2010/8/27 15:43
Top
Re: Solar Spawning
Home away from home
Joined:
2008/7/8 21:15
From Germany
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 605
Offline
@FF: Thx. It depends on what you mean with "properly" I noticed none of the mission solars has any weapons visible. I don't know if there is a way changing that on creation, since there are a few unknown values yet. Setting the iUnk9 to 1 had no effect. If I spawn regular weapon platforms, they don't attack. Maybe the personality thing does not work like it does for npcs.

The rest works ok, The types in the radar and on the screen match. You can see them from very far, too. The only thing I did not test is giving them names and I don't know how to do that either, yet

@adoxa: You are misunderstanding me.

Quote:
Count again. It initialises five values.

That's what I wrote after that sentence you quoted. You left the important part out.

Quote:
iRep is set by pub::Reputation:etAffiliation.

From what I have seen, it is used by both Alloc and SetAffiliation (which would corresponded with the way we set it in FLHook).

Quote:
Not quite - the alignment is for the following int. bool = 1 byte, int = 4 bytes, so to keep the int DWORD aligned, 3 padding bytes are added after the bool.


DWORD is 4 byte, so we are talking about the same.

I used debugging only for getting a memory dump of the whole struct.

Posted on: 2010/8/27 16:12
Top
Re: Solar Spawning
Home away from home
Joined:
2009/8/16 2:58
From Qld, Aus.
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 2035
Offline
@Schmackbolzen: Ah yes, my mistake. You should edit the first post.

Posted on: 2010/8/28 5:57
Top
Anonymous
Re: Solar Spawning
Anonymous-Anonymous
So now when a base is destroyed, it will be respawned after some time?
Where do I get this plugin?

Posted on: 2010/8/28 10:45
Top
Re: Solar Spawning
Home away from home
Joined:
2008/7/8 21:15
From Germany
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 605
Offline
This is still in development. I suppose for full potential also clienthooking will be needed (I will test some time later how much you can change after a base is spawned). For now it is for developers only, so that we can reverse everything which is needed to make a practical use of it.

@Adoxa: Done.

Posted on: 2010/8/28 11:09
Top
Re: Solar Spawning
Home away from home
Joined:
2009/8/16 2:58
From Qld, Aus.
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 2035
Offline
Why didn't you just use bool iUnk9;? Padding is taken care of automatically. And let's not get started on last byte/first byte.

Posted on: 2010/8/28 15:04
Top
Re: Solar Spawning
Home away from home
Joined:
2008/7/8 21:15
From Germany
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 605
Offline
I don't trust the compiler (since it is from MS) and we are dealing with multiple versions here (no clue whether vc7-vc10 behave the same). Last and first byte depends whether it is big or little endian and to my knowledge the last byte should be used, also the asm code I saw suggests this (also for the programmer it is only important to know, that 1 is true). If anyone wants to try whether setting it to boolean will not change the structs size/composition, be my guest

Posted on: 2010/8/28 15:47
Top
Re: Solar Spawning
Just can't stay away
Joined:
2008/6/16 20:41
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Posts: 312
Offline
struct member allignment can be setup in source code with #pragma pack keyword. As far as i remember is #pragma pack push 1 before the struct definition and #pragma pack pop (or similar).
see http://msdn.microsoft.com/en-us/library/2e70t5y1(VS.80).aspx

Wouldnt it be better to leave it for UINT iUnk9; if the alignment is 4 bytes by default?

Posted on: 2010/8/28 16:19
Open in new window
Top
Re: Solar Spawning

Joined:
2015/9/13 18:49
Group:
Registered Users
FLServer Admins
$$$ Supporters $$$
Senior Members
Posts: 21
Offline
Probably 11 years too late but iUnk8 is the BaseID of the base the Solar is linked to.

Posted on: 2021/3/25 23:03
Top