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
44 user(s) are online (26 user(s) are browsing Forum)

Members: 0
Guests: 44

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

Current balance: -300€
(last updated 11/2017)

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

Bitcoin address:
Thanks!
Collapse/Expand Links
Collapse/Expand Advertisement
There are currently 85 users playing Freelancer on 36 servers.
November. 17, 2017

Browsing this Thread:   1 Anonymous Users



 Bottom   Previous Topic   Next Topic  Register To Post



Finding display name of object
Starport Admin
Joined:
2009/2/21 21:42
Group:
Webmasters
Registered Users
Posts: 3456
Offline
I've been trying to figure out how to read the name of a space object (from, say, a CSolar object) and am not sure which way to proceed.

The most logical path seems to be using FmtStrs, which can directly take a variety of IDs, including space IDs. However, I don't see how A) to initialize a FmtStr properly and B) to actually get the string in the FmtStr.

So is there a way of finding the name (not nickname!) of any object, from a CObject or IObjInspectImpl object? I specifically want the name of that instance (the [Object] in the system, for example), not the name as defined by the ids_name in the archetype.

I haven't checked how to find pilot names yet, but I'll want to do that too.

Posted on: 2012/8/16 4:19
"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: Finding display name of object
Home away from home
Joined:
2009/8/16 2:58
From Qld, Aus.
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 1805
Offline
If you rearrange CEqObj's virtual functions so get_name is in the right place (+0x88; I did it by moving the protected functions up to the top, then get_name is third-last):
Code:
CSolar* solar = whatever;
UINT ids_name = ((CEqObj*)solar)->get_name();

Alternatively, just do what get_name does directly:
Code:
UINT nickname = whatever;
FmtStr fmtstr, dummyfmt;
LPCWSTR dummystr;
Reputation::Vibe::GetName(nickname, fmtstr, dummyfmt, dummystr);
UINT ids_name = fmtstr.strid;

Posted on: 2012/8/16 15:21
Top
Re: Finding display name of object
Starport Admin
Joined:
2009/2/21 21:42
Group:
Webmasters
Registered Users
Posts: 3456
Offline
Thanks adoxa. I think I really need to clean up the headers I'm using.

Also, just to make sure, I remember you said somewhere that Server.dll isn't loaded by the client. Isn't pub::Reputation part of Server.dll? If so, wouldn't the get_name() call/Reputation::Vibe::GetName call fail when used client side?

I only managed to run pub::Audio::PlaySoundEffect from the server, for instance, even though I find that rather odd.

EDIT: get_name() works. I'm trying to figure out how to find the pilot name (IE Ens. John Doe) instead of just the ship's archetype name, but get_pilot_name() just returns a string containing the ship archetype name (just as it shows up in the radar).

Posted on: 2012/8/16 17:16

Edited by FriendlyFire on 2012/8/17 5:09:50
Edited by FriendlyFire on 2012/8/17 5:10:15
"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: Finding display name of object
Home away from home
Joined:
2009/8/16 2:58
From Qld, Aus.
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 1805
Offline
The Reputation namespace is part of common.dll.

Okay, I did some actual testing this time, so here's working code (extracted from Console).
Code:
  UINT tgt;
  CShip* cship = GetCShip();
  IObjRW* target = cship->get_target();
  if (target == NULL)
    return false;

  // The object is at +0x10 of the IObjRW.
  // The id is at +0x104 of the object.
  tgt = *(PUINT)(*(PDWORD)((PBYTE)target + 0x10) + 0x104);

  FmtStr  fmt1, fmt2;
  LPCWSTR name, pname;
  WCHAR   buf[128];
  int rc = Reputation::Vibe::GetName( tgt, fmt1, fmt2, pname );
  if (rc != 0)
    return false;
  // For a ship, fmt1 is the designation, fmt2 is the name & rank.
  // For a solar, fmt1 is the name, fmt2 is empty.
  // It appears the name comes from fmt2.
  // It still doesn't work for trade lane rings, you just get a space.
  if (fmt2.strid == 0)
  {
    GetString( RSRC, fmt1.strid, buf, 128 );
    name = buf;
  }
  else
    name = pname;

Posted on: 2012/8/17 7:45

Edited by adoxa on 2012/8/17 7:52:47
Top
Re: Finding display name of object
Starport Admin
Joined:
2009/2/21 21:42
Group:
Webmasters
Registered Users
Posts: 3456
Offline
Thank you so much

Now to actually figure out why none of the headers I have have the Reputation namespace as part of Common.dll.

Posted on: 2012/8/17 15:32
"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