Raised This Month: $32 Target: $400
 8% 

Baseentity again


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
zahn
Junior Member
Join Date: Jan 2005
Old 01-30-2005 , 10:12   Baseentity again
Reply With Quote #1

I can include cbase.h baseentity.h to my project but when I try using a function from it, I get the extern errors. I've tried and tried and no matter what I do, I get extern error(s).

Code:
// Thanks to LanceVorgin for this wonderful vtable hook
// LevelShutdown 
// Called at the end of a level 
int VFUNC LevelShutdown(IBaseClientDLL* pClient) 
{ 
   int HighestEnt = pEntityList->GetHighestEntityIndex(); 

   // Set up player structure 
   player_info_s player; // public/cdll_int.h 

   Vector origin; 

   for (int i = 0; i < HighestEnt; ++i) 
   { 
      pEngineFuncs->GetPlayerInfo(i, &player); 

      CBaseEntity *pEnt = (CBaseEntity *)pEntityList->GetClientEntity(i); 
      //VectorCopy(pEnt->GetAbsOrigin(), origin); 

      sprintf(buffer, "Name: %s -> Index: %i, -> X:%.3f, Y:%.3f, Z:%.3f", player.name, i, origin[0]/*x*/, origin[1]/*y*/, origin[2]/*z*/); 
      DEBUG_LOG_STRING(buffer); 
   } 

   DEBUG_LOG_STRING("Level shutdown."); 

   return client_LevelShutdown(pClient); 
}
The above code workes because I'm not using pEnt->GetAbsOrigin(), but as soon as I do that I get:

Code:
Client.obj : error LNK2019: unresolved external symbol "public: void __thiscall CBaseEntity::CalcAbsolutePosition(void)" (?CalcAbsolutePosition@CBaseEntity@@QAEXXZ) referenced in function "public: class Vector const & __thiscall CBaseEntity::GetAbsOrigin(void)const " (?GetAbsOrigin@CBaseEntity@@QBEABVVector@@XZ) 
Release//sheep-hl2.dll : fatal error LNK1120: 1 unresolved externals
I tried including baseentity.cpp itself to my project and well, lets not talk about how many extern errors came from that (ok it was 296 error(s), 1 warning(s)).. the extern errors are the only errors.

My includes:

Code:
// SDK includes 
#define GAME_DLL 1 

#include "cbase.h" // dlls 
#include "cdll_int.h" // public 
#include "baseentity.h" 
#include "filesystem.h" // public 
#include "interface.h" // public/tier1 
#include "icliententitylist.h" // public 
#include "ivdebugoverlay.h" // public/engine 
#include "IEffects.h"
Altho I don't know if its a problem with the includes, more likely a missing lib? I have all the libs added to my project and theres no lib for baseentity that I know of..

This is basicly the same problem when trying to use UTIL_** functions.. theres no lib so I get extern errors, even with adding the header/cpp file.

Also don't ask me why I'm doing it in LevelShutdown, it was just one I had hooked

Thanks for any help.
zahn is offline
vancelorgin
Senior Member
Join Date: Dec 2004
Location: san frandisco
Old 01-30-2005 , 16:16  
Reply With Quote #2

You've encountered the nasty problem of dependency hell. There's no lib for server.dll funcs, as if there were they'd need to be synchronized with the real server.dll, and the real server.dll doesn't export _SHIT_ [win32, anyway ]. For the problem you posted there's an easy answer: change all 'protected' and 'private' declarations in the CBaseEntity definition to 'public', then just use m_vecOrigin off the ent directly. "But what of the 'dirty' handling the Get/Set AbsOrigin/AbsAngles/AbsVelocity funcs do?", you ask. Well: fuck em. They're like never used - this works fine for the time being. I was reimplimenting them, but got to InvalidatePhysicsRecursive and stopped - feel free to try. As for the UTIL_ funcs, if you include the cpp in yourproject it'll probably compile as long as none of the funcs are used, at which point you'll descend farther into dependency hell until you've basically mirrored the mp sdk in your plugin. The main culprit is gEntList - with that you have at least tracelines. I've yet to get that bitch fully mirrored myself, though. For now, work around the UTIL_ funcs by writing your own until somebody :cough: releases some sort of base or Valve updates the pile of shit they call their plugin interface
__________________
Avoid like the plague.
vancelorgin is offline
zahn
Junior Member
Join Date: Jan 2005
Old 01-30-2005 , 23:57  
Reply With Quote #3

