Finding display name of object
-
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.
-
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):
CSolar* solar = whatever; UINT ids_name = ((CEqObj*)solar)->get_name(); ```Alternatively, just do what get_name does directly:
UINT nickname = whatever;
FmtStr fmtstr, dummyfmt;
LPCWSTR dummystr;
Reputation::Vibe::GetName(nickname, fmtstr, dummyfmt, dummystr);
UINT ids_name = fmtstr.strid; -
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).
-
The Reputation namespace is part of common.dll.
Okay, I did some actual testing this time, so here’s working code (extracted from Console).
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;
-
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.