wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Warcraft Editing Tools
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 04-06-2010, 12:12 PM   #1
Element of Water
User
 
Element of Water's Avatar
 
Join Date: Mar 2009
Posts: 147

Submissions (2)

Element of Water is on a distinguished road (18)

Default RtC Plugin -- EoWNativePack

This is a native pack for RtC which includes 3 plugins:

FileAPI -- a secure FIle I/O system which allows Warcraft 3 to have access to files outside of the map itself.
OptimizeAPI -- an attempt to optimise some of the useful BJ functions, which are not often used because they "waste a function call".
WindowAPI -- a way of accessing various properties of the Warcraft 3 window.

The current natives are:
Collapse JASS:
//============================================================================
// OptimiseAPI
//

// for reals
native NpRMax takes real a, real b returns real
native NpRMin takes real a, real b returns real
native NpRAbs takes real r returns real
native NpModuloReal takes real dividend, real divisor returns real

// for integers
native NpIMax takes integer a, integer b returns integer
native NpIMin takes integer a, integer b returns integer
native NpIAbs takes integer r returns integer
native NpModuloInteger takes integer dividend, integer divisor returns integer

//============================================================================
// WindowAPI
//

native NpGetWindowWidth takes nothing returns integer
native NpGetWindowHeight takes nothing returns integer
native NpMinimizeWindow takes nothing returns boolean

//============================================================================
// FileAPI
//

// you'll find all your saved files in the "Warcraft/SavedData" directory, where
// "Warcraft" indicates the directory where Warcraft 3 is installed
// note that you cannot open more than 32 different files in one instance of a map

// opens a file and returns a file id used to access the file later -- if append
// is true, when writing to the file, data will be added at the end, rather than 
// overwriting the original contents -- you cannot open files larger than 1 mb
// or 1048576 bytes -- this function will build all directories for you and create
// the file if you specify a file that doesn't exist
// Note: you cannot specify an absolute path ("C:/...") for safety reasons
native FileOpen takes string filename, boolean append returns integer
// closes the file, returns false if it doesn't exist, true on success
native FileClose takes integer fileid returns boolean
// returns the size of the specified file in bytes -- can be used to check if you're
// near the limit for WriteFile -- a return value of -1 means something went wrong
native FileGetSize takes integer fileid returns integer
// writes the given string to the file, returns false on failure, true on success
// the maximum amount of data a file written like this can contain is 1 mb or 1048576 
// bytes, for safety reasons 
native FileWrite takes integer fileid, string toWrite returns boolean
// writes a string followed by an end line to the file -- the file size cap still
// applies -- not much different from WriteFile with a "\n" escape character at
// the end of the toWrite string
native FileWriteLine takes integer fileid, string toWrite returns boolean
// reads the specified number of characters from the file, stopping when it encounters
// the first character of the string stopAtChar -- returns "ReadFile_ERROR" on failure 
native FileReadEx takes integer fileid, integer maxChars, string stopAtChar returns boolean
// the same as FileReadEx except it does not specify a character to stop at
native FileRead takes integer fileid, integer maxChars returns string
// the same as FileReadEx except the stopAtChar is '\n' (newline)
native FileReadLine takes integer fileid, integer maxChars returns string
You can download the DLLs plus the source files in the attached zip. Remember to read the readme!

Remember: I need suggestions / requests!

PS: If anyone can think of a better name, it would be welcome.
Attached Files
File Type: zip EoWNativePack.zip (277.0 KB, 60 views)

Last edited by Element of Water : 04-09-2010 at 08:30 PM.
Element of Water is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 04-07-2010, 02:40 PM   #2
Earth-Fury
Two Blue
 
Earth-Fury's Avatar
 
Join Date: Mar 2003
Posts: 2,179

Submissions (7)

Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)

Send a message via MSN to Earth-Fury
Default

prefixes are evil.

RAbs is likely faster as R2I() (Ints can be used in real expressions)
__________________
Useful Links:
My Resources:
Good Resources:
Search
Tutorials
Ability Guide

UnitMaxState
BonusMod

AutoIndex
ARGB
TimerUtils

Earth-Fury is offline   Reply With Quote
Old 04-07-2010, 03:12 PM   #3
Element of Water
User
 
Element of Water's Avatar
 
Join Date: Mar 2009
Posts: 147

Submissions (2)

Element of Water is on a distinguished road (18)

Default

What should I do other than prefixes? Allow it to collide with everything?

Quote:
RAbs is likely faster as R2I() (Ints can be used in real expressions)
You mean I should scrap IAbs and use R2I(RAbs(i))? I'm confused...

EDIT: Updated, added some file i/o that was requested on the hive.