Alright! I'll try messing around with it, thanks for your help.

Altho, couldn't I somehow find the address in memory of BaseEntity, kind alike you did with uhm, CreateEnt I think it was? I mean, GetAbs.. isn't the only functions I'm going to need, what about things like health, armor, team number etc.?
zahn is offline
vancelorgin
Senior Member
Join Date: Dec 2004
Location: san frandisco
Old 01-31-2005 , 00:11  
Reply With Quote #4

It's such a horribly terribly awfully simple function it's not worth your time - just modify m_vec* yourself. Some funcs [SetHealth for example] are virtual, so you can just call them yourself. If you want a bigger func you'd have to get the address yourself somehow and delegate it (using my little class or the massive one pm used )
__________________
Avoid like the plague.
vancelorgin is offline
zahn
Junior Member
Join Date: Jan 2005
Old 01-31-2005 , 01:31  
Reply With Quote #5

Ok, I'll try see if I can find that function, thanks again.

I might just go over all the files in /public to see if theres anything I can use to get the origin based on the entity, gonna take a while
zahn is offline
zahn
Junior Member
Join Date: Jan 2005
Old 01-31-2005 , 01:47  
Reply With Quote #6

I'm playing around with dlights thats why I need the origin of the player.

Code:
	for (int i = 0; i < pEngineFuncs->GetMaxClients(); i++)
	{
		entity_t *pEnt		= (entity_t *)pEntityList->GetClientEntity(i);
		dlight_t *dl		= pEffects->CL_AllocDlight(0);

		dl->color.r			= 128;
		dl->color.g			= 255;
		dl->color.b			= 0;

		dl->origin			= pEnt->origin;
		dl->radius			= 200;
		dl->die				= 2000;
	}
This crashes.. if I were to define my own origin eg. Vector tOrigin = Vector(100, 200, 0); and then use it at dl->origin = tOrigin it workes, prints a light right outside CT spawn.

Well, I'll keep digging around the headers see if theres any functions outside of BaseEntity that'll print the origin based on the players entity.

EDIT: Oops sorry, thought I edited my other post :/.
zahn is offline
vancelorgin
Senior Member
Join Date: Dec 2004
Location: san frandisco
Old 01-31-2005 , 02:49  
Reply With Quote #7

*WHY* when you can already have the players origin?
__________________
Avoid like the plague.
vancelorgin is offline
zahn
Junior Member
Join Date: Jan 2005
Old 01-31-2005 , 03:42  
Reply With Quote #8

Quote:
Originally Posted by vancelorgin
*WHY* when you can already have the players origin?
Oh I'm not sure I understand what you mean. I thought the players origin got stored somewhere in BaseEntity, which I'm trying now to find a way out of. Are they already stored somewhere I missed?

Basicly I thought you would loop through MaxClients and then get the clients entity with ClientEntity, from there use GetAbs().. but you already covered that part. Thats why I also asked if there might be a "get position based on entity index" function.

Thanks again for your help, apreciated.
zahn is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 01-31-2005 , 08:59  
Reply With Quote #9

Quote:
Originally Posted by vancelorgin
(using my little class or the massive one pm used )
Well, sorry, I'm a megalomanist.

I've been once googling on some unimportant thing, and found that FastDelegate class - It is compatible with most compilers, fast, easy to use.

Anyway, could you please show me your little class? ;)
__________________
hello, i am pm
PM is offline
zahn
Junior Member
Join Date: Jan 2005
Old 01-31-2005 , 12:33  
Reply With Quote #10

Ok think I figured it out, Lance. Thanks again for the help.
zahn is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:51.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode