Topic: Hacking help needed
bothie Topic Opener |
Posted at: 2019-03-04, 15:01
Hi After years, I decided to come back to widelands, and still some problems exist and so I decided to go on and do some hacking on the game, however, it seems, nothing in the code is really helping newcomers into getting started, and so, I am basicly at the point, that I believe, that I found a bug, but I can't verify anything, because I don't get any useful information. A few examples: I have one "DescriptionIndex di" in my hand. It's 96. What is it? I already greped over the source, but since DescriptionIndex is just an int used for everything if I am not mistaken, I have no idea, what to look up. So what is the conversion DescriptionIndex -> std::string so I can get it to stdout in debug messages. Similar problem applies to other types, like "Request * r". Am I the only coder, who wants to know, what is the content of r in human readable form? Or is there some place in the code, where all this magic already happens? Basicly, what I need is a way to log(...) the content of a "Request", a "DescriptionIndex" or basicly any other type in a meaningful way. Any help appreciated and thanks in advance Top Quote |
Nordfriese |
Posted at: 2019-03-04, 15:48
Moin bothie and welcome to the forums Yep, I was also quite confused by the code when I started coding for widelands… It uses a lot of serial numbers to describe concepts such as buildings, workers, wares etc. A DescriptionIndex is such a serial – depending on the context, it may be the serial of a WareDescription, WorkerDescription, BuildingDescription, … Which Index refers to which concept is defined by the order in which they are loaded in the init.lua when starting the game. Look at
Similarly, for a
Almost the same "translation" can be applied to nearly all serials. If no EGBase or Game is provided, you can usually obtain an egbase e.g. via Edited: 2019-03-04, 15:50
Top Quote |
GunChleoc |
Posted at: 2019-03-05, 11:28
Some objects also have a "log_general_info" function that will log to the console:
Please do not hesitate to post any other questions Busy indexing nil values Top Quote |
Nordfriese |
Posted at: 2019-03-10, 21:15
Moin, now I have a question myself I´m experimenting with a possible new way to show workareas. I´m trying to display the workarea of a building as a plain-color overlay on triangles instead of displaying it on the nodes. This approach has the advantage over the current system that several visible workareas, as well as visible buildhelp icons, don´t obscure anything when overlapping. The result is (apart from some minor glitches such as a "grid" and a few missing triangles that will be fairly easy to solve) already more or less what I want: The code is here: lp:~nordfriese/widelands/workareas The code (the relevant parts are in wui/interactive_player.cc::draw_map_view and wui/interactive_base.cc::get_workarea_overlays) works basically like this: On every rendering I create a The problem is that my approach is very slow. I already improved performance by using one big Top Quote |
GunChleoc |
Posted at: 2019-03-11, 09:05
Maybe you could piggy-back to the code that calculates the drawing of the map terrains? The information which pixels to use is already there, so won't need to go pixel by pixel yourself. You could then create 1 square of the colored texture in the same size as the base terrain textures and add it as an overlay to the terrain drawing code. Have a look at the player color in the animation class for some color overlay code to poach. We also need to consider what happens with multiple buildings selected - maybe use an arithmetic middle per overlapping triangle? Alternatively, using a shader in the terrain program should also work, if you want to get into that. Edited: 2019-03-11, 09:09
Busy indexing nil values Top Quote |
Tribal-Chief |
Posted at: 2019-03-11, 10:55
The planned change would be a great improvement especially where you have building spaces turned on. Incidentally the picture above does highlight the fact that all Frisian images have incorrect shadow directions. Edited: 2019-03-11, 10:55
Top Quote |
WorldSavior |
Posted at: 2019-03-11, 12:15
Seeing multiple working areas is a feature. But seeing coordinates thanks to working areas is also a good feature. So what about adding some dot per each field? Wanted to save the world, then I got widetracked Top Quote |
Nordfriese |
Posted at: 2019-03-11, 15:59
@GunChleoc thans for your suggestion I tried to hack the terrain shader first, but that clashed with the dither layer. Since I don´t want to have to render the overlay twice, I now implemented it as a new (very simplistic) shader: And it has no negative impact on performance at all! (Unless I open 5+ building windows with workareas at the same time.) The colors themselves as well as their alpha strength still need some tweaking of course.
When deciding the color for a triangle, I currently apply all colors one after the other, and I weight the color components with their individual alpha channels:
This returns a good-looking result IMHO
Um… they´re short and pointing north-northeast… for frisians and all other images…
Okay, I´ll re-add some markers… Top Quote |
WorldSavior |
Posted at: 2019-03-11, 16:11
Thank you Wanted to save the world, then I got widetracked Top Quote |
Tribal-Chief |
Posted at: 2019-03-11, 16:54
Um… they´re short and pointing north-northeast… for frisians and all other images… but they point in another direction, check against trees or rocks, or buildings of other tribes. Top Quote |