Commit Graph

10 Commits (netcode)

Author SHA1 Message Date
kts 7bc43929e0 Added much code for the foundation of the netcode. Server automatically starts on port 31337 and runs as a separate thread in the SDL client. This TCP server functions as a basic echo server and can be connected to thru telnet or by typing 'connect 127.0.0.1 31337' in timesynk's console. Once connected, the echo functionality can be tested by using console command 'send my message goes here'. Somewhat buggy and crashses on occasion - suspected cause is consoleLog()ing a string that is not properly nul terminated, resulting in reading memory out of bounds. Curses client does not run the server properly at the moment, probably due to using select on server, clients, and stdin when combined with ncurses - will look into this later. 2013-11-06 23:40:19 -08:00
kts 8fc710f3a2 Successfully recoded both SDL and curses client to use a model that ticks the world according to a Tick Event/Signal. How this works in SDL is a simple SDL Timer that pushes an SDL_USEREVENT with a code of EVENT_TICK at some interval in ms. The curses client works by calling setitimer with tickSignal as a callback, triggering whenever a SIGALRM signal is given. This was chosen for maximum cross-compatability for POSIX platforms, even though Linux has excellent timer fd support. Both the SDL and curses interfaces can have their tickrate modified by calling tickrate some_number_in_ms from the console. 0 stops the timer. For all of this to work, main() no longer has the while loop contained in it, but rather calls interfaceLoop() and lets the interface handle it (as this is extremely platform/api specific - some platforms have user input strongly tied into the drawing window (SDL), so we cannot use a monolithic select()-style while loop for all). Much more to be cleaned up, but this sets the foundation for network code. 2013-11-04 02:32:07 -08:00
kts 1f641bb92e Due to various errors on windows, along with much rage, it was decided that it is far more sensible for consoleGetCommand to simply return command[0] as the command string and command[1] as the remainder, leaving the task of distinguishing one argument from another to the function that consoleProcessCommand passes it to. This is, of course, up for remodeling in the future (possibly by using a variable amount of arguments such as in printf), but for now it'll do. Also added C preprocessor conditions for strndup to allow on Win*. 2013-10-23 21:05:29 -07:00
kts c28a62d522 As per usual, added a bunch of stuff and remember almost none of them. Most importantly, a console interface has been added that can be summoned by pressing the tilde key. Much of the functionality, including the less-than-stellar associative array (that acts as a function pointer) was ripped from the noirchat project. The only important commands are 'quit' and, for SDL, 'set_video widthxheight 0|1', with 0 representing windowed and 1 representing fullscreen. Both the curses and SDL client now have camera offsets, allowing for the center of the screen to always be centered on the player. There are plans to have the camera offset be relative to the distance from the edges of the map (so if the player is 25% from the left-side of the map, the camera offset would be 25% off center). Really in need of code clean-up and reorganization. 2013-10-22 02:49:25 -07:00
kts 29cdd11ec8 Added basic NPC/monster functionality as well as a console system. Simply call ConsoleLog(&string) and it'll create a new ConsoleEntry, set the console_last_entry's next to it, set the new entry's prev to console_last_entry, and finally set console_last_entry to point to the new entry (functions very similarly to Tile Chains). This may later be changed to an array form so as to easily pull sections of the log from anywhere. 2013-10-19 22:56:46 -07:00
kts 45ebcfe970 Added a temporary font spritesheet and the ability to interfacePrint in SDL with aforementioned font. This simply works by getting the numerical offset of the ASCII character value within the spritesheet (same principle as the rest of the tiles). In the future SDL_ttf will be used, but for the time being this will suffice. 2013-10-17 19:38:00 -07:00
kts 4c204db4f3 Added support for doors. A DoorTile is a fairly basic tile - at the moment - sporting a state int to specify its current state via STATE_OPEN, STATE_CLOSED, STATE_BROKEN, or STATE_MISSING. Graphically/ascii-ly, the proper visual appearance is acquired by multiplying the door id by the total door states(4) and adding the current state value to the result. For example, for a door with the id of 0, you would have visual tile 0 for closed, 1 for open, 2 for broken, and 3 for missing. Beyond the doors, the curses tiles were moved from interface/curses.(c/h) to tiles/curses_tiles.(c/h) - they should, at some point, be generated in a similar manner to the tiles for the SDL client (using pack_tiles). 2013-10-17 15:11:29 -07:00
kts 33ab0f2af2 Renamed binary_to_c to pack_tiles and made it convert tiles/*.png to various char arrays in tiles/tiles.c and tiles/tiles.h. Added fully functional graphical tiles to the SDL client by using the tile's id and tid to point to the appropriate arrays in tiles.c/tiles.h. Also added proper displaying of multiple tiles on a tile chain, tile movement via gameMoveTile, tile line drawing via drawLine, along with other touch-ups 2013-10-15 18:54:23 -07:00
kts 6e414d9223 Who knows what has been added! As far as I recall, *context(s) were tweaked, added compiled-in graphics for the SDL client, and probably some other stuff. 2013-10-14 19:21:33 -07:00
kts 0c5dc4c822 Initial commit, contains a barebones structure with the interface for both (x)curses and SDL. Can be built via the Makefile or via the XCode project in the xcode/ subdirectory 2013-09-17 22:37:36 -07:00