Last edited by Element of Water : 04-07-2010 at 03:16 PM.
Element of Water is offline   Reply With Quote
Old 04-07-2010, 03:22 PM   #4
TriggerHappy
 
Join Date: Feb 2008
Posts: 405

Submissions (2)

TriggerHappy will become famous soon enough (43)TriggerHappy will become famous soon enough (43)

Default

These natives could easily be malicious.
You should make a filesize limit on the files that are being written to.
TriggerHappy is offline   Reply With Quote
Old 04-07-2010, 04:49 PM   #5
Element of Water
User
 
Element of Water's Avatar
 
Join Date: Mar 2009
Posts: 147

Submissions (2)

Element of Water is on a distinguished road (18)

Default

You can't run an exe file with this, even if you make a virus, so I don't see what you mean...
Element of Water is offline   Reply With Quote
Old 04-07-2010, 05:22 PM   #6
TriggerHappy
 
Join Date: Feb 2008
Posts: 405

Submissions (2)

TriggerHappy will become famous soon enough (43)TriggerHappy will become famous soon enough (43)

Default

You could make a HUGE file.
And.. remove the prefixes on the I/O functions.

Last edited by TriggerHappy : 04-07-2010 at 05:23 PM.
TriggerHappy is offline   Reply With Quote
Old 04-07-2010, 05:55 PM   #7
Ammorth
I blink, therefore I am.
 
Ammorth's Avatar
 
Join Date: Sep 2006
Posts: 1,812

Submissions (10)

Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)

Default

Id say anything over 1mb is over-kill for a file. Maybe have a limit to the number of specific files a person can modify? 255 seems extremely large. something like 16 or 32 would be better.

Also, I think the natives would work best if they read line-by-line and save line-by-line.

Can the files be created anywhere, or only relative to war3.exe? If anywhere, you have a problem with people modifying other files (firewalls, windows, etc) which could cause complications.
__________________

Last edited by Ammorth : 04-07-2010 at 05:57 PM.
Ammorth is offline   Reply With Quote
Old 04-07-2010, 06:23 PM   #8
Element of Water
User
 
Element of Water's Avatar
 
Join Date: Mar 2009
Posts: 147

Submissions (2)

Element of Water is on a distinguished road (18)

Default

Ok, it seems I have a lot of work to do...
Quote:
Id say anything over 1mb is over-kill for a file. Maybe have a limit to the number of specific files a person can modify? 255 seems extremely large. something like 16 or 32 would be better.
There is already a limit in place as to the number of open files at one time, and that is 16, but do you mean something else?
Quote:
Also, I think the natives would work best if they read line-by-line and save line-by-line.
I like writing and reading in bulk, but I guess at the moment there is no way of making a new line (escape char "\n" would just print as "\n").
Quote:
Can the files be created anywhere, or only relative to war3.exe? If anywhere, you have a problem with people modifying other files (firewalls, windows, etc) which could cause complications.
The file path is relative to wc3, but it allows absolute file paths too. I guess I could make it so you can only write to files within a specific folder in the wc3 directory, so that would also prevent the modification of core wc3 files.

I'll get on it later, maybe tomorrow, but right now I'm in the middle of something else. For now I suppose I'll remove those natives...

Last edited by Element of Water : 04-07-2010 at 06:24 PM.
Element of Water is offline   Reply With Quote
Old 04-07-2010, 06:40 PM   #9
Ammorth
I blink, therefore I am.
 
Ammorth's Avatar
 
Join Date: Sep 2006
Posts: 1,812

Submissions (10)

Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)

Default

Quote:
Originally Posted by Element of Water
Ok, it seems I have a lot of work to do...
There is already a limit in place as to the number of open files at one time, and that is 16, but do you mean something else?

If I open a file, write the max size, close the file. open a new file, write the max size, close the file. open a new file... etc. You could rape someones HD. Limiting the number of specific files a map can open would be the best bet.

Quote:
Originally Posted by Element of Water
I like writing and reading in bulk, but I guess at the moment there is no way of making a new line (escape char "\n" would just print as "\n").

I'm thinking about saving data over maps (not using gamecache). You would want each bit of data on its own line, instead of jumbled together. C++ has getLine() and endl for reading and writing to multiple lines, so even if you made natives that read line by line and wrote line by line (keeping the bulk ones there) would be handy.
__________________
Ammorth is offline   Reply With Quote
Old 04-07-2010, 07:27 PM   #10
Element of Water
User
 
Element of Water's Avatar
 
Join Date: Mar 2009
Posts: 147

Submissions (2)

Element of Water is on a distinguished road (18)

Default

