Raised This Month: $91 Target: $400
 22% 

stock is_big_map()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DJEarthQuake
Senior Member
Join Date: Jan 2014
Location: Midwest
Old 10-29-2019 , 13:13   stock is_big_map()
Reply With Quote #1

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. */
__________________
"It's not the actual programming that's interesting. But it's what you can accomplish with the end results that are important." -Dennis Ritchie
"Mathematics, rightly viewed, possesses not only truth, but supreme beauty a beauty cold and austere, like that of sculpture..." -Bertrand Russell
DJEarthQuake is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-29-2019 , 22:43   Re: stock is_big_map()
Reply With Quote #2

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.
__________________

Last edited by fysiks; 10-29-2019 at 22:43.
fysiks is offline
DJEarthQuake
Senior Member
Join Date: Jan 2014
Location: Midwest
Old 10-30-2019 , 05:19   Re: stock is_big_map()
Reply With Quote #3

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.
__________________
"It's not the actual programming that's interesting. But it's what you can accomplish with the end results that are important." -Dennis Ritchie
"Mathematics, rightly viewed, possesses not only truth, but supreme beauty a beauty cold and austere, like that of sculpture..." -Bertrand Russell
DJEarthQuake is offline
DJEarthQuake
Senior Member
Join Date: Jan 2014
Location: Midwest
Old 11-03-2019 , 06:25   Re: stock is_big_map()
Reply With Quote #4

Remember we are dealing with MB.

(1047296 * .001) / 1024 = 1.02275

1047296 / 1024 = 1022.75
__________________
"It's not the actual programming that's interesting. But it's what you can accomplish with the end results that are important." -Dennis Ritchie
"Mathematics, rightly viewed, possesses not only truth, but supreme beauty a beauty cold and austere, like that of sculpture..." -Bertrand Russell
DJEarthQuake is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-03-2019 , 16:44   Re: stock is_big_map()
Reply With Quote #5

Quote:
Originally Posted by DJEarthQuake View Post
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 View Post
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.
__________________
fysiks is offline
DJEarthQuake
Senior Member
Join Date: Jan 2014
Location: Midwest
Old 11-03-2019 , 17:07   Re: stock is_big_map()
Reply With Quote #6

Ditto
__________________
"It's not the actual programming that's interesting. But it's what you can accomplish with the end results that are important." -Dennis Ritchie
"Mathematics, rightly viewed, possesses not only truth, but supreme beauty a beauty cold and austere, like that of sculpture..." -Bertrand Russell
DJEarthQuake is offline
Reply


Thread Tools
Display Modes

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 10:39.


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