Online roguelike gamedev @ ANSI C

All trinity of online roguelikes written in ANSI C programming language (~ C89-C99 standard) as they all were initially based at Angband source code

So for all those who want to come closer to understanding – how online roguelikes works or want to help with developing, I wanna share a few useful links, to begin with:
 
1) wiki: C language, ANSI C
2) online roguelikes source code repositories:

3) Read the book about C. There are a lot of books about ANSI C; my personal favorite one is “C Primer Plus” by Stephen Prata. C it’s a language which you should not learn fast, as you need to understand a lot of deep internal stuff. Don’t be hurry 🙂

 
So.. To get into the development process, you should:
 
1) learn ANSI C basics (book or online tutorial would do)
2) create very simple roguelike game yourself (good tutorial – RogueLulz, Part I: Drawing the Map, Walking Around, Basic Monsters and Attacking)
3) ‘read’ source code and understand how it works
4) add a tiny feature and make it work. Eg: change the color of UI, add an indicator of buff/debuff, add a new window with minimap etc
5) join our Discord and catch up with the dev process together! 🙂
 
Please don’t hesitate to add more information, useful links, tutorials or anything considering this topic in our discord, so I’ll add it there.
 

Coding FAQ:

Explain why your ATTR is 16 bit? I gather you need more values than 127, but could you elaborate? Also, is this in V?

Yes, because tilesets can be bigger than 128×128. Also GCU client uses special attributes greater than 128 because of Necklace of the Eye frontend. For example: it’s not possible to use @ symbols because NotEye uses @ to track the position of the player so you could use a smily face instead (0x263A).

Give a bird’s-eye view of how the dungeon levels are aligned in memory in V/PWMA nowdays? (e.g., in mang it’s horrid cave[-4096 to 127] array, with wilderness indexes spiraling in negative dimensions (as you well know))

Levels are now stores in a [x/y/z] array. Wilderness is rectangular. Towns or wilderness areas are (x,y,0). Then at location (x,y) you can have a dungeon with floors from 1 to 127 on z axis.

Is there also a function like get_player_level(struct player*p) which uses p->world_x, p->world_y, p->depth or something similar? and are there accessors like that?

No, only a get_cave.

Are monsters/objects still stored globally with references into levels, or are they now part of level struct?

Part of level. Everything is in the cave now: mobs, objects, traps.

How to debug the server?

Install C++Builder Community Edition

There are two ways to do it – via ready solution or manual:
1) solution: download project file for the server (RMB → ‘Save file as…’)
2) manual:

  1. create new project
  2. counsole application → C
  3. specify project source, choose “main.c” in /src/server
  4. save the project with the name: mangband into /src/bcb6 (first it will save .h file; and afterwards new window appear with *.cbproj) // name is important so it will generate server binary as mangband.exe
  5. now lets configure the game: project tab → try to find the “options”
  6. Building →
    C++ Shared Options → Final output directory → choose PWMAngband (main source folder)
  7. C++ Compiler → ‘Use classic Borland compiler’ → true
  8. Directories and Conditionals → conditional defines:
    _DEBUG;STRICT;BCC_IDE;WINDOWS
  9. Directories and Conditionals → Include file search path we need to add ..\win and ..\common
    to do so click on “…” to add a line
  10. Directories and Conditionals → Object file output directory → PWMAngband
  11. Pre-compiled headers → cache: true
  12. now we need to add all files into the project; first the files in “common”, all .c files
    right click project.exe and click add
    in /common
    .c
    add everything except net-unix.c
    it will appear in project folder (expand to see the files)
  13. now add all the files from the /server except main.c
  14. last file to add is “angband.rc” from /win
  15. project -> make … if it’s linking – we are good 🙂
  16. check is .exe files generated (should be in PWMAngband folder)
  17. execute (green arrow)
  18. now open “game-world.c”
  19. find “void exit_game_panic(void)” (ctrl-f shoulds open search wndow)
  20. let’s make breakpoint here: click in the margin on the left, on the line (red marker dot will appear)
  21. now close the server window (which is running as you executed it previously); use ctrl+c for closing it (closing with “x” can crash)
  22. now we will launch server in debug mode: click on button next to green arrow (Run)
  23. it is now in debug mode: “exit_game_panic” is the function that is called when there is a crash; so when the game crashes, the debugger will stop on that line
  24. open a window called “stack view” in debug menu: view → call stack (it will appear on the left)
  25. when the program stops, you get the line where the crash occurs, so you can fix the code immediately!

How to debug the client?

Solution: download project file for the client (RMB → ‘Save file as…’)

Basically the same, but you should add variables from PWMAngband\src\bcb6\<file>.bpr to your IDE project file.

  1. look in mangclient_sdl.bpr and instead of server’s _DEBUG;STRICT;BCC_IDE;WINDOWS (Directories and Conditionals → conditional defines:), use:
    STRICT;BCC_IDE;WINDOWS;SOUND_SDL;USE_SDL;_DEBUG

  2. add library path to the project properties:
    D:\GitHub\Tangaria\PWMAngband\src_SDL

  3. also add .._SDL\SDL.lib .._SDL\SDL_ttf.lib .._SDL\SDL_image.lib .._SDL\SDL_mixer.lib files directly to the project (right click project.exe and click “add”)

How to modify broken data

To report typo, error or make suggestion: select text and press Ctrl+Enter.

Leave a Reply

🇬🇧 Attention! Comments with URLs/email are not allowed.
🇷🇺 Комментарии со ссылками/email удаляются автоматически.