Quote:
If I open a file, write the max size, close the file. open a new file, write the max size, close the file. open a new file... etc. You could rape someones HD. Limiting the number of specific files a map can open would be the best bet.
Ok, but how would I do this? By map name? Have a general limit across all maps?

Quote:
I'm thinking about saving data over maps (not using gamecache). You would want each bit of data on its own line, instead of jumbled together. C++ has getLine() and endl for reading and writing to multiple lines, so even if you made natives that read line by line and wrote line by line (keeping the bulk ones there) would be handy.
I see what you mean, but wouldn't that make this whole system effectively gamecache but not as ordered?
Element of Water is offline   Reply With Quote
Old 04-07-2010, 07:32 PM   #11
Ammorth
I blink, therefore I am.
 
Ammorth's Avatar
 
Join Date: Sep 2006
Posts: 1,812

Submissions (10)

Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)

Default

I would use a static array of all the files that have been openned, adding new files to the array. When there are no more spots left in the array, return an error.

Hmm, right, gamecache...
__________________
Ammorth is offline   Reply With Quote
Old 04-07-2010, 07:38 PM   #12
Element of Water
User
 
Element of Water's Avatar
 
Join Date: Mar 2009
Posts: 147

Submissions (2)

Element of Water is on a distinguished road (18)

Default

Quote:
I would use a static array of all the files that have been openned, adding new files to the array. When there are no more spots left in the array, return an error.
So you don't mean an overall limit, just a limit per game?

Quote:
Hmm, right, gamecache...
Are you saying "abandon this thing because gamecache does it anyway"?
Element of Water is offline   Reply With Quote
Old 04-07-2010, 10:45 PM   #13
Ammorth
I blink, therefore I am.
 
Ammorth's Avatar
 
Join Date: Sep 2006
Posts: 1,812

Submissions (10)

Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)

Default

I wouldn't limit the total number of files, but the number of unique files a map can access per game. Sure, a map maker can have there map generate 32 random files of 1 mb per game, but it would take a lot longer to fill someone's HD. So ya, a limit per game.

Not at all. Gamecache can't be modified outside of wc3 easily, while a file can. You could use a program to upload the files created by a map to a server and easily keep track of data this way. As well as being able to download new data, and have the map load it.
__________________
Ammorth is offline   Reply With Quote
Old 04-07-2010, 11:43 PM   #14
Element of Water
User
 
Element of Water's Avatar
 
Join Date: Mar 2009
Posts: 147

Submissions (2)

Element of Water is on a distinguished road (18)

Default

Yeah, that makes it much easier. To be honest I think a limit of 32 is way higher than anyone would need, but then agaib some maps might want to load large amounts of data. I know nothing I'll ever do will amount to even 1 mb of memory...

Wow, I made the thing and I couldn't think of any uses for it, but now you've convinced me not to give it up. Thanks.

Todo list so far:
  • Make the natives only able to access a specific folder in the wc3 directory, I'll call it "Saved Data" maybe?
  • Enforce a limit of 1 mb per file to write, 32 maximum files to write per game. I guess I can allow an infinite number of files / amount of data to read.
  • Make "WriteLine" and "ReadLine" natives.
If there's anything I missed, please tell me. Goodnight. It's 40 minutes past midnight here and I'm very tired.
Element of Water is offline   Reply With Quote
Old 04-08-2010, 12:17 AM
<?White-Tiger?>
This message has been deleted by <?White-Tiger?>. Reason: should be pm lol^^
Old 04-08-2010, 06:22 PM   #15
Element of Water
User
 
Element of Water's Avatar
 
Join Date: Mar 2009
Posts: 147

Submissions (2)

Element of Water is on a distinguished road (18)

Default

Big Update:
The file system is back, and fully secure (I think). Here's what I've done:
  • Removed the prefixes on the File I/O natives.
  • The natives now only allow you to open files smaller than 1 mb, and if you hit that limit when writing, you won't be able to write any more.
  • The natives can only access one directory and all of its sub-directories on the hard-drive: the SavedData folder in your wc3 installation folder -- this is created as soon as you open a file if it doesn't already exist.
  • You can now specify a path that includes directories which don't exist, and OpenFile will create them for you.
  • You no longer have to specify "modes" for OpenFile -- you can read or write from any file. I added a boolean "append" to OpenFile to keep that functionality.
  • One game (instance of a map) can only open a maximum of 32 different files at one time.
  • Added WriteFileLine and ReadFileLine.
  • Added GetFileSize.
  • Removed IsFileOpen -- if you call OpenFile and the file is already open, it will just return the same id.
Now is it functional/secure enough for you?

Last edited by Element of Water : 04-08-2010 at 06:22 PM.
Element of Water is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 01:41 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services