server init

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: server init

Postby L'In20Cible » Wed Nov 15, 2017 7:37 pm

Speed0x wrote:you dont need to prove your point. ive already seen your point. i dont disagree with your point.

your point just doesnt help me.

Sorry, I misinterpreted your previous post and thought you were saying I was wrong for telling you that the tables are re-allocated every map and not that it was not affecting you because you never change the map on your server (which technically doesn't make me wrong, but whatever.).

Speed0x wrote:just a moment ago i wanted to create a simple loader via the server_ready listener. but then you kinda told me its a useless approach, although it suits my needs at least. so idk..
I didn't say it was useless; I said it was unnecessary. And I truly believe it is because I really don't understand why you persist to want to globalize the pre-cached indexes when all it does is limiting your plugin to a single map. But hey, if it does fits your needs, go for it! :wink:
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: server init

Postby satoon101 » Wed Nov 15, 2017 10:36 pm

Speed0x wrote:you are kinda wrong, because i know that i dont reload the map and your scenario never happens.. so it doesnt help me.. :(

Just because the indexes happen to be the same, doesn't mean that is by design. You shouldn't rely on that being true whatsoever. L'In20Cible is 100% right. I'm really not sure why you are trying to 'cache' the indexes anyway, that's a really quick lookup when you want to use the Decal object, and it only happens once per map (which is something that has to happen anyway).
Image
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: server init

Postby Speed0x » Tue Nov 21, 2017 10:06 pm

okay, using Decal().index is waaaaaaay too slow. ( i just tested it )
Last edited by Speed0x on Tue Nov 21, 2017 10:17 pm, edited 1 time in total.
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: server init

Postby Speed0x » Tue Nov 21, 2017 10:16 pm

what if i use these functions :

Syntax: Select all

def get_decal_index(path):
engine_server.precache_decal(path,True)
return string_tables['decalprecache'][path]

def get_model_index(path):
engine_server.precache_model(path,True)
return string_tables['modelprecache'][path]


and always reload my cache, every time the OnServerActivate listener is fired?? wouldnt this be the best solution??
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: server init

Postby satoon101 » Tue Nov 21, 2017 10:20 pm

I honestly don't see how it could possibly be slower, as that's pretty much all it does, as well:


The one improvement we could perhaps make for the Precache classes is to store the index and re-retrieve it on server_spawn when we re-precache.
Image
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: server init

Postby Speed0x » Tue Nov 21, 2017 10:25 pm

well the point is, that im only working with the indexes in my custom code.
so i dont need to initiate an entire Decal() class in python. i guess creating all the memory buffers and requirements for such are taking some time to load via python, because im loading the maximum amount in cache of both decals and models.

so since i would only need Decal().index, i guess my get_index classes are of better use here. but only, if i am correct, that reloading the indexes @ OnServerActivate, would work and never cause problems, such as "non-existing" index... etc...
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: server init

Postby Ayuto » Tue Nov 21, 2017 10:36 pm

Speed0x wrote:so i dont need to initiate an entire Decal() class in python. i guess creating all the memory buffers and requirements for such are taking some time to load via python, because im loading the maximum amount in cache of both decals and models.

The instantiation of these classes only needs to be done once (when your plugin is loaded), so I'm not sure why you even care about that.
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: server init

Postby Speed0x » Tue Nov 21, 2017 10:41 pm

because it takes too long. ( 30-60 seconds on low end machines). with my code it takes about (max 5 seconds) . if you had reat earlier posts, you would have seen that i don't restart the map usually anyway. but in case i do, i just wanted to know if the indexes will display correctly with my code. thats all. i dont need this constant attacks on my chosen approach without helping me with my approach... thats really just playing devils advocate ;)
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: server init

Postby L'In20Cible » Tue Nov 21, 2017 11:20 pm

Speed0x wrote:what if i use these functions :

Syntax: Select all

def get_decal_index(path):
engine_server.precache_decal(path,True)
return string_tables['decalprecache'][path]

def get_model_index(path):
engine_server.precache_model(path,True)
return string_tables['modelprecache'][path]

Could simply be:

Syntax: Select all

def get_decal_index(path):
return engine_server.precache_decal(path,True)

def get_model_index(path):
return engine_server.precache_model(path,True)
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: server init

Postby Ayuto » Wed Nov 22, 2017 6:50 am

Speed0x wrote:i dont need this constant attacks on my chosen approach without helping me with my approach...
You know that it's not an attack. So, please stop bringing up that point everytime.

I would rather like to fix any existing performance issues than finding any workarounds. That's why I'm not discussing yours or L'In20Cible's solution.
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: server init

Postby Speed0x » Thu Nov 23, 2017 8:34 pm

with the recent changes in the autounload class, i might test using this class now. but what about the following scenario:

ent = Tempentity("")
ent.model = Model(path)

will this tempentitiy still have the correct prechached model, even after the map restarts???
or do i still have to reset the ent.model each maprestart manually, to display the tempent model correctly?
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: server init

Postby Ayuto » Thu Nov 23, 2017 8:40 pm

You would have to reset after every map change/reload. If you don't want to create instances over and over, you could also do something like this:

Syntax: Select all

my_model = Model(path)
ent = TempEntity("blabla")

# Later before sending it or only after a map change
ent.model_index = my_model.index
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: server init

Postby Speed0x » Thu Nov 23, 2017 8:43 pm

okay, that is also how i do my workaround... i will just stick with my current code then.. thanks

Return to “Plugin Development Support”

Who is online

Users browsing this forum: Google [Bot] and 23 guests