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

How do you patch your hl1.dll to increase the precache limit?


Post New Thread Reply   
 
Thread Tools Display Modes
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-11-2010 , 15:22   Re: How do you patch your hl1.dll to increase the precache limit?
Reply With Quote #11

@Jim : Do you know if it's possible to change the size array ? I know dword_2166F90[] is an array from a structure. Like you can see on the quake1SDK, something similar to :

PHP Code:
typedef struct server_s
{
    
qboolean    active;                // false when server is going down
    
server_state_t    state;            // precache commands are only valid during load

    
double        time;
    
    
int            lastcheck;            // used by PF_checkclient
    
double        lastchecktime;        // for monster ai 

    
qboolean    paused;                // are we paused?

    //check player/eyes models for hacks
    
unsigned    model_player_checksum;
    
unsigned    eyes_player_checksum;
    
    
char        name[64];            // map name
    
char        modelname[64];        // maps/<name>.bsp, for model_precache[0]
    
struct model_s     *worldmodel;
    
char        *model_precache[256];    // NULL terminated
    
char        *sound_precache[256];    // NULL terminated
    
char        *lightstyles[64];
    
struct model_s        *models[512];

    
int            num_edicts;            // increases towards MAX_EDICTS
    
edict_t        *edicts;    
[...] 
When you click on it, you don't see 512, though when you check the array size (*) you see well "Maximal possible size : 512". I've tried to print the bytes from this address but it doesn't help.

Do you have some ideas ?
__________________
Arkshine is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 09-12-2010 , 00:01   Re: How do you patch your hl1.dll to increase the precache limit?
Reply With Quote #12

well, changing original array's size is not a good idea, because in data section its size is fix when compiled using 512. you can change it using a hex editor, but the offsets after this array will change maybe, I haven't actually done this kind of operation before, so I can't say it's ok or not. I only can confirm that if this array is at the end of PE, you can enlarge it without errors.
and dword_2166F90[] is not alloc in swds, it's an extern var
Maybe alloc an native array yourself, and change some code while using the original array, redirect it to your own array.
I may do some test when I get home.
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
platzpatrone
Veteran Member
Join Date: Apr 2007
Location: Germany
Old 09-12-2010 , 01:25   Re: How do you patch your hl1.dll to increase the precache limit?
Reply With Quote #13

i understand only a half of them what jim_yang wrotes but its
awesome, to have such a coder here on this forums.
platzpatrone is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-13-2010 , 05:32   Re: How do you patch your hl1.dll to increase the precache limit?
Reply With Quote #14

Quote:
Originally Posted by jim_yang View Post
well, changing original array's size is not a good idea, because in data section its size is fix when compiled using 512. you can change it using a hex editor, but the offsets after this array will change maybe, I haven't actually done this kind of operation before, so I can't say it's ok or not. I only can confirm that if this array is at the end of PE, you can enlarge it without errors.
and dword_2166F90[] is not alloc in swds, it's an extern var
Maybe alloc an native array yourself, and change some code while using the original array, redirect it to your own array.
I may do some test when I get home.
Thanks I understand better. I got the same idea that somehow we need now to redirect the original one to a bigger. So I've searched where each array are used :

sound :
  • PF_precache_sound_I()
  • PF_ambiensound_I()
  • SV_BuildSoundMsg()
  • SV_LookupSoundIndex()
  • SV_BuildHashedSoundLookupTable()
  • SV_SpawnServer()

model :
  • PF_precache_model_I()
  • PF_setmodel()
  • SV_FindModelNumbers()
  • SV_ModelIndex()
  • SV_SpawnServer()

generic :
  • PF_precache_generic_I()

At the start, I though I could write a plugin which detect when you go over 512 then rewriting the functions to use my own dynamic array in pawn, but I guess it's almost impossible since there are vars of the main structure used in some functions and I can't access it. (I've tried to access it with orpheu without success). Also it would be a lot less efficient doing that.

So, I'm interesting on "alloc an native array". What do you mean exactly ? Changing the original address is easy and it would really efficient to do that, but the part to create such array, I really don't know how to do. Because I guess you need to create it in the engine dll ? It seems we need a new module.


EDIT : I've discussed with joropito, and he made a module to allocate memory. I'm testing right now !
__________________

Last edited by Arkshine; 09-13-2010 at 10:47.
Arkshine is offline
solidjake
Junior Member
Join Date: Aug 2010
Old 09-13-2010 , 16:38   Re: How do you patch your hl1.dll to increase the precache limit?
Reply With Quote #15

Oh boy.. good luck!
solidjake is offline
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 09-14-2010 , 03:03   Re: How do you patch your hl1.dll to increase the precache limit?
Reply With Quote #16

What about not necessarily precaching more, but tricking it, telling it it already has, or shouldn't precache regular game models like v_m4a1. Might seem risky,but I think it can be done.
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]
Tirant is offline
Prajch
Senior Member
Join Date: Dec 2007
Location: anger++
Old 09-14-2010 , 06:31   Re: How do you patch your hl1.dll to increase the precache limit?
Reply With Quote #17

Quote:
Originally Posted by Tirant View Post
What about not necessarily precaching more, but tricking it, telling it it already has, or shouldn't precache regular game models like v_m4a1. Might seem risky,but I think it can be done.
I actually wrote a plugin that does exactly that a year or two ago... if anyone is really interested I can dig it up and explain what it does. It's more practical on servers that run a restricted mod like a jump server, where they don't need many of the default precached entities.

And I doubt patching the game files is a good idea... like people have been saying, it gets quite complicated where you'd have to locate every single reference and alter it or coax the game to use your own memory space. And above all that, every client that connects to your server will have to have those files. And to put the icing on the cake, I think modifying certain game files gets you a tasty VAC ban! Bon appetit!
Prajch is offline
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 09-14-2010 , 07:32   Re: How do you patch your hl1.dll to increase the precache limit?
Reply With Quote #18

I'd love to see it if you don't mind. I'm just curious how exactly to do it. I understand my logic/theory, just now how to apply it. This might be useful cause I'm developing a CoD mod, and I'm trying to cut down the download as much as possible, but there are still many files to precache .

I mean, why precache files that your server will already have, and 99.9% of people can't modify their counter-strike.gcf (not even sure you can, I mean, whats the point?). So they should already have them.

Just a stab in the dark, but does it forward the precache and then return handled if the file is in a config/const array?
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]

