Raised This Month: $51 Target: $400
 12% 

Including CBaseEntity


Post New Thread Reply   
 
Thread Tools Display Modes
Manip
Senior Member
Join Date: Jan 2004
Old 01-19-2005 , 21:01  
Reply With Quote #11

Quote:
Originally Posted by theqizmo
And Manip: so much overhead, creating a player class can give you all the variables you need, instead of recreating them everytime.
...I am using a single pointer .... ? .... Are you saying you would use LESS than 32bits in your player class?
Manip is offline
Send a message via AIM to Manip
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 01-19-2005 , 21:10  
Reply With Quote #12

Awww stop arguing and make it work for me
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
theqizmo
Member
Join Date: Oct 2004
Old 01-20-2005 , 00:57  
Reply With Quote #13

Manip: Instead of calling an engine function everytime I want data, I call it when the player joins, and save it to my player class. Then when I want to find the pointer to the player class, I use the pointers in my class. You call valve's functions multiple times:

Code:
  edict_t *player = engine->PEntityOfEntIndex(rtn);
...
   ToLog("[SAP] Admin_slap - Admin %s<%s> to %s<%s> with %d damage", 
      engine->GetClientConVarValue(engine->IndexOfEdict(ed), "name"), engine->GetPlayerNetworkIDString(ed), 
      engine->GetClientConVarValue(rtn, "name"), engine->GetPlayerNetworkIDString(engine->PEntityOfEntIndex(rtn)), damage);
Everytime an admin slaps a player, it looks for all of that. It works, I don't say it doesn't, and nor is any of it wrong, however, it isn't really "reusable." You copy and paste what you need into another function, and it works, but it's being called so much it's pointless: it's overhead. But, you can do whatever you like with your plugin.

(and if you're really worried about memory usage with Half-Life2, don't =x)


Geesu: what are your include directories? If you can build the HL server dll, then your headers are fine, and you're just missing a header in your plugin (include the previous headers and fix the include paths), and if it doesn't work, reinstall the SDK.

These directories are the default for the hl SDK project:
../game_shared/sdk;./;../Public/tier1;../Public;../game_shared;../utils/common;../dlls;../dlls/sdk

These are mine, in order (and yes if I dont need one, I dont care):
\src
\src\common\
\src\dlls\
\src\game_shared
\src\public\
\src\public\
\src\public\dlls\
\src\public\engine\
\src\public\tier1\
\src\public\tier0\
\src\public\vgui\
\src\tier1
theqizmo is offline
Send a message via ICQ to theqizmo Send a message via AIM to theqizmo Send a message via MSN to theqizmo
Manip
Senior Member
Join Date: Jan 2004
Old 01-20-2005 , 03:47  
Reply With Quote #14

Half Life 2 already has a "player class", all you doing by addding all that information locally and updating it each time a player changes a value is adding overhead by abstracting somoething that already exists.

The function calls I'm using are very "cheap" in general they are almost just links into private class data.
Manip is offline
Send a message via AIM to Manip
theqizmo
Member
Join Date: Oct 2004
Old 01-20-2005 , 14:13  
Reply With Quote #15

I never update my pointers past the initialization of my class, (with the exception of the CBasePlayer*, which I'm having issues with since the last patch on linux.) I create the pointers when a player joins, update all that I can, and I use them when I need them. Once the player disconnects, I unset the pointers and destroy the class.

The *only* variables I use that aren't pointers are a signed int, and three booleans. How does this add overhead? The pointers won't change unless the player disconnects and rejoins, and by then, my class will have already updated them.

What's wrong with abstracting from the SDK? They SDK is by no means complete, and because of that, it's better to create your own classes than not. You're given a PlayerInfo class, but how much of that is specifically usable? Why rely on someone else's methods to do your work, when you can write your methods for your specific needs?
theqizmo is offline
Send a message via ICQ to theqizmo Send a message via AIM to theqizmo Send a message via MSN to theqizmo
BAILOPAN
Join Date: Jan 2004
Old 01-20-2005 , 15:17  
Reply With Quote #16

It really depends on how expensive it is to look up an IPlayerInfo pointer - I think it's a constant operation because I've given invalid pointers and gotten non-NULL results, which would say there's a simple lookup with no bounds checking.

So in this case, it doesn't really help to cache the IPlayerInfo... I know I don't do it in SourceMod.
__________________
egg
BAILOPAN is offline
vancelorgin
Senior Member
Join Date: Dec 2004
Location: san frandisco
Old 01-20-2005 , 16:42  
Reply With Quote #17

I don't cache it either. I do however provide inline passthroughs for it in my player class. I'll speak for qiz and I here as last I checked we used very similar architectures

The overhead he's referring to is all the PEntityFromIndex and IndexOfEntity calls being made. Besides, the 'overhead' you speak of, manip, is required to have any complicated features involving individual players, unless by some stretch of the imagination a flat array of player specific data is 'better' to you

And for the record I had cbaseentity in my plugin the night I first started to mess with it, and I was obviously doing more with them than anybody else seems to be (*cough* baseent::create *cough* ent method hooks *cough*)
__________________
Avoid like the plague.
vancelorgin is offline
c0ldfyr3
AlliedModders Donor
Join Date: Aug 2005
Location: Ireland
Old 09-01-2005 , 19:55   Randomise Interface
Reply With Quote #18

Just read this post and noticed the post about the Randomise Interface.

Yet another amazing addition to what im quickly calling the BEST DAMN SDK EVER !!!

Check this out...

Anywhere...
Code:
m_Random->RandomInt(0,10)
Header...
Code:
#include "random.h"
IUniformRandomStream *m_Random;
cpp....
Code:
m_Random = (IUniformRandomStream *)((ismm->engineFactory())("VEngineRandom001", NULL));
(The VENGINE_CLIENT_RANDOM_INTERFACE_VERSION definition wouldnt work for me for some strange reason, even with the header included...)
__________________
c0ldfyr3 is offline
Send a message via MSN to c0ldfyr3 Send a message via Yahoo to c0ldfyr3
Fix
Member
Join Date: Jun 2005
Old 12-25-2005 , 08:28  
Reply With Quote #19

#define GAME_DLL 1
#include "cbase.h"

->
d:\HL2MP Mod\src\utils\serverplugin_sample\serverplugi n_empty.cpp(37): error C2371: ' more gameeventmanager ': Redefinition; different basis types
d:\HL2MP Mod\src\utils\serverplugin_sample\serverplugi n_empty.cpp(247): error C2440: ' = ': ' IGameEventManager * ' cannot be converted in ' IGameEventManager2 * '
d:\HL2MP Mod\src\utils\serverplugin_sample\serverplugi n_empty.cpp(272): error C2664: ' IGameEventManager2::RemoveListener ': Conversion of the parameter 1 of ' CEmptyServerPlugin * does not const ' in ' IGameEventListener2 * ' possible
d:\HL2MP Mod\src\utils\serverplugin_sample\serverplugi n_empty.cpp(302): error C2660: ' IGameEventManager2::AddListener ': Function does not accept 2 parameters
d:\HL2MP Mod\src\utils\serverplugin_sample\serverplugi n_empty.cpp(33: error C2664: ' IGameEventManager2::RemoveListener ': Conversion of the parameter 1 of ' CEmptyServerPlugin * does not const ' in ' IGameEventListener2 * ' possible

(errors translated from german to english with google)
Fix is offline
Send a message via ICQ to Fix Send a message via MSN to Fix
c0ldfyr3
AlliedModders Donor
Join Date: Aug 2005
Location: Ireland
Old 12-25-2005 , 08:46  
Reply With Quote #20

Quote:
Originally Posted by Fix
d:\HL2MP Mod\src\utils\serverplugin_sample\serverplugi n_empty.cpp(247): error C2440: ' = ': ' IGameEventManager * ' cannot be converted in ' IGameEventManager2 * '
d:\HL2MP Mod\src\utils\serverplugin_sample\serverplugi n_empty.cpp(272): error C2664: ' IGameEventManager2::RemoveListener ': Conversion of the parameter 1 of ' CEmptyServerPlugin * does not const ' in ' IGameEventListener2 * ' possible
d:\HL2MP Mod\src\utils\serverplugin_sample\serverplugi n_empty.cpp(302): error C2660: ' IGameEventManager2::AddListener ': Function does not accept 2 parameters
d:\HL2MP Mod\src\utils\serverplugin_sample\serverplugi n_empty.cpp(33: error C2664: ' IGameEventManager2::RemoveListener ': Conversion of the parameter 1 of ' CEmptyServerPlugin * does not const ' in ' IGameEventListener2 * ' possible
I have marked the pieces of information you need.
Does no body even try and debug their own errros anymore ?
__________________
c0ldfyr3 is offline
Send a message via MSN to c0ldfyr3 Send a message via Yahoo to c0ldfyr3
Reply



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 02:47.


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