AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   stock is_big_map() (https://forums.alliedmods.net/showthread.php?t=319399)

DJEarthQuake 10-29-2019 12:13

stock is_big_map()
 
Code:
///Uses: Sandboxing, more. stock is_big_map(){new Float:mega = (0.001);     new adjmsize,mname[32];     get_mapname(mname,charsmax (mname));     new Float:msize = (filesize("maps/%s.bsp",mname, charsmax (mname))*(mega)/1024);     adjmsize = floatround(msize, floatround_ceil);     return adjmsize;} /***Examples: **if( is_big_map() < 2 ) {  ///Code runs on maps less than 2 MB. **if( is_big_map() > 5 ) {  ///Code runs on maps larger than 5 MB. */

fysiks 10-29-2019 21:43

Re: stock is_big_map()
 
The name of this function is not consistent with what it's returning. "is_big_map" implies that it will return a boolean i.e. an answer to the question "Is big map?" (which would be a yes or a no)

Also, multiplying the file size, in bytes, by 0.001/1024 doesn't make any sense. Either you use the definition 1 KB = 1000 bytes or 1 KB = 1024 bytes, not both.

It might just make more sense to call it get_map_filesize() and either leave it in bytes or allow for optionally specifying the desired unit:

Code:

stock get_map_filesize(unit = 0)
{
    new szMapName[32];
    get_mapname(szMapName, charsmax(szMapName));
    return (filesize("maps/%s.bsp", szMapName, charsmax(mname)) / 1024^unit);
}

I don't have a setup to test compile this at the moment so consider it like pseudo-code. Also, I don't think using the charsmax() in filesize() makes any sense.

DJEarthQuake 10-30-2019 04:19

Re: stock is_big_map()
 
Thank you for doing that. Here is an example of code that I use is_big_map on for now until it gets cleaned up.
https://forums.alliedmods.net/showthread.php?t=135044
The compass is worth the effort to optimize IMO. Client overflows and server crashes happen on otherwise fascinating work that could be used on larger projects as author hoped.

DJEarthQuake 11-03-2019 05:25

Re: stock is_big_map()
 
Remember we are dealing with MB.

(1047296 * .001) / 1024 = 1.02275

1047296 / 1024 = 1022.75

fysiks 11-03-2019 15:44

Re: stock is_big_map()
 
Quote:

Originally Posted by DJEarthQuake (Post 2671381)
Thank you for doing that. Here is an example of code that I use is_big_map on for now until it gets cleaned up.
https://forums.alliedmods.net/showthread.php?t=135044
The compass is worth the effort to optimize IMO. Client overflows and server crashes happen on otherwise fascinating work that could be used on larger projects as author hoped.

Quote:

Originally Posted by DJEarthQuake (Post 2671820)
Remember we are dealing with MB.

(1047296 * .001) / 1024 = 1.02275

1047296 / 1024 = 1022.75

Nothing you just said makes any sense and it's obvious that you have no idea what I said in my reply.

DJEarthQuake 11-03-2019 16:07

Re: stock is_big_map()
 
Ditto


All times are GMT -4. The time now is 11:04.

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