Author Topic: GetFactoryCargo()  (Read 1549 times)

Offline BlackBox

  • Administrator
  • Hero Member
  • *****
  • Posts: 3093
GetFactoryCargo()
« on: December 10, 2004, 03:40:50 PM »
I was able to get this from Eddy-B:

Code: [Select]
void GetFactoryCargo(Unit &u,int bay,map_id &unitType,map_id &weaponType)
{
  int p=*((int *)0x0054F848)+*((int *)&u)*120;
  map_id type=u.GetType();
  switch (type)
  {
   case map_Structure_Factory:
    unitType=(map_id)*((char *)(p+bay+0x61));
    weaponType=(map_id)*((char *)(p+bay+0x48));
    break;
   case map_Spaceport:
    unitType=(map_id)*((char *)(p+0x6E));
    weaponType=(map_id)*((char *)(p+bay+0x61));
    break;
   default:
    unitType=weaponType=map_None;
    break;
  }
 }

Btw, he might be a little dangerous. He was asking me how to repair structures (besides SetDamage). I said, yes there is a way but I'd rather not reveal it at the moment. (Didn't mention the word CommandPacket, didn't want to get him started at it).

He wanted to trade this code for code to repair a structure, but he ended up just giving this to me.

So, be prepared. I think I might be able to get a couple other functions as well.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
GetFactoryCargo()
« Reply #1 on: December 10, 2004, 09:39:56 PM »
Hmm, this is essentially equivalent to how I've been doing it. Although, I've decalred enough structures (and added that asm file for linking things) so I can use actually names rather than hardcoded offsets/pointers. But yeah, he's got the right address for the internal unit array pointer.

I'm thinking I should hurry up and release some sort of library so there is little point to look into doing this stuff. Plus, if we can get one library out there, it'll be less problems if we want to somehow modify the game internally.

I was thinking of a library you could link with, but then any changes could require other people to recompile. Maybe I should consider more of a DLL you can link with for extra functionality.
 

Offline BlackBox

  • Administrator
  • Hero Member
  • *****
  • Posts: 3093
GetFactoryCargo()
« Reply #2 on: December 12, 2004, 10:28:38 AM »
Hmm, yea, that would be a good idea, with a shared DLL. (We could just include it in one of the updates, and everyone would have it)

We'd have to be certain that there was compatibility for these functions. (We couldn't do stuff like change the # of parameters, etc because existing DLL's would break).

We'll have to plan it out and be sure that we insert the 'reserved' params where needed, etc.

Or....

Another option (though it might be kind of gross) is to add exports to the EXE. This is fairly easy to do (actually, probably easier than adding imports) and could be cleaner.

But anyway.... now Eddy-B is digging into the map files.

We need to be careful. Do know that that GetFactoryCargo() func was pasted directly into the channel (thankfully the only other ppl there bsides him were ops) when he gave it to me.