Last edited by Tirant; 09-14-2010 at 07:35.
Tirant is offline
Prajch
Senior Member
Join Date: Dec 2007
Location: anger++
Old 09-14-2010 , 12:28   Re: How do you patch your hl1.dll to increase the precache limit?
Reply With Quote #19

I might have misread what you were suggesting originally. Everything used by the engine (sounds, sprites, models and I think brushes in the map) has to be precached. Even though they're contained in the .gcf, they still need to be precached. As far as I know, there's no dynamic loading going on so what you load at map start is all you can use until map end. It was probably for performance reasons at the time, though the hardcoded 512 limit was sort of a stupid idea.

What my plugin does is hook the precache functions (model and sound are the important ones) to monitor what is being precached and decide when to block it. It has access to the name of the file being precached, so you can either filter by extension, or create an exhaustive list of files you want to avoid precaching and load that into memory.

I think you also have to hook the functions that associate entities with models and sprites and sounds, so that you can provide the game a suitable replacement or cancel the call. I don't remember if it's necessary for models/sprites, though my plugin does replace them with a dummy sprite (maybe just to see where precaches were blocked in a map). But for sounds, if you block the precache of the glock firing noise and you pull it out and shoot, the server crashes. I never actually got around to fixing that, but from parts I left commented out I can tell the idea was to hook EmitSound and EmitAmbientSound to cancel the call or emit a dummy sound of my own. You could also prevent the event from happening in the first place by restricing use of the weapon that emits the sound, but there are probably other sounds you can't block in the same way.

Originally I had trouble because returning FMRES_SUPERCEDE wasn't actually blocking the precache. I figured out (don't remember how) that you have to use the forward_return() function before returning, with the parameters (FMV_CELL, 0), which tells the engine that the function ran successfully if I remember correctly.

I hope that helps... if you need to see some actual code I'll have to clean up the plugin a bit; lots of debugging and logging and useless stuff I have to snip out.
Prajch is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-14-2010 , 13:11   Re: How do you patch your hl1.dll to increase the precache limit?
Reply With Quote #20

Models need to be loaded because it returns some useful informations, see model_s struct, used by severals functions. Blocking the precache of useless resources is easy, though you need to search what resources are used. But not sure if it's worth to try to trick things like replacing blanks sounds and such. You can free much resources by removing all hl-related. Or in Cs, removing the shield and you free 20 models, you can remove weapons non used on specific maps and you can free a lot of resources.
I know Joaquim has done a private plugin which does that nicely, but I'm going to write my own plugin with more features, including the feature to increase the precache size if it works (right now half-working EDIT : proof ).
__________________

Last edited by Arkshine; 09-14-2010 at 15:11.
Arkshine is offline
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 04:36.


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