• What are you working on? December 2011 Edition
    3,353 replies, posted
[QUOTE=raBBish;33751217]To add to the discussion; C++11 (well, Technical Report 2 to be exact) has filesystem from Boost in the standard. Although so far only MSVC11 supports it, not g++ or others. It's cross-platform but other platforms just haven't implemented it yet :v:[/QUOTE] Tried googling for more info, but couldn't find anything. Care to point me in the right direction?
[QUOTE=thomasfn;33752627]One might say that he's a dickhead.[/QUOTE] [IMG]http://i.imgur.com/oPj2F.png[/IMG]
So my artist needs to make the art actually movable and whatnot in-game. But instead, this is how he spends his time: [media]http://www.youtube.com/watch?v=53w7dxeL7Pw[/media]
[QUOTE=DuCT;33752974]Tried googling for more info, but couldn't find anything. Care to point me in the right direction?[/QUOTE] [url]http://www.boost.org/doc/libs/1_48_0/libs/filesystem/v3/doc/index.htm[/url] [quote]A proposal, N1975, to include Boost.Filesystem in Technical Report 2 has been accepted by the C++ Standards Committee. That proposal was based on version 2 of Boost.Filesystem; presumably the final TR2 form will be based on version 3.[/quote] Said proposal: [url]http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1975.html[/url] More about TR2: [url]http://en.wikipedia.org/wiki/C%2B%2B_Technical_Report_1#Technical_Report_2[/url] e: MSVC11 including it: [url]http://msdn.microsoft.com/en-us/library/hh409293(v=vs.110).aspx[/url] [quote]Support for new headers <atomic>, <chrono>, <condition_variable>, [b]<filesystem>[/b], <future>, <mutex>, <ratio>, and <thread>.[/quote]
[QUOTE=Overv;33752515][cpp]// Headers #include <iostream> #include <fstream> int main( int argc, const char* argv[] ) { // Show usage info if ( argc != 3 ) { std::cerr << "Usage: bin2array <input.bin> <output.hpp>" << std::endl; return 1; } // Read binary std::ifstream binFile ( argv[1], std::ios::binary | std::ios::ate ); if ( !binFile.is_open() ) { std::cerr << "Failed to open input binary!" << std::endl; return 1; } std::streamsize length = binFile.tellg(); binFile.seekg( 0, std::ios::beg ); char* data = new char[length]; binFile.read( data, length ); binFile.close(); // Write header with output array std::ofstream outFile( argv[2] ); if ( !outFile.is_open() ) { std::cerr << "Failed to open output file!" << std::endl; return 1; } outFile << "unsigned char data[] = {"; for ( unsigned long i = 0; i < length; i++ ) { if ( i % 5 == 0 ) outFile << "\n\t"; outFile << (int)data[i]; if ( i < length - 1 ) outFile << ", "; } outFile << "\n}"; return 0; }[/cpp] [url=http://hosting.overvprojects.nl/bin2array.exe]Binary[/url][/QUOTE] I prefer my tools on the web ;0 [url]http://tool.garry.tv/bin2c/[/url] (untested as of yet)
[QUOTE=raBBish;33753083][url]http://www.boost.org/doc/libs/1_48_0/libs/filesystem/v3/doc/index.htm[/url] Said proposal: [url]http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1975.html[/url] More about TR2: [url]http://en.wikipedia.org/wiki/C%2B%2B_Technical_Report_1#Technical_Report_2[/url] e: MSVC11 including it: [url]http://msdn.microsoft.com/en-us/library/hh409293(v=vs.110).aspx[/url][/QUOTE] Cool, thanks.
Can do it very easily with notepad++, a hex editor and regex. [img]http://goo.gl/dTdmf[/img] Copy to your clipboard the number you want per line * 6. [img]http://goo.gl/wEjhV[/img] [code] unsigned char Data[] = { 0x03, 0x01, 0xCC, 0xF4, 0x16, 0x80, 0x00, 0x07, 0x02, 0xDD, 0x39, 0xC9, 0xA4, 0xD0, 0xA6, 0x70, 0x7F, 0x62, 0xB4, 0x3A, 0x80, 0x6C, 0x25, 0x5F, 0xAE, 0x05, 0x94, 0xBD, 0xBC, 0x26, 0x33, 0xB3, 0x76, 0x8A, 0x30, 0x11, 0x35, 0x63, 0xC8, 0x92, 0x80, 0x48, 0xB1, 0xA3, 0x72, 0x34, 0xDF, 0xE1, 0x8F, 0x18, 0xE6, 0x8F, 0xF1, 0x70, 0x1A, 0x5A, 0x82, 0x32, 0xFA, 0xAC, 0x92, 0x31, 0x22, 0x31, 0x0A, 0x37, 0xFF, 0x98, 0x06, 0x53, 0xFB, 0x21, 0x8C, 0x64, 0x89, 0x94, 0x49, 0x9A, 0xED, 0xC6, 0x07, 0x8A, 0x94, 0xB9, 0x33, 0xF3, 0xD1, 0x50, 0x93, 0x91, 0x62, 0x15, 0x8A, 0xDE, 0x11, 0x97, 0x57, 0xCB, 0xD4, 0x07, 0xEA, 0x5A, 0x4F, 0xE6, 0xBD, 0x44, 0xE7, 0x05, 0x0E, 0x31, 0x7E, 0x5C, 0xA3, 0x09, 0x0E, 0x32, 0x62, 0x0F, 0x41, 0x1D, 0xD0, 0x07, 0x8A, 0xA4, 0xD0, 0xF9, 0x96, 0x97, 0xF0, 0x18, 0x37, 0x47, 0x0F, 0x26, 0x4D, 0x49, 0xA5, 0xAC, 0x4D, 0xD9, 0xB4, 0x34, 0xAF, 0x6B, 0x97, 0xB4, 0x77, 0x79, 0x3E, 0xCD, 0xDA, 0xB9, 0xE1, 0xE7, 0x23, 0xA0, 0x20, 0xF8, 0x52, 0x81, 0xB1, 0xF1, 0xCF, 0xCF, 0x4B, 0x82, 0x3B, 0x3E, 0xD6, 0x88, 0x04, 0x8F, 0x7B, 0x79, 0x09, 0x63, 0xEC, 0xB0, 0x2F, 0xF1, 0xA3, 0x60, 0x3B, 0x7F, 0xC5, 0x14, 0x78, 0x56, 0x54, 0x63, 0xFC, 0x4E, 0x1D, 0x95, 0xCA, 0xB3, 0xC3, 0x53, 0x91, 0x3F, 0x5B, 0xCF, 0xAF, 0xB1, 0xE6, 0x72, 0xBE, 0x58, 0xBB, 0xC5, 0xB1, 0x2E, 0xD8, 0x56, 0x10, 0xD6, 0x84, 0xF2, 0xA6, 0x97, 0xAE, 0x0D, 0x81, 0x9E, 0x7C, 0xA8, 0x19, 0xA8, 0x07, 0xE0, 0xC8, 0x03, 0xA7, 0x76, 0xEA, 0x03, 0xEB, 0xE8, 0x77, 0x2D, 0x09, 0x4B, 0xF0, 0x90, 0x8D, 0xF0, 0x5E, 0xA8, 0x3E, 0x4D, 0x15, 0x02, 0xB1, 0x32, 0x28, 0x33 };[/code]
Hey that's so much easier than pressing a button on a website!
[QUOTE=garry;33753704]Hey that's so much easier than pressing a button on a website![/QUOTE] Let me just upload a 50MB binary file to download it again in text form
[QUOTE=garry;33753704]Hey that's so much easier than pressing a button on a website![/QUOTE] Never said it was. Was just showing what you can do with notepad++, regex and a hex editor.
[QUOTE=garry;33753704]Hey that's so much easier than pressing a button on a website![/QUOTE] Your tool lacks re-usability and flexibility though, and I can honestly say that I've never had the need for a utility like that. So his solution is actually pretty slick, if you compare effort and flexibility.
[QUOTE=Overv;33752515][cpp]// Headers #include <iostream> #include <fstream> int main( int argc, const char* argv[] ) { // Show usage info if ( argc != 3 ) { std::cerr << "Usage: bin2array <input.bin> <output.hpp>" << std::endl; return 1; } // Read binary std::ifstream binFile ( argv[1], std::ios::binary | std::ios::ate ); if ( !binFile.is_open() ) { std::cerr << "Failed to open input binary!" << std::endl; return 1; } std::streamsize length = binFile.tellg(); binFile.seekg( 0, std::ios::beg ); char* data = new char[length]; binFile.read( data, length ); binFile.close(); // Write header with output array std::ofstream outFile( argv[2] ); if ( !outFile.is_open() ) { std::cerr << "Failed to open output file!" << std::endl; return 1; } outFile << "unsigned char data[] = {"; for ( unsigned long i = 0; i < length; i++ ) { if ( i % 5 == 0 ) outFile << "\n\t"; outFile << (int)data[i]; if ( i < length - 1 ) outFile << ", "; } outFile << "\n}"; return 0; }[/cpp] [url=http://hosting.overvprojects.nl/bin2array.exe]Binary[/url][/QUOTE] Try pasting this into a bash shell (mingw if you're on windows): [release]echo $'Hello World!'>file.bin && echo $'\nConverting file.bin into an object file..' && echo $'.global _len\n.global _my_file\n _my_file:\n__file_start=.\n.incbin \"file.bin\"\n__file_len=.-_my_file\n_file:\n.long __file_start\n_len:\n.int __file_len' | as --msyntax=intel -o file.o && echo $'Object file now contains the symbols: \n' && nm file.o && echo $'\nNow compiling and running executable..\n' && echo $'#include <stdio.h>\nextern const char my_file[]; extern const unsigned int len; int main() { printf("Hi!, I am executable!\\n\\nThe length of my file is %u bytes.\\nAnd it contains: ", len); for (unsigned int i = 0; i < len; i++){putchar(my_file[i]); fflush(stdout);} return 0; }' | gcc -o test -x c --std=c99 -Wl,file.o - && ./test [/release] [editline]16th December 2011[/editline] [IMG]http://dl.dropbox.com/u/27714141/Hi%21.png[/IMG]
[QUOTE=Dotmister;33753765]Let me just upload a 50MB binary file to download it again in text form[/QUOTE] Hey let me copy and paste text from notepad++ containing 52,428,800 numbers and 52,428,800 commas. The file would be at least 100mb. You're gonna include that in your project?
[QUOTE=garry;33754159]Hey let me copy and paste text from notepad++ containing 52,428,800 numbers and 52,428,800 commas. The file would be at least 100mb. You're gonna include that in your project?[/QUOTE] If you are putting that into a cpp file you are doing something wrong.
i have a job interview at a software developer that is 15 minutes away from my home, and apparently they're a pretty successful company woo :>
Huzzah! Apparently my client is extremely enthusiastic about my progress report. :v: [quote]thank you so much for the status report, i'm extremely enchanted of how things are going, i will announce the team and sponsors here, and i'm very glad that step by step the vp8 implementation takes shape[/quote] [editline]16th December 2011[/editline] [QUOTE=Kopimi;33754350]i have a job interview at a software developer that is 15 minutes away from my home, and apparently they're a pretty successful company woo :>[/QUOTE] Good luck!
[QUOTE=high;33754176]If you are putting that into a cpp file you are doing something wrong.[/QUOTE] Exactly??? Anyway - it works. [url]http://holly.googlecode.com/svn-history/r32/trunk/trunk/examples/EmbeddedSoundFile.hpp[/url] [vid]http://puu.sh/aNCq[/vid]
[QUOTE=garry;33754723]Exactly??? Anyway - it works. [url]http://holly.googlecode.com/svn-history/r32/trunk/trunk/examples/EmbeddedSoundFile.hpp[/url] [url]http://puu.sh/aNCq[/url][/QUOTE] Isn't that exactly what embedded resources are for?
[vid]http://dl.dropbox.com/u/11093974/Junk/yay_VP8.webm[/vid] A little laggy due to the recorder.
[QUOTE=jalb;33754997][vid]http://dl.dropbox.com/u/11093974/Junk/yay_VP8.webm[/vid] A little laggy due to the recorder.[/QUOTE] What a pretty UI
[CODE] public struct CustomType { public int x; public int y; public int z; public override string ToString() { return string.Format("{0} {1} {2}", x, y, z); } } public class PacketHello : Packet { public string name; public long x; public float shit; public double precise; public int y; public short z; public byte id; public bool isnetawesome; public CustomType custom; }[/CODE] + [CODE] static void Main(string[] args) { PacketHello c = new PacketHello(); c.name = "fp :D"; c.x = 1234; c.shit = 0.578f; c.precise = 0.5; c.y = -50; c.z = 1200; c.id = 2; c.isnetawesome = true; c.custom = new CustomType() { x = 1, y = 1234, z = -1 }; byte[] data = c.GetPacketData(); PacketHello b = Packet.GetPacket<PacketHello>(new MemoryStream(data)); foreach (FieldInfo field in typeof(PacketHello).GetFields()) { Console.WriteLine(field.GetValue(c) + "\t\t" + field.GetValue(b)); } Console.ReadLine(); }[/CODE] = [IMG]http://dl.dropbox.com/u/44710267/awesome.png[/IMG] .NET is so amazing <33333
[QUOTE=Robber;33754873]Isn't that exactly what embedded resources are for?[/QUOTE] Are they cross platform?
Fun Fact: Garrys posts makes each page 200(numPosts / numPostsGarry) percent higher
[QUOTE=eloreda;33755112][CODE] public struct CustomType { public int x; public int y; public int z; public override string ToString() { return string.Format("{0} {1} {2}", x, y, z); } } public class PacketHello : Packet { public string name; public long x; public float shit; public double precise; public int y; public short z; public byte id; public bool isnetawesome; public CustomType custom; }[/CODE] + [CODE] static void Main(string[] args) { PacketHello c = new PacketHello(); c.name = "fp :D"; c.x = 1234; c.shit = 0.578f; c.precise = 0.5; c.y = -50; c.z = 1200; c.id = 2; c.isnetawesome = true; c.custom = new CustomType() { x = 1, y = 1234, z = -1 }; byte[] data = c.GetPacketData(); PacketHello b = Packet.GetPacket<PacketHello>(new MemoryStream(data)); foreach (FieldInfo field in typeof(PacketHello).GetFields()) { Console.WriteLine(field.GetValue(c) + "\t\t" + field.GetValue(b)); } Console.ReadLine(); }[/CODE] = [IMG]http://dl.dropbox.com/u/44710267/awesome.png[/IMG] .NET is so amazing <33333[/QUOTE] If you're using reflection to (de)serialize packet data, just keep in mind you cannot rely on the order of the fields or properties. [url]http://msdn.microsoft.com/en-us/library/ch9714z3.aspx[/url] [quote] The GetFields method does not return fields in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which fields are returned, because that order varies. [/quote]
[QUOTE=synthiac;33755940]wow check out this awesome feature i found in my hex editor [code]unsigned char rawData[26] = { 0x20, 0x03, 0x77, 0x88, 0xD6, 0x4E, 0xCF, 0xC7, 0x7F, 0x4A, 0xEF, 0x69, 0x4F, 0xAD, 0xD3, 0xED, 0x8C, 0x83, 0xBD, 0x1F, 0xD8, 0xC7, 0x7D, 0xD3, 0x50, 0xF5 }; [/code][/QUOTE] Vim? [editline]17th December 2011[/editline] Wow, I've never been so angry at people reinventing the wheel poorly because they don't want to use a fucking library that's been designed, thought about and properly programmed to be cross platform. Unix uses UTF-8 paths, Windows uses UTF-16 paths. How the fuck are you going to have Unicode paths now? In fact, this infuriates me: [QUOTE=DevBug;33751874]I'm going to have to side with Dajoh on this one: 1. It's a learning experience 2. The API will match your naming/coding conventions 3. Dependencies. This is especially important to me, probably less so to non-purists. 4. Licenses. God damn licenses. However, there is no need to roll your own for everything. Except boost, because fuck boost.[/QUOTE] 1. Good. 2. So fucking what? Are you going to rewrite everything simply because it doesn't fit your conventions? 3. What's so bad about dependencies? 4. Boost can be used in commercial products with no cost, have you even read its 10 line long license? Fuck Boost? Why? I'm going to go out on a limb here and say that Facepunch suffers from a good amount of [url=http://en.wikipedia.org/wiki/Not_Invented_Here]Not Invented Here[/url] syndrome. I'm not trying to start a flame war, but it's just so frustrating to see people go down the same path where I spent 3 years trying to write a game engine from scratch, restarting multiple times, just to look at it what I had: Half a filesystem abstraction layer that was Unix only and horrible to use. Using third party libraries helps things immensely, and yes, there's a time when they don't fit your needs, but this isn't one of them.
[QUOTE=synthiac;33755991]no, some shitty freeware hex editor called hxd.[/QUOTE] Vim's xxd tool does exactly that, it can also be used as a hex editor in Vim.
[QUOTE=VoiDeD;33755926]If you're using reflection to (de)serialize packet data, just keep in mind you cannot rely on the order of the fields or properties. [url]http://msdn.microsoft.com/en-us/library/ch9714z3.aspx[/url][/QUOTE] Thanks but I'm using [CODE]foreach (FieldInfo field in thisType.GetFields().OrderBy((x) => x.MetadataToken))[/CODE]
I'm still working on my game framework (it's not really an engine) since I'll be using it for LD. It can now load (and display) sprites and sounds. There's not a lot to show since it's just ugly programmer art for testing if everything works properly. [QUOTE=garry;33755119]Are they cross platform?[/QUOTE] I have no idea. :v: But I would be surprised if they weren't. [QUOTE=VoiDeD;33755926]If you're using reflection to (de)serialize packet data, just keep in mind you cannot rely on the order of the fields or properties. [url]http://msdn.microsoft.com/en-us/library/ch9714z3.aspx[/url][/QUOTE] Keep in mind that reflection is slow as fuck though. I'm not saying don't use, but don't use it when performance is critical and it doesn't make something a LOT easier.
Oh, wow, just waking up. Yeah, resources are Windows-only. But you didn't have to invent bin2c. There's [url=http://www.deadnode.org/sw/bin2h/]Bin2h[/url] and Vim's [url=http://linuxcommand.org/man_pages/xxd1.html]xxd[/url] utility.
I'm not denying that there's alternatives. I'm just saying that there's now one more.
Sorry, you need to Log In to post a reply to this thread.