Eddy999999

Members
  • Content count

    145
  • Joined

  • Last visited

Community Reputation

134 Neutral

About Eddy999999

  • Rank
    Member
  1. Hack Wars Beta

    Wow, sounds like an awesome game, I'm checking it out right now. It reminds me of a game I played a long time ago, called SlaveHack, which I don't think exists anymore, except this sounds a lot more in-depth.
  2. help with questions on editer plz

    Quote:Original post by craigie Cough excuse me ? who use who's ideas? YOU use THEIR ideas. All of the design of the game was made by Nintendo, and you're talking about using everything they've worked to create except for the story itself. You DO know there's more to a game than the story, right? It's not a book...
  3. websites

    Try W3Schools to learn about actually coding a website. For free hosting, a good place to start is Freehostia.
  4. Lua Classes - Method not Defined?

    Figured out what the problem was. I needed to do UIElement_mt.__index=UIElement This topic can be deleted now.
  5. I'm trying to implement a simple class in Lua, but I'm getting the following error when I try to access a method of a class: data/lua/startup.lua:11: attempt to call method 'LoadBG' (a nil value) I can't seem to figure out what I am doing wrong. From what I can tell, I am defining everything in the same way as it shown here, but I'm getting that error. Here's my relative code: --c_UIElement.lua UIElement={} UIElement_mt={} function UIElement:create(posX,posY,width,height,parentEle) -- Create the new instance of the UIElement local new_inst={ pointer=UIElement_Create(posX,posY,width,height,parentEle), x=posX, y=posY, w=width, h=height, parent=parentEle, bg="", border="" } setmetatable(new_inst,UIElement_mt) -- Set the metatable for the UIElement return new_inst end --Load the background for the element from filename function UIElement:LoadBG(filename) UIElement_LoadBG(self.pointer,filename) end --Set the border for the element function UIElement:SetBorder(border) UIElement_SetBorder(self.pointer,border) end UIElement_mt.__metatable=false UIElement_mt.__newindex=function(ele,key,value) error("Invalid index: \"" + key + "\"") end --startup.lua dofile("data/lua/c_UIElement.lua") ele=UIElement:create(10,10,120,100,nil) ele:LoadBG("images/ui/bg.png") ele:SetBorder("wood") Help please? I'm still pretty new to Lua, so it's probably just something stupid that I forgot. EDIT: Darn, no source tags for Lua?
  6. C++ Inputting Integer from Pythons Pack()

    Nevermind, I got it. Here's my code though, in case you know of an easier way to do it: int getResource(string resname, string filename, string *result) { unsigned char *temp=new unsigned char(); char *numfiles=new char[4]; unsigned long curpos; //Running total for the current file position vector<unsigned long> filepos; //A vector containing the positions of each file within the resource file ifstream resfile; resfile.open(resname.c_str(),ios::in | ios::binary); //Open the file //Get the number of files contained in the resource file resfile.read(numfiles,4); cout << "Number of files: " << (int)*numfiles << "\n"; //Get the positions of all of the files within the resource file //And store them in the filepos vector for (int i=0; i<(int)*numfiles; i++) { cout << "Getting position of file number " << i << "\n"; curpos=0; for (int j=0; j<4; j++) { resfile.read((char*)temp,1); curpos+=(unsigned long)*temp * (unsigned long)pow(256.0,j); } cout << " position: " << curpos << "\n"; } return 0; }
  7. C++ Inputting Integer from Pythons Pack()

    Now I have a new problem: I can't get any values above 255. For example, if I store a value of 300, then when I try to get it in my C++ program, I get a value of 44 (300-256). I'm assuming this has something to do with the fact that there are only 256 ASCII values, but I'm not sure how to fix it... EDIT: If I read the bytes one by one, for the value 300, for example, I get 44 1 0 0. So I can obviously multiply the second byte by 256^1, the third by 256^2, and the fourth by 256^3, and add them all up. Is this the easiest and/or most efficient way to do it? [Edited by - Eddy999999 on March 7, 2008 9:55:58 PM]
  8. C++ Inputting Integer from Pythons Pack()

    I actually originally had allocated for four bytes, and used the binary flag, but I changed it when I was trying other things, and I forgot to change it back when I posted the code. Anyways, the problem was that I was outputting the value of temp, rather than what was stored at the address, as you stated. I'm just so used to not having to use the indirection operator when outputting char pointers that I didn't put it there when I changed it to an int value. Thanks =D
  9. I have a tool which I made in Python to compress a bunch of files in a directory into a single resource file. The very first 4 bytes of the file is an integer telling how many files are contained in the resource file. In my Python tool, I wrote the integers to the file using Pythons struct.pack() method, but I'm having trouble reading the number from my game, which is written in C++. I though I could just use ifstream.read() to read the first 4 bytes from the file, and convert it to an integer, but when I tested it with a sample resource file (named python.res), the ouput was 3624856, when it should have been 12. Here's my function: /* Retrieves a compressed file from a resource file resname - The name of the resource file to access filename - The name of the file within the resource file result - The string to place the file into Return - Negative values indicate errors */ int getResource(string resname, string filename, string *result) { char *temp=new char(); ifstream resfile; resfile.open(resname.c_str(),ios::in); //Open the file //Read the first four bytes of the file, and output the resulting integer resfile.read(temp,4); cout << temp << "\n" << (unsigned int)temp; return 0; } Also, I'm almost positive the output to the file is correct, because I have been able to write a program (also in python) to unpack the files, which works perfectly. Does anyone know why I am getting a different number in my C++ program? Thanks in advance, -Eddy
  10. Zlib Compression Help

    After minimal tweaking, the code you gave me works. Thanks a ton =D
  11. Zlib Compression Help

    I'm continuing this from my other thread since it's starting to get (more than) a bit off topic from what I was originally asking. I'm trying to implement some basic compression/decompression in my game using zlib. I want to create a couple functions like this which simply take pointers to strings as arguments, and (de)compress the source string, and place the result into the destination string, then return any errors. My code compiles and runs, but when I run it, I don't get the desired output. Once the string has been compressed and then uncompressed, the uncompressed string is the original string followed by a bunch of characters, and I get the zlib error code Z_DATA_ERROR. I have no idea what I'm doing wrong. Here's the code that I have so far: #include "zlib.h" #include <stdio.h> #include <string> #include <iostream> #include <fstream> #include <sstream> using namespace std; int CompressString(string *source, string *destination) { //Define the source, destination, source length, and destination length char *src=(char*)source->c_str(); int srcLen=strlen(src); int destLen=compressBound(srcLen); char *dest=new char[destLen]; //Decompress the string in src and place it in dest int result=compress((unsigned char *)dest,(uLongf*)&destLen,(const unsigned char *)src,srcLen); //Return the results of the compression string resultStr(dest); *destination=resultStr; delete dest; return(result); } int DecompressString(string *source, string *destination, int destLen) { //Define the source, destination, source length, and destination length char *src=(char*)source->c_str(); int srcLen=strlen(src); char *dest=new char[destLen]; //Decompress the string in src and place it in dest int result=uncompress((unsigned char *)dest,(uLongf*)&destLen,(const unsigned char *)src,srcLen); //Return the results of the decompression string resultStr(dest); *destination=resultStr; delete dest; return(result); } int main(int argc, char *argv[]) { //Define the needed variables string src="bla bla bla lorum ipsum this is a test string yadda yadda yadda, etc. etc."; string compressed; string decompressed; int result; //Compress the string, and output the results cout << "Compressing string: " << src.c_str() << "\n"; result=CompressString(&src,&compressed); cout << "Error code: " << result << "\n"; cout << "Compressed String: " << compressed.c_str() << "\n\n"; //Decompress the string, and output the results cout << "Decompressing String: " << compressed.c_str() << "\n"; result=DecompressString(&compressed,&decompressed,src.length()); cout << "Error code: " << result << "\n"; cout << "Decompressed String: " << decompressed.c_str() << "n\n"; } Here's the output I'm getting: Compressing string: bla bla bla lorum ipsum this is a test string yadda yadda yadda, etc. etc. Error code: 0 Compressed String: x£K╩ITHéΓ£ⁿó╥\à╠éb YÆæY¼ Decompressing String: x£K╩ITHéΓ£ⁿó╥\à╠éb YÆæY¼ Error code: -3 Decompressed String: bla bla bla lorum ipsum this══════════════════════════════ ════════════════²²²²▌▌↕n Error code -3 is Z_DATA_ERROR. The website states that: Quote:uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, or Z_DATA_ERROR if the input data was corrupted. I don't see anywhere in my code where the compressed data could become corrupted. If anyone could please help me out, it would be greatly appreciated.
  12. Phun - a 2D physics playground

    Quote:Original post by emilk Quote:Original post by Eddy999999 I'm still getting a runtime error: ... 10:54:29: Reloading N9rendering7TextureE [/code] Try beta 3.12 from my home page, I have a feeling it will fix your problem. - Emil Well, it works now, but it runs extremely slow. Is this just because of my computer? Here are my specs again: Windows XP Professional Edition SP2 AMD Athlon XP 2800+ 2.13GHz 768MB RAM NVIDIA GeForce MX 4000
  13. C++/Python Compression

    Well, it's almost working. However, when I try to decompress the data that I've compressed, it comes out with the original string followed by a bunch of "╠" characters, and it gives a Z_DATA_ERROR. Here's the code: //Compress program #include "zlib.h" #include <stdio.h> #include <string> #include <iostream> #include <fstream> unsigned long CompressData(const char *source, unsigned int sourceSize, char *destination) { // This will hold the size of the compressed data unsigned long dsize; // Compress everything from source to destination int result = compress((unsigned char *)destination, &dsize, (const unsigned char *)source, sourceSize); // Check result for errors if( result != Z_OK ) { std::cout << "Error occured!"; } // ... do something ... // Return the size of the compressed data return( dsize ); } int main(int argc, char *argv[]) { char *src="test string..."; char dest[1024]; std::cout << "Compressing string " << src << "\n"; CompressData(src,strlen(src),(char*)&dest); std::cout << dest; } //Decompress program #include "zlib.h" #include <stdio.h> #include <string> #include <iostream> #include <fstream> unsigned long DecompressData(const char *source, unsigned int sourceSize, char *destination) { // This will hold the size of the compressed data unsigned long dsize; // Compress everything from source to destination int result = uncompress((unsigned char *)destination, &dsize, (const unsigned char *)source, sourceSize); // Check result for errors if( result != Z_OK ) { std::cout << "Error occured! Error code: " << result << "\n"; } // ... do something ... // Return the size of the compressed data return( dsize ); } int main(int argc, char *argv[]) { char *src="test string..."; char dest[1024]; std::cout << "Decompressing string " << src << "\n"; DecompressData(src,strlen(src),(char*)&dest); std::cout << dest; }
  14. C++/Python Compression

    I'm not trying to deal with files, just the only example I could find dealt with files, so I was trying to work from there. I saw the functions you posted in the manual, but as I said above, I don't really know much about streams, so I have no idea how to actually use the functions. I also don't know what most of those data types mean. For example, I know what bytes and long integers are, but what's special about the Bytef and uLongF data types. I guess I just need some samples to look at to fully understand exactly how to actually use the functions, because right now it's Greek to me, since I simply don't understand a lot of the terms/data types used. P.S. And before you try to say I'm lazy and just want to be spoon fed, I've been working on this pretty much all day, and part of last night, searching google, reading through documentation, etc. and so far it just hasn't clicked... EDIT: After reading through the documentation a bit more, it's starting to make a bit more sense. The biggest question I have now is what is the Bytef datatype? I'm gathering it's a stream of some type, but what's different about it? Also, how can I convert a string to a Bytef and vice versa? [Edited by - Eddy999999 on March 2, 2008 10:15:21 PM]
  15. C++/Python Compression

    I got the example working, and since noone has offered any input, I figured I'd try to mess with it to try to make it read/write strings instead of files. To start with, I'm trying to make the compression function compress a string into a file. Here's the original compression function: int ZlibEngine::compress( const char *input, const char *output, int level ) { err = Z_OK; avail_in = 0; avail_out = output_length; next_out = output_buffer; m_AbortFlag = 0; fin = fopen( input, "rb" ); fout = fopen( output, "wb" ); length = filelength( fileno( fin ) ); deflateInit( this, level ); for ( ; ; ) { if ( m_AbortFlag ) break; if ( !load_input() ) break; err = deflate( this, Z_NO_FLUSH ); flush_output(); if ( err != Z_OK ) break; progress( percent() ); } for ( ; ; ) { if ( m_AbortFlag ) break; err = deflate( this, Z_FINISH ); if ( !flush_output() ) break; if ( err != Z_OK ) break; } progress( percent() ); deflateEnd( this ); if ( m_AbortFlag ) status( "User Abort" ); else if ( err != Z_OK && err != Z_STREAM_END ) status( "Zlib Error" ); else { status( "Success" ); err = Z_OK; } fclose( fin ); fclose( fout ); fin = 0; fout = 0; if ( m_AbortFlag ) return Z_USER_ABORT; else return err; } I'm not too familiar with streams and such, but I'm thinking that I just need to make fin contain the string I want, rather than the data from a file. However, I believe it still has to be the FILE type. So I tried changing fin = fopen( input, "rb" ); to fin=tmpfile(); fputs("teststring...",fin); Which compiles and runs fine, but it doesn't give the expected output. After the compression function runs, and the file is decompressed again, instead of containing "teststring...", the output file contains about 4kb of the character Í. Once again, I don't know much about streams or anything, so if anyone could please help me out, it would be greatly appreciated. Also, if anyone needs the full code for the ZlibEngine class, I can post it (or you can download it from the page I posted above).