Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (AndrewAMD, TipmyPip), 12,672 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 3
Page 1 of 8 1 2 3 4 5 6 7 8
Your own RESOURCE file without A6PRO edition #55025
09/15/05 18:43
09/15/05 18:43
Joined: Aug 2005
Posts: 1,185
Ukraine
Lion_Ts Offline OP
Serious User
Lion_Ts  Offline OP
Serious User

Joined: Aug 2005
Posts: 1,185
Ukraine
Hi !
Do you want to have your own easy managable resource? Or your funny small game eats about 200Mb on HDD but same game from competitor is 70Mb size? And you don't have 3DGS PRO edition?
With some restrictions I'll give it to you...

It's free, and it can be adjusted for your need by yourself .

But if you use this, you must provide credits in your game:

to Jean-loup Gailly and Mark Adler - www.zlib.org
to Gilles Vollant - www.winimage.com
to LionTs (Leonid Tsinitskiy) - www.lionts.com

Quote:


...
Condition of use and distribution are the same than zlib :
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
...





From the 3dgs manual:
Quote:


add_buffer(char* name,void* buffer)
Adds a named buffer to the engine file system. If the engine afterwards attempts to open a file with the given name, it reads out of the buffer rather than loading the file from the hard disk. This allows to add a user defined file resource system in an external language.




We have an idea...
And implementation (C++):
Code:

//Place this into sample.cpp in sdk
...
#include "unzip.h"
#include "iowin32.h"
const char *zipfilename="RESOURCE.ZIP\0";
...
int do_extract_currentfile(unzFile uf)
{
char filename_inzip[256];
char* filename_withoutpath;
char* p;
int err=UNZ_OK;
FILE *fout=NULL;
void* buf;
uInt size_buf;

unz_file_info file_info;
uLong ratio=0;
err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
if (err!=UNZ_OK) return err;
size_buf = file_info.uncompressed_size ;
buf = (void*)malloc(size_buf);
if (buf==NULL) return UNZ_INTERNALERROR;
p = filename_withoutpath = filename_inzip;
while ((*p) != '\0')
{
if (((*p)=='/') || ((*p)=='\\'))
filename_withoutpath = p+1;
p++;
}
//you can pass zip password for your resource
err = unzOpenCurrentFilePassword(uf,NULL);
err = unzReadCurrentFile(uf,buf,size_buf);
add_buffer(filename_withoutpath,buf);
unzCloseCurrentFile (uf);
//you have to return error code
//this is quick example, so I don't
//engine may crash if zip is errornous
return 0;
}


int do_extract(unzFile uf)
{
uLong i;
unz_global_info gi;
int err=UNZ_OK;
FILE *fout=NULL;

err = unzGetGlobalInfo (uf,&gi);
if (err==UNZ_OK) {
for (i=0;i<gi.number_entry;i++){
err = do_extract_currentfile(uf);
if ( err != UNZ_OK) break;
if ((i+1)<gi.number_entry){
err = unzGoToNextFile(uf);
if (err!=UNZ_OK) break;
}
}
}
return err;
}
DLLFUNC var add_zip_resource()
{
unzFile uf=NULL;
int err;
char* pass;
//you can pass resource name and password for zip archive from c-script
//this is quick example, so I don't
uf = unzOpen(zipfilename);
if (uf == NULL) return var(-1);
err = do_extract(uf);
unzClose(uf);
return var(err);
}


Needed files to compile project you can download from http://www.zlib.org
If you don't need to change my code or want to try it:
Place ZIPRES.DLL into your plugin folder. Create simple zip v2.0 (deflate method) archive with your models, images, sounds (without subdirs and password). Name it RESOURCE.ZIP and place into game folder.
In your c-script:
Code:

...
dllfunction add_zip_resource() var;
...
function main(){
if (add_zip_resource() != 0 ) {
...show message...
exit;
}
...


Somewhere in your code (it's example, provide your own resources & code):
Code:

...
entity* temp_entity;
bmap* temp_bmap;
...
temp_entity=ent_create("yor_model.mdl",temp_pos,temp_action);
temp_bmap=bmap_create("your_image.tga");
...
bmap_lock(temp_bmap,0);
...
ent_playloop (temp_entity, temp_sound, 100);
...


You can place into archive c-script files also, then load it and execute with console ( execute(STRING) ).
In small test level you'll can see, that WMB and MDL files loaded automatically, when level has been loaded.
To manage resources (add, remove,replace) you can use your archivator (WinRar, WinZip or alike, just don't forget to create .zip v2.0), not BIND... and 'File|Resource...'
All code tested and working well. Same technique I'm using in my game project (I don't have 3DGSpro, may be Conitec has one for free ? ).
And for last word, you may write your own archiving/encrypting methods, may be better than zlib. And use similar code to add buffers to engine file system.

That's all and thank you for reading my bad English.

Last edited by Lion_Ts; 09/15/05 18:54.
Re: Your own RESOURCE file without A6PRO edition [Re: Lion_Ts] #55026
09/15/05 22:25
09/15/05 22:25
Joined: Sep 2004
Posts: 1,214
Austin, Texas
Josh_Arldt Offline
Senior Developer
Josh_Arldt  Offline
Senior Developer

Joined: Sep 2004
Posts: 1,214
Austin, Texas
Nice contribution.
Thanks for sharing!

Re: Your own RESOURCE file without A6PRO edition [Re: Josh_Arldt] #55027
09/15/05 22:32
09/15/05 22:32
Joined: Jul 2003
Posts: 893
Melbourne, Australia
Matt_Coles Offline

User
Matt_Coles  Offline

User

Joined: Jul 2003
Posts: 893
Melbourne, Australia
extremely handy contribution, it won't let me download the test level, but the dll downloads fine, thanks Lion TS

Re: Your own RESOURCE file without A6PRO edition [Re: Matt_Coles] #55028
09/15/05 22:58
09/15/05 22:58
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Quote:

extremely handy contribution, it won't let me download the test level, but the dll downloads fine, thanks Lion TS




The same!

Thanks a lot!

Re: Your own RESOURCE file without A6PRO edition [Re: Pappenheimer] #55029
09/16/05 07:29
09/16/05 07:29
Joined: Mar 2004
Posts: 564
Richmond, BC, Canada
Calined Offline
User
Calined  Offline
User

Joined: Mar 2004
Posts: 564
Richmond, BC, Canada
so now its possible to encrypt the data in a single file so that noone can steal the data?(for example) without the pro?


take a listen on my Portfolio Site
Re: Your own RESOURCE file without A6PRO edition [Re: Calined] #55030
09/16/05 08:12
09/16/05 08:12
Joined: Oct 2002
Posts: 799
Germany->Bavaria->Nuremberg
C
Christian__A Offline
User
Christian__A  Offline
User
C

Joined: Oct 2002
Posts: 799
Germany->Bavaria->Nuremberg
maybe i didnt see that, but is it possible to set a password for the .zip-file ?
otherwise everybody would be able to open the .zip and get everything he wants...

i will test this soon. thank you for sharing it!


MfG, Christian__A. Visit my Site: www.chris-a.de


Re: Your own RESOURCE file without A6PRO edition [Re: Christian__A] #55031
09/16/05 08:21
09/16/05 08:21
Joined: Mar 2004
Posts: 564
Richmond, BC, Canada
Calined Offline
User
Calined  Offline
User

Joined: Mar 2004
Posts: 564
Richmond, BC, Canada
quote sourcecode:

//you can pass zip password for your resource err = unzOpenCurrentFilePassword(uf,NULL); err = unzReadCurrentFile(uf,buf,size_buf); add_buffer(filename_withoutpath,buf); unzCloseCurrentFile (uf);//you have to return error code//this is quick example, so I don't//engine may crash if zip is errornous return 0;

/quote

maybe this is what you are looking for...
dunno*shrug*


take a listen on my Portfolio Site
Re: Your own RESOURCE file without A6PRO edition [Re: Christian__A] #55032
09/16/05 10:45
09/16/05 10:45
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Quote:

maybe i didnt see that, but is it possible to set a password for the .zip-file ?
otherwise everybody would be able to open the .zip and get everything he wants...

i will test this soon. thank you for sharing it!




yes. See Source above.

Re: Your own RESOURCE file without A6PRO edition [Re: FBL] #55033
09/16/05 11:11
09/16/05 11:11
Joined: Aug 2005
Posts: 1,185
Ukraine
Lion_Ts Offline OP
Serious User
Lion_Ts  Offline OP
Serious User

Joined: Aug 2005
Posts: 1,185
Ukraine
Hi!
I'm confused with 3dgs...
In manual described functions:
- ent_create
- bmap_create
- snd_create
With third I have problem: sound* give to me an errror while interpreted by engine (yes, sound* not recognized by engine as type, so snd_create from help is useless). I change code to:
Code:

function* temp_snd; //it's a pointer to a byte (like void*)
...
temp_snd=snd_create("temp.wav");
...


All ok. It's worked, when "temp.zip" is presented in game dir. But when I place "temp.wav" to zipped resource, engine says "format or device unavailable". Can somebody to think about it with me ?
Oh, I'm using GS Commercial v6.31.4 / WED v6.259 (as reported by WED).

Re: Your own RESOURCE file without A6PRO edition [Re: Matt_Coles] #55034
09/16/05 11:25
09/16/05 11:25
Joined: Aug 2005
Posts: 1,185
Ukraine
Lion_Ts Offline OP
Serious User
Lion_Ts  Offline OP
Serious User

Joined: Aug 2005
Posts: 1,185
Ukraine
Quote:

extremely handy contribution, it won't let me download the test level, but the dll downloads fine, thanks Lion TS



I can't download example too
It's a free hosting, may be file size big (1.7Mb) ?
I'll try to correct this.
If can't correct:
I get the AUM example "skinc" (board game with sceleton), publish it, put all *.mdl and *.wmb to .zip and delete it from published game. That's all. When level has been loaded, all needed mdl/wmb loaded automatically.

Last edited by Lion_Ts; 09/16/05 11:46.
Page 1 of 8 1 2 3 4 5 6 7 8

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1