• Register

I am a programmer, and one of the 3 founders of mionet. Mionet is a small site intended for indie game dev and discussion. I hope to be able to contribute a lot to the indie game dev scene in the coming years.

RSS My Blogs

Recoding is good

miotatsu Blog

Yesterday I began work on the Player Creation screen for Meiro and I knew that I needed to switch the state to it if the player presses enter when a file of the name "New Player" is selected. At the time the file names were loaded into arrays and manipulated like plain raw memory, I did not append a null character at the end of the names but instead a newline and so I was not able to use c-string related functions. Because of this I had implemented some of that functionality specifically for my newline terminated version of a string. I had done all this early on and did not realize at the time that it was a terrible idea and the features that were available in the cstring library. So I was writing code to check if the name was "New Player" and while doing so I realized my cArraylen function (my equivalent of strlen) was not returning the correct size. I decided to cout each array after it was loaded into memory to see that it was loading them correctly and discovered that in fact it was not. It is a miracle (or rather a curse) that those bugs did not show themselves much earlier. I decided it would be easier to recode the state from scratch than to try to fix all those bugs.
Today I did just that. The original .cpp file for the save selection state was 1100 lines, was extremely inefficient, and as I already explained - very buggy. It also took me 2 months to write (on and off). This new implementation took me one day to write, is readable, and only 396 lines. I rewrote it from scratch and so a lot of things changed, especially with the rendering. The notable change relating to this post is how I went about handling the file names. This time around I steered away from raw memory (as well as c-strings) and loaded them into std::strings. I think this experience really goes to show how much I am learning from coding meiro. Next up I will be working on the player creation screen however I am going to be on vacation until Tuesday (I think) and won't have internet until I am back, so I won't be able to keep you guys updated on the progress.

for those interested here is the recoded version of my file loading:
char delim = 0x0A;
inFile.open("data/DAT_000.dat", std::ios::in|std::ios::binary|std::ios::ate);
if (inFile.is_open())
{
Filesize = inFile.tellg();
array = new char[Filesize];
inFile.seekg (0, std::ios::beg);
inFile.read (array, Filesize);
inFile.close();
for (int i = 0; i < Filesize; i++){
if (array[i]!= 0x0A && array[i]!= 0)
array[i]= array[i]+ 31; //my "encryption" is simply to subtract 31 from each char
}
outFile.open("data/TMP_000.txt", std::ios::out);
outFile.write(array, Filesize);
outFile.close();
inFile.open("data/TMP_000.txt", std::ios::in);
std::getline(inFile, sFile1, delim);
std::getline(inFile, sFile2, delim);
std::getline(inFile, sFile3, delim);
inFile.close();

and now when I want to do something like a move operation it is as simple as:
//swap file 2 with file 1
SDL_FreeSurface( pFile2 );
SDL_FreeSurface( pFile1 );
sFile2.swap( sFile1 ); //one-line swap ftw
pFile1 = TTF_RenderText_Solid( TitleFont18, sFile1.c_str(), white );
pFile2 = TTF_RenderText_Solid( TitleFont18, sFile2.c_str(), color[offset] );

:D

Site updates

miotatsu Blog

the mionet site has been updated, here is a crosspost from the frontpage:
Big site updates! My mionet tumblr is now the homepage of mionet! Because of this change I will refrain from reblogging and posting stupid or personal things from here on out, and use this for site news and updates and stuff like that. One downside of using the blog instead of the rss feed that we had before is that other admins can’t post updates to the main site (unless I share the account with them, which I might). One of the upsides is that tumblr will be faster at updating (should be instant) and it is sexy

I will be making another personal account which will probably be miotatsu.tumbr.com later and I will use that for future silly blogging shenanigans.

NOW YOU MIGHT BE WONDERING how I am able to host the full site if mionet2.com is pointing to tumblr, the answer is that we now have a subdomain (hat.mionet2.com) which points to the server, which is where all the pages other than the homepage are hosted. If things look glitchy for you, you will need to clear out your browsers cache. anyway enjoy the update guys!

First blog post

miotatsu Blog

I am the main programmer on the mionet team, and one of the three founding members of mionet. I have been programming for around 3 years now, and use C++ & SDL. I am also learning OpenGL. I will keep this blog regularly updated with my progress on both the mionet site, and the games made by the team and other community members. To start off with, here is the last update to my current project called meiro:
test 8: copy
edit: apparently I can't post links for 7 days, so it will have to wait!