.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Programming
General Programming Help others and get yourself helped here!

Reply
 
Thread Tools
Is this possible to pass #define from makefile?
Old
  (#1)
KWo
Developer of PODBot mm
 
KWo's Avatar
 
Status: Offline
Posts: 3,425
Join Date: Apr 2004
Default Is this possible to pass #define from makefile? - 20-05-2006

The problem is - everytime I'm trying to rescue the hostage - right after I press the "use" button - if there is some bot teamnate near me - it steals my hostage. It was too much annoying for me and I've decide to solve it. The code checks only if the hostage is "used" by some another CT bot. Lack of code to check if some human player is "using" such hostage. The only way to solve this is - to hack the private data. The people from AMX X showed me how to do this (thanks to VEN).
The problem is - data stored in private data are placed in some offsets. These offsets are system depanding - win32, linux and amd64 - they use different offsets for data stored in private data. The AMX X code uses some conditions as:
#if defined __linux__
(...)

#if defined __amd64__
(...)
but I didn't find there how do they pass these __linux__ and __amd64__ to compile code correctly for each system.
The question is - is there a way to pass these __linux__ and __amd64__ as some defined from makefile to have one the same code for all systems, but during compilation compile it correctly without necessity adding somewhere in the code:
#define __linux__
or
#define __amd64__

before compilation?
  
Reply With Quote
Re: Is this possible to pass #define from makefile?
Old
  (#2)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: Is this possible to pass #define from makefile? - 20-05-2006

just use the -D parameter for gcc.
  
Reply With Quote
Re: Is this possible to pass #define from makefile?
Old
  (#3)
jeefo
путинхуйлоебаное
 
jeefo's Avatar
 
Status: Offline
Posts: 453
Join Date: Nov 2005
Location: Saint-Petersburg
Default Re: Is this possible to pass #define from makefile? - 20-05-2006

In my oponion using offsets for pvPrivateData is not good idea, since they can be broken by newest cs update. So i have no idea how to define it form makefile.

But i see two possible ways to solve problem, intercepting DispatchUse (not sure if it's work with CS hostages). And track the user use button.

About a second method. It can be put in POD's SoundSimulateUpdate () function in this way (and i think it's good idea):
PHP Code:
else if (pPlayer->v.oldbuttons IN_USE// pressed used button?
{
    
fHearDistance 1024.0;
    
fTimeSound WorldTime () + 0.5;

    if ((
g_iMapType MAP_CS) && !IsValidBot (pPlayer))
    {
        
MakeVectors (pPlayer->v.v_angle);
        
Vector vEye pPlayer->v.origin pPlayer->v.view_ofs;

        
TraceResult tr;
        
TraceLine (vEyevEye + (gpGlobals->v_forward 200), dont_ignore_monsters,  pPlayer, &tr);

        if (!
FNullEnt (tr.pHit) && FClassnameIs (tr.pHit"hostage_entity"))
            
g_HostagesUsedByHumans.push_back (tr.pHit);
   }

Hopes it help, if not i'm sorry for offtop
  
Reply With Quote
Re: Is this possible to pass #define from makefile?
Old
  (#4)
KWo
Developer of PODBot mm
 
KWo's Avatar
 
Status: Offline
Posts: 3,425
Join Date: Apr 2004
Default Re: Is this possible to pass #define from makefile? - 20-05-2006

Quote:
Originally Posted by strelomet
In my oponion using offsets for pvPrivateData is not good idea, since they can be broken by newest cs update.
They are unchanged since CS1.5. I was afraiding the same way You are now, but the specialists from AMX and AMX X explained me that this stuff is safe. Of course - there are in my code some checks if the data contains really this what I'm expecting to get. Here is the table for all private data "OFFSETS" used by AMX and AMX X.
Quote:
Originally Posted by cstrike.h taken from AMX X 1.71
Code:
#if defined __linux__
    #define EXTRAOFFSET                    5 // offsets 5 higher in Linux builds
    #define EXTRAOFFSET_WEAPONS            4 // weapon offsets are obviously only 4 steps higher on Linux!
#else
    #define EXTRAOFFSET                    0 // no change in Windows builds
    #define EXTRAOFFSET_WEAPONS            0
#endif // defined __linux__
/*
    Offset history:
    041029:
    Confirmed (pretty much) ALL offsets for 32 bit Windows, 32 bit Linux and amd64 (yes that's all of them).
    Found out that weapon offsets are only +4 higher on Linux.
    Also backpack ammo offsets were all obviously 5 steps too high since unknown time...

*/

#define HAS_SHIELD      (1<<24) //16777216 

// "player" entities
#if !defined __amd64__
    // 32 bit offsets here
    #define OFFSET_ARMORTYPE            112 + EXTRAOFFSET
    #define OFFSET_TEAM                    114 + EXTRAOFFSET
    #define OFFSET_CSMONEY                115 + EXTRAOFFSET
    #define OFFSET_PRIMARYWEAPON        116 + EXTRAOFFSET
    #define OFFSET_INTERNALMODEL        126 + EXTRAOFFSET
    #define OFFSET_NVGOGGLES            129 + EXTRAOFFSET
    #define OFFSET_DEFUSE_PLANT            193 + EXTRAOFFSET
    #define OFFSET_VIP                    209 + EXTRAOFFSET
    #define OFFSET_TK                    216 + EXTRAOFFSET // 040926
    #define OFFSET_BUYZONE                235 + EXTRAOFFSET
    #define OFFSET_ISDRIVING            350 + EXTRAOFFSET // 040926
    #define OFFSET_STATIONARY            362 + EXTRAOFFSET // 040927 (363 works also!)

    #define OFFSET_AWM_AMMO                377 + EXTRAOFFSET // 041029: All of these *_AMMO:s were changed -5
    #define OFFSET_SCOUT_AMMO            378 + EXTRAOFFSET
    #define OFFSET_PARA_AMMO            379 + EXTRAOFFSET
    #define OFFSET_FAMAS_AMMO            380 + EXTRAOFFSET
    #define OFFSET_M3_AMMO                381 + EXTRAOFFSET
    #define OFFSET_USP_AMMO                382 + EXTRAOFFSET
    #define OFFSET_FIVESEVEN_AMMO        383 + EXTRAOFFSET
    #define OFFSET_DEAGLE_AMMO            384 + EXTRAOFFSET
    #define OFFSET_P228_AMMO            385 + EXTRAOFFSET
    #define OFFSET_GLOCK_AMMO            386 + EXTRAOFFSET
    #define OFFSET_FLASH_AMMO            387 + EXTRAOFFSET
    #define OFFSET_HE_AMMO                388 + EXTRAOFFSET
    #define OFFSET_SMOKE_AMMO            389 + EXTRAOFFSET
    #define OFFSET_C4_AMMO                390    + EXTRAOFFSET

    #define OFFSET_CSDEATHS                444 + EXTRAOFFSET // 040926
    #define OFFSET_SHIELD                510 + EXTRAOFFSET
    // "weapon_*" entities
    #define OFFSET_WEAPONTYPE            43 + EXTRAOFFSET_WEAPONS
    #define OFFSET_CLIPAMMO                51 + EXTRAOFFSET_WEAPONS
    #define OFFSET_SILENCER_FIREMODE    74 + EXTRAOFFSET_WEAPONS
    // "hostage_entity" entities
    #define OFFSET_HOSTAGEFOLLOW        86 + EXTRAOFFSET
    #define OFFSET_HOSTAGEID            487 + EXTRAOFFSET
    // "armoury_entity"
    #define OFFSET_ARMOURY_TYPE            34 + EXTRAOFFSET_WEAPONS
#else
    // Amd64 offsets here
    #define OFFSET_ARMORTYPE            137 + EXTRAOFFSET
    #define OFFSET_TEAM                    139 + EXTRAOFFSET // +25
    #define OFFSET_CSMONEY                140 + EXTRAOFFSET // +25
    #define OFFSET_PRIMARYWEAPON        141 + EXTRAOFFSET // +25
    #define OFFSET_INTERNALMODEL        152 + EXTRAOFFSET // +26
    #define OFFSET_NVGOGGLES            155 + EXTRAOFFSET // +26
    #define OFFSET_DEFUSE_PLANT            219 + EXTRAOFFSET // +26
    #define OFFSET_VIP                    242 + EXTRAOFFSET // +27
    #define OFFSET_TK                    249 + EXTRAOFFSET // +33 040927
    #define OFFSET_BUYZONE                268 + EXTRAOFFSET // +27
    #define OFFSET_ISDRIVING            386 + EXTRAOFFSET // 040927
    #define OFFSET_STATIONARY            400 + EXTRAOFFSET // 040927 (401 works also)

    #define OFFSET_AWM_AMMO                426 + EXTRAOFFSET // +44
    #define OFFSET_SCOUT_AMMO            427 + EXTRAOFFSET // +44
    #define OFFSET_PARA_AMMO            428 + EXTRAOFFSET // +44
    #define OFFSET_FAMAS_AMMO            429 + EXTRAOFFSET // +44
    #define OFFSET_M3_AMMO                430 + EXTRAOFFSET // +44
    #define OFFSET_USP_AMMO                431 + EXTRAOFFSET // +44
    #define OFFSET_FIVESEVEN_AMMO        432 + EXTRAOFFSET // +44
    #define OFFSET_DEAGLE_AMMO            433 + EXTRAOFFSET // +44
    #define OFFSET_P228_AMMO            434 + EXTRAOFFSET // +44
    #define OFFSET_GLOCK_AMMO            435 + EXTRAOFFSET // +44
    #define OFFSET_FLASH_AMMO            436 + EXTRAOFFSET // +44
    #define OFFSET_HE_AMMO                437 + EXTRAOFFSET // +44
    #define OFFSET_SMOKE_AMMO            438 + EXTRAOFFSET // +44
    #define OFFSET_C4_AMMO                439    + EXTRAOFFSET // +44

    #define OFFSET_CSDEATHS                493 + EXTRAOFFSET // +49
    #define OFFSET_SHIELD                559 + EXTRAOFFSET
    // "weapon_*" entities
    #define OFFSET_WEAPONTYPE            57 + EXTRAOFFSET // +14
    #define OFFSET_CLIPAMMO                65 + EXTRAOFFSET // +14
    #define OFFSET_SILENCER_FIREMODE    88 + EXTRAOFFSET // +14
    // "hostage_entity" entities
    #define OFFSET_HOSTAGEFOLLOW        51 + EXTRAOFFSET // +21, long=51, int=107! (must use the long* offset because pointers on amd64 are stored the size of longs, 8 bytes, instead of the usual int 4 bytes.)
    #define OFFSET_HOSTAGEID            516 + EXTRAOFFSET // +29
#endif
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

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



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com