tons of compiling warnings

tons of compiling warnings

Postby freem » 20 Jun 2016, 10:31

When compiling the game, there are tons of warnings (and I didn't even tried with the parano mode of clang). I fixed most of them (with some small refactoring sometimes) and hopefully it didn't had bugs (I guess the warnings are from a transition from C to C++, with pointers transformed in references), but there is a warning which probably highlight a bug and that I can't guess how to fix:

{l Code}: {l Select All Code}
~/contrib/Wyrmgus/src/ai/ai_building.cpp:306:30: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses]
                if (unit.Type->Building && !unit.Type->GivesResource == resource) {
                                           ^                         ~~
~/contrib/Wyrmgus/src/ai/ai_building.cpp:306:30: note: add parentheses after the '!' to evaluate the comparison first
                if (unit.Type->Building && !unit.Type->GivesResource == resource) {
                                           ^
                                            (                                   )
~/contrib/Wyrmgus/src/ai/ai_building.cpp:306:30: note: add parentheses around left hand side expression to silence this warning
                if (unit.Type->Building && !unit.Type->GivesResource == resource) {
                                           ^
                                           (                        )
1 warning generated.


From the code, I know that unit.Type->GivesResource and resource are both integers. Using the logical not operator on an int might be a way to change it to a bool, and then the result would be to compare a boolean, most probably "false" (since every non-0 value of an int is "true"), with an int. The result will probably be "false" most of the time. This is the 2nd advice of clang.
The other possibility would be to follow the 1st advice of clang, but in that case, it would be much clearer to just use the != operator instead of ==.

There is also a lot of noise related to alsa in-game, and several random segfaults.
About the alsa noise, I didn't even tried to fix it, I must admit. I don't know how alsa works, and those underrun warns are quite frequent in most games anyway (still, wyrmsun have a lot of those, really).
And for the random segfaults, I could not compile in debug mode, because of linkage issues related to oaml. I managed to fix that by modifying the CMakeLists.txt in a dirty way that can't work for others, but I thought I could inform about that (now I'll hopefully be able to find where are those segfaults from).

Lastly, I have a question. Here you say code contributions should be in CC0, and in the COPYING file, it is said code is GPL. Fact is, CC0 is compatible with GPL of course, but GPL is not compatible with CC0 (because GPL is "viral", unlike CC0, for example), which means that, in practice, the code will be GPL.
Not like I really mind, but what is your goal around that? If you intend to keep it under GPL, there is no problem, but if you intend to move to code to CC0, I think the best would be to move parts of the code you and new contributors own in a different file, to ease the tracking of remaining GPL code.
I intend to send you the small patches I did for the warning fixes, but I just would like to know under which licence :)

PS: interesting game. It feels like it might be a good one when beta stage will be reached.
freem
BN Moderator
 
Posts: 106
Joined: 18 May 2015, 19:38

Re: tons of compiling warnings

Postby Andrettin » 20 Jun 2016, 15:40

freem {l Wrote}:When compiling the game, there are tons of warnings (and I didn't even tried with the parano mode of clang). I fixed most of them (with some small refactoring sometimes) and hopefully it didn't had bugs (I guess the warnings are from a transition from C to C++, with pointers transformed in references), but there is a warning which probably highlight a bug and that I can't guess how to fix:

{l Code}: {l Select All Code}
~/contrib/Wyrmgus/src/ai/ai_building.cpp:306:30: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses]
                if (unit.Type->Building && !unit.Type->GivesResource == resource) {
                                           ^                         ~~
~/contrib/Wyrmgus/src/ai/ai_building.cpp:306:30: note: add parentheses after the '!' to evaluate the comparison first
                if (unit.Type->Building && !unit.Type->GivesResource == resource) {
                                           ^
                                            (                                   )
~/contrib/Wyrmgus/src/ai/ai_building.cpp:306:30: note: add parentheses around left hand side expression to silence this warning
                if (unit.Type->Building && !unit.Type->GivesResource == resource) {
                                           ^
                                           (                        )
1 warning generated.


From the code, I know that unit.Type->GivesResource and resource are both integers. Using the logical not operator on an int might be a way to change it to a bool, and then the result would be to compare a boolean, most probably "false" (since every non-0 value of an int is "true"), with an int. The result will probably be "false" most of the time. This is the 2nd advice of clang.
The other possibility would be to follow the 1st advice of clang, but in that case, it would be much clearer to just use the != operator instead of ==.


Thank you! I think removing the "== resource" would work best, since this function checks whether a location near a mine is good enough for the AI to build a town hall in, and that particular part of the code sees if there are too many buildings around the mine. If using "unit.Type->GivesResource == resource", it would discount only mines giving the resource you're looking for itself in that check, while using "!unit.Type->GivesResource" would discount any mine (which is better, since the AI shouldn't decide not to build a town hall near a gold mine just because there is copper and silver nearby).

By the way, what other compile warnings are you getting? I don't personally get tons of them when compiling, so knowing of them would be useful.

There is also a lot of noise related to alsa in-game, and several random segfaults.
About the alsa noise, I didn't even tried to fix it, I must admit. I don't know how alsa works, and those underrun warns are quite frequent in most games anyway (still, wyrmsun have a lot of those, really).
And for the random segfaults, I could not compile in debug mode, because of linkage issues related to oaml. I managed to fix that by modifying the CMakeLists.txt in a dirty way that can't work for others, but I thought I could inform about that (now I'll hopefully be able to find where are those segfaults from).


Hmm =/ I don't really have an idea of where the segfaults could be coming from, I haven't experienced any with the current state of the code. If you find out where they come from, I'll be glad to hear! Now that you mention it, some people have mentioned in the past having crashes when the time of day changed if OpenGL rendering is active. Maybe that's the issue you're having? I have so far never managed to reproduce that issue, so receiving more information to get that fixed would be most welcome.

Lastly, I have a question. Here you say code contributions should be in CC0, and in the COPYING file, it is said code is GPL. Fact is, CC0 is compatible with GPL of course, but GPL is not compatible with CC0 (because GPL is "viral", unlike CC0, for example), which means that, in practice, the code will be GPL.
Not like I really mind, but what is your goal around that? If you intend to keep it under GPL, there is no problem, but if you intend to move to code to CC0, I think the best would be to move parts of the code you and new contributors own in a different file, to ease the tracking of remaining GPL code.
I intend to send you the small patches I did for the warning fixes, but I just would like to know under which licence :)


Ah, I see how that could cause confusion. It would be nice to eventually track down all past contributors to the engine and have them agree with a MIT license for the code. With new contributors release their code under the CC0, then as you said it defaults to GPLv2 (since they are derivative of the engine's code), but it would make this move to a MIT license easier to do later on. I look forward to your patches :)

PS: interesting game. It feels like it might be a good one when beta stage will be reached.


Thanks for your interest in the game :) It has been out of beta stage for a long time now, though I guess there are things that could be improved. And I have a lot of plans to keep making the game better :)
Andrettin
Wyrmsun Moderator
 
Posts: 220
Joined: 29 Mar 2015, 19:26

Re: tons of compiling warnings

Postby freem » 20 Jun 2016, 22:35

Andrettin {l Wrote}:By the way, what other compile warnings are you getting? I don't personally get tons of them when compiling, so knowing of them would be useful.


Most warnings clang gave me were on things like:

{l Code}: {l Select All Code}
void foo( bar& b )
{
  if( &b )
  ...
}


because since valid C++ code does not pass invalid references compilers can optimize such things. Which makes a lot of sense.
There were other warnings, but they were not the majority.
There were also complaints about tests always true or false (taking the address of an array is always true, obviously, and the code does that several times).

Hmm =/ I don't really have an idea of where the segfaults could be coming from, I haven't experienced any with the current state of the code. If you find out where they come from, I'll be glad to hear! Now that you mention it, some people have mentioned in the past having crashes when the time of day changed if OpenGL rendering is active. Maybe that's the issue you're having? I have so far never managed to reproduce that issue, so receiving more information to get that fixed would be most welcome.


No hint for now (haven't played since I finally successfully compiled a debug version), but when I'll have some info I'll give the stacktrace and/or fix things. But I think it might be because of memory problems. I think so because I noticed that the memory consumption grows endlessly, so maybe there is not only memory leaks.

Ah, I see how that could cause confusion. It would be nice to eventually track down all past contributors to the engine and have them agree with a MIT license for the code. With new contributors release their code under the CC0, then as you said it defaults to GPLv2 (since they are derivative of the engine's code), but it would make this move to a MIT license easier to do later on. I look forward to your patches :)


I'll send the changes in the week so that if I could find some hints about the segfaults before, I could try to fix them in the process. But it'll be hard for you to track the % of code under CC0/MIT if it is mixed with GPL files. Maybe purely new functions (I haven't added any class) could be sent to alternate files to ease that, so that you will be able to notice when the GPL files weight less?

Thanks for your interest in the game :) It has been out of beta stage for a long time now, though I guess there are things that could be improved. And I have a lot of plans to keep making the game better :)


Well, thanks for working on it.
It's not common to have games providing 2 levels of strategy/tactics. In fact, the "grand strategy" mode reminds me of and old game that I liked a lot when I was a child: Lords of the Realm (ok, I only played the 2nd version with the extension pack, but I think the principle is roughly the same).

About the beta stage, I have noticed that you are still adding features, so I would consider it more like alpha stage (temple, auras, etc). But I don't think I really care about beta/alpha, as long as the stuff works or can be made working without too much efforts.
freem
BN Moderator
 
Posts: 106
Joined: 18 May 2015, 19:38

Re: tons of compiling warnings

Postby Andrettin » 21 Jun 2016, 09:59

freem {l Wrote}:Most warnings clang gave me were on things like:

{l Code}: {l Select All Code}
void foo( bar& b )
{
  if( &b )
  ...
}


because since valid C++ code does not pass invalid references compilers can optimize such things. Which makes a lot of sense.
There were other warnings, but they were not the majority.
There were also complaints about tests always true or false (taking the address of an array is always true, obviously, and the code does that several times).


I see; do you have a list with the parts of the code where it does that? The only instance of a reference being checked whether it is null I've found so far is in CleanUnits() (in unit.cpp).

No hint for now (haven't played since I finally successfully compiled a debug version), but when I'll have some info I'll give the stacktrace and/or fix things. But I think it might be because of memory problems. I think so because I noticed that the memory consumption grows endlessly, so maybe there is not only memory leaks.


Hmm, it could be because of memory issues indeed. Some graphics have a different texture (or in SDL rendering, different surfaces) for different hair/skin color variations, and then different variations of those for the times of day, maybe it's that. For example, the gnome graphics have four different skin color variations, and a bunch of hair color ones, all of which have versions for four different times of day.

I'll send the changes in the week so that if I could find some hints about the segfaults before, I could try to fix them in the process. But it'll be hard for you to track the % of code under CC0/MIT if it is mixed with GPL files. Maybe purely new functions (I haven't added any class) could be sent to alternate files to ease that, so that you will be able to notice when the GPL files weight less?


Ah, I think it wouldn't be hard to track it by contributor. The contributors who did the code for Stratagus before it was forked into Wyrmgus all did so licensing their code under the GPLv2, for instance. And the contributors to Wyrmgus itself can be easily tracked on GitHub.

Well, thanks for working on it.
It's not common to have games providing 2 levels of strategy/tactics. In fact, the "grand strategy" mode reminds me of and old game that I liked a lot when I was a child: Lords of the Realm (ok, I only played the 2nd version with the extension pack, but I think the principle is roughly the same).

About the beta stage, I have noticed that you are still adding features, so I would consider it more like alpha stage (temple, auras, etc). But I don't think I really care about beta/alpha, as long as the stuff works or can be made working without too much efforts.


Yeah, I intend to keep working on the game indefinitely :) I liked Lords of the Realm 2 quite a bit as well. It's mix of a strategic level with a top-down RTS-like mode was a great inspiration for me, actually.
Andrettin
Wyrmsun Moderator
 
Posts: 220
Joined: 29 Mar 2015, 19:26

Re: tons of compiling warnings

Postby freem » 21 Jun 2016, 14:01

Andrettin {l Wrote}:I see; do you have a list with the parts of the code where it does that? The only instance of a reference being checked whether it is null I've found so far is in CleanUnits() (in unit.cpp).


The stderr log I had on 51a425569384366459f2b2e957f7db3e36afc427 (this commit didn't compiled, so I did a 1st commit to fix that, and I know myself, I probably cleaned some warns in the process, then I pulled again after playing a bit, and fixed other warnings):

{l Code}: {l Select All Code}
** tolua warning: Mapping variable to global may degrade performance.

In file included from /home/berenger/contrib/Wyrmgus/src/action/action_board.cpp:53:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_attack.cpp:61:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_build.cpp:60:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_built.cpp:50:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_defend.cpp:54:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_follow.cpp:54:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_move.cpp:55:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_pickup.cpp:56:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_patrol.cpp:54:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_repair.cpp:57:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_resource.cpp:56:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_spellcast.cpp:64:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_still.cpp:57:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_train.cpp:52:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_use.cpp:55:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
In file included from /home/berenger/contrib/Wyrmgus/src/action/actions.cpp:78:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/action/action_use.cpp:224:68: warning: expression result unused [-Wunused-value]
                                        unit.Player->ChangeResource(goal->Type->GivesResource, (goal->ResourcesHeld, true));
                                                                                                ~~~~  ^~~~~~~~~~~~~
1 warning generated.
2 warnings generated.
In file included from /home/berenger/contrib/Wyrmgus/src/action/command.cpp:56:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/ai/ai_building.cpp:45:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/ai/ai_building.cpp:306:30: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses]
                if (unit.Type->Building && !unit.Type->GivesResource == resource) {
                                           ^                         ~~
/home/berenger/contrib/Wyrmgus/src/ai/ai_building.cpp:306:30: note: add parentheses after the '!' to evaluate the comparison first
                if (unit.Type->Building && !unit.Type->GivesResource == resource) {
                                           ^
                                            (                                   )
/home/berenger/contrib/Wyrmgus/src/ai/ai_building.cpp:306:30: note: add parentheses around left hand side expression to silence this warning
                if (unit.Type->Building && !unit.Type->GivesResource == resource) {
                                           ^
                                           (                        )
2 warnings generated.
In file included from /home/berenger/contrib/Wyrmgus/src/ai/ai_force.cpp:49:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/ai/ai_plan.cpp:47:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/ai/ai_plan.cpp:707:84: warning: format specifies type 'int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
                        fprintf(stderr, "AI Player #%d's scout %d is null.\n", AiPlayer->Player->Index, i);
                                                               ~~                                       ^
                                                               %zu
2 warnings generated.
In file included from /home/berenger/contrib/Wyrmgus/src/ai/ai_resource.cpp:51:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/ai/ai_resource.cpp:439:70: warning: address of array 'unit->Type->ResInfo' will always evaluate to 'true' [-Wpointer-bool-conversion]
                return (unit->Type->BoolFlag[HARVESTER_INDEX].value && unit->Type->ResInfo && !unit->Removed);
                                                                    ~~ ~~~~~~~~~~~~^~~~~~~
2 warnings generated.
In file included from /home/berenger/contrib/Wyrmgus/src/editor/editloop.cpp:63:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/editor/editloop.cpp:1614:13: warning: adding 'char' to a string pointer does not append to the string [-Wstring-plus-char]
                key = '0' + ptr - UiGroupKeys.c_str();
                      ~~~~^~~~~
/home/berenger/contrib/Wyrmgus/src/editor/editloop.cpp:1614:13: note: use array indexing to silence this warning
2 warnings generated.
In file included from /home/berenger/contrib/Wyrmgus/src/game/trigger.cpp:47:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/map/map.cpp:49:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/map/map_wall.cpp:44:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/missile/missile.cpp:58:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/missile/missile.cpp:1214:8: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (&goal && goal.Variable[THORNSDAMAGE_INDEX].Value && missile.SourceUnit->MapDistanceTo(goal) <= 1) {
                     ^~~~ ~~
2 warnings generated.
In file included from /home/berenger/contrib/Wyrmgus/src/missile/missile_deathcoil.cpp:43:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/missile/missile_flameshield.cpp:42:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/missile/missile_parabolic.cpp:44:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/missile/missile_tracer.cpp:45:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/pathfinder/astar.cpp:43:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/pathfinder/astar.cpp:602:8: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
        if (!&unit) {
            ~ ^~~~
2 warnings generated.
/home/berenger/contrib/Wyrmgus/src/sound/sound.cpp:312:8: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
        if (!&unit) {
            ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/sound/sound.cpp:332:8: warning: address of 'source' will always evaluate to 'true' [-Wpointer-bool-conversion]
        if (!&source) {
            ~ ^~~~~~
2 warnings generated.
In file included from /home/berenger/contrib/Wyrmgus/src/spell/spell_areaadjustvital.cpp:39:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/spell/spell_capture.cpp:44:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/spell/spell_demolish.cpp:40:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/spell/spell_polymorph.cpp:49:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/spell/spell_retrain.cpp:39:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/spell/spell_spawnmissile.cpp:41:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/spell/spell_summon.cpp:45:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/spell/spells.cpp:54:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
/home/berenger/contrib/Wyrmgus/src/stratagus/player.cpp:1483:82: warning: address of array 'unit.Type->ResInfo' will always evaluate to 'true' [-Wpointer-bool-conversion]
                if (unit.IsAlive() && unit.Type->BoolFlag[HARVESTER_INDEX].value && unit.Type->ResInfo && !unit.Removed) {
                                                                                 ~~ ~~~~~~~~~~~^~~~~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/stratagus/script_player.cpp:59:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/stratagus/selection.cpp:51:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/stratagus/selection.cpp:851:64: warning: address of array 'unit.Type->ResInfo' will always evaluate to 'true' [-Wpointer-bool-conversion]
                if (unit.Type->BoolFlag[HARVESTER_INDEX].value && unit.Type->ResInfo) { //this selection mode is not for workers
                                                               ~~ ~~~~~~~~~~~^~~~~~~
2 warnings generated.
/home/berenger/contrib/Wyrmgus/src/ui/botpanel.cpp:1377:10: warning: enumeration values 'ButtonUnit' and 'ButtonEditorUnit' not handled in switch [-Wswitch]
        switch (buttonaction.Action) {
                ^
/home/berenger/contrib/Wyrmgus/src/ui/botpanel.cpp:2021:10: warning: enumeration values 'ButtonUnit' and 'ButtonEditorUnit' not handled in switch [-Wswitch]
        switch (CurrentButtons[button].Action) {
                ^
2 warnings generated.
In file included from /home/berenger/contrib/Wyrmgus/src/ui/interface.cpp:56:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/ui/interface.cpp:702:13: warning: adding 'char' to a string pointer does not append to the string [-Wstring-plus-char]
                key = '0' + ptr - UiGroupKeys.c_str();
                      ~~~~^~~~~
/home/berenger/contrib/Wyrmgus/src/ui/interface.cpp:702:13: note: use array indexing to silence this warning
2 warnings generated.
/home/berenger/contrib/Wyrmgus/src/ui/mainscr.cpp:450:10: warning: enumeration values 'VariableChange' and 'VariableIncreaseChange' not handled in switch [-Wswitch]
        switch (e) {
                ^
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/ui/mouse.cpp:66:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/unit/build.cpp:45:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/unit/script_unit.cpp:62:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/unit/unit_draw.cpp:62:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
In file included from /home/berenger/contrib/Wyrmgus/src/unit/unit.cpp:83:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/unit/unit.cpp:4552:73: warning: address of array 'unit.GetAnimations()->Death' will always evaluate to 'true' [-Wpointer-bool-conversion]
        if (type->CorpseType || (unit.GetAnimations() && unit.GetAnimations()->Death)) {
                                                      ~~ ~~~~~~~~~~~~~~~~~~~~~~^~~~~
/home/berenger/contrib/Wyrmgus/src/unit/unit.cpp:5601:8: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false [-Wtautological-undefined-compare]
                if (&unit == NULL) {
                     ^~~~    ~~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/unit/unit_find.cpp:40:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/unit/unit_find.cpp:539:64: warning: address of array 'unit.Type->ResInfo' will always evaluate to 'true' [-Wpointer-bool-conversion]
                if (unit.Type->BoolFlag[HARVESTER_INDEX].value && unit.Type->ResInfo && !unit.Removed) {
                                                               ~~ ~~~~~~~~~~~^~~~~~~
3 warnings generated.
2 warnings generated.
In file included from /home/berenger/contrib/Wyrmgus/src/unit/upgrade.cpp:75:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/unit/upgrade.cpp:1181:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&unit) {
                    ~ ^~~~
2 warnings generated.


You will notice that unit_find.h:224:9 generates a lot of noise, which is normal, it's a header and is compiled every time it's included.

I didn't fixed some of those warns: the tolua one, which I don't understand anyway, the printf, switch not handling everything and the !GiveResource == resource one that I see you have fixed.

You might want to edit the comits I made, because I removed zombie code on several points. That zombie code is useless (git is here to keep old code, no need to do it manually) and annoying (distract from real code, and can block the feature to jump between corresponding {}() that I use a lot in vim).
Also, I used tabulations for indentation, since I felt like it was the more common but there are 4 space indentations in the files too. That could probably be fixed in few minutes (few seconds to let sed run, and few minutes to check it didn't made things worse, or eventually use astyle) if you have any preference.

Ah, I think it wouldn't be hard to track it by contributor. The contributors who did the code for Stratagus before it was forked into Wyrmgus all did so licensing their code under the GPLv2, for instance. And the contributors to Wyrmgus itself can be easily tracked on GitHub.


True, you can also use various git features like blame and alike, but there is nothing really handy that I know about to know how much of GPL code is still present in current status, which was my point.
Not that I really mind: yes, for my projects I tend to use BSD/MIT-style licences when possible, because I prefer licences I can actually understand, and (L)GPL is hard enough to understand even for lawyers, so... but, it's not my project.

Yeah, I intend to keep working on the game indefinitely :)


Games can't really be finished, from a coder point of view. There is always the little feature you can add... :D
Myself seeing this game I have various ideas coming quickly (but I know it's not easy to do): marking tiles of resources to be work on on priority (to clean path), military formations movements (keep ranged behind a nice line of melee while moving, can find that in several games like ages of empires 2), castle siege (but I guess you already have it in mind ;))... oh, and now that I think about it, I noticed you can't ask a worker which have gathered some resources to harvest the trunks in which you can hide units.
But it's easy to speak.

I liked Lords of the Realm 2 quite a bit as well. It's mix of a strategic level with a top-down RTS-like mode was a great inspiration for me, actually.


Which explains the strategy mode, I guess. I probably still have the siege pack around, and I don't think I remember any other game having the siege feature. Sad that AI usually sucked a lot, but the feature was still fun and it's true in most games anyway.
freem
BN Moderator
 
Posts: 106
Joined: 18 May 2015, 19:38

Re: tons of compiling warnings

Postby Andrettin » 22 Jun 2016, 10:37

freem {l Wrote}:
Andrettin {l Wrote}:I see; do you have a list with the parts of the code where it does that? The only instance of a reference being checked whether it is null I've found so far is in CleanUnits() (in unit.cpp).


The stderr log I had on 51a425569384366459f2b2e957f7db3e36afc427 (this commit didn't compiled, so I did a 1st commit to fix that, and I know myself, I probably cleaned some warns in the process, then I pulled again after playing a bit, and fixed other warnings):

{l Code}: {l Select All Code}
** tolua warning: Mapping variable to global may degrade performance.

In file included from /home/berenger/contrib/Wyrmgus/src/action/action_board.cpp:53:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_attack.cpp:61:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_build.cpp:60:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_built.cpp:50:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_defend.cpp:54:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_follow.cpp:54:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_move.cpp:55:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_pickup.cpp:56:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_patrol.cpp:54:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_repair.cpp:57:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_resource.cpp:56:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_spellcast.cpp:64:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_still.cpp:57:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_train.cpp:52:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/action/action_use.cpp:55:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
In file included from /home/berenger/contrib/Wyrmgus/src/action/actions.cpp:78:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/action/action_use.cpp:224:68: warning: expression result unused [-Wunused-value]
                                        unit.Player->ChangeResource(goal->Type->GivesResource, (goal->ResourcesHeld, true));
                                                                                                ~~~~  ^~~~~~~~~~~~~
1 warning generated.
2 warnings generated.
In file included from /home/berenger/contrib/Wyrmgus/src/action/command.cpp:56:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/ai/ai_building.cpp:45:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/ai/ai_building.cpp:306:30: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses]
                if (unit.Type->Building && !unit.Type->GivesResource == resource) {
                                           ^                         ~~
/home/berenger/contrib/Wyrmgus/src/ai/ai_building.cpp:306:30: note: add parentheses after the '!' to evaluate the comparison first
                if (unit.Type->Building && !unit.Type->GivesResource == resource) {
                                           ^
                                            (                                   )
/home/berenger/contrib/Wyrmgus/src/ai/ai_building.cpp:306:30: note: add parentheses around left hand side expression to silence this warning
                if (unit.Type->Building && !unit.Type->GivesResource == resource) {
                                           ^
                                           (                        )
2 warnings generated.
In file included from /home/berenger/contrib/Wyrmgus/src/ai/ai_force.cpp:49:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/ai/ai_plan.cpp:47:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/ai/ai_plan.cpp:707:84: warning: format specifies type 'int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
                        fprintf(stderr, "AI Player #%d's scout %d is null.\n", AiPlayer->Player->Index, i);
                                                               ~~                                       ^
                                                               %zu
2 warnings generated.
In file included from /home/berenger/contrib/Wyrmgus/src/ai/ai_resource.cpp:51:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/ai/ai_resource.cpp:439:70: warning: address of array 'unit->Type->ResInfo' will always evaluate to 'true' [-Wpointer-bool-conversion]
                return (unit->Type->BoolFlag[HARVESTER_INDEX].value && unit->Type->ResInfo && !unit->Removed);
                                                                    ~~ ~~~~~~~~~~~~^~~~~~~
2 warnings generated.
In file included from /home/berenger/contrib/Wyrmgus/src/editor/editloop.cpp:63:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/editor/editloop.cpp:1614:13: warning: adding 'char' to a string pointer does not append to the string [-Wstring-plus-char]
                key = '0' + ptr - UiGroupKeys.c_str();
                      ~~~~^~~~~
/home/berenger/contrib/Wyrmgus/src/editor/editloop.cpp:1614:13: note: use array indexing to silence this warning
2 warnings generated.
In file included from /home/berenger/contrib/Wyrmgus/src/game/trigger.cpp:47:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/map/map.cpp:49:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/map/map_wall.cpp:44:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/missile/missile.cpp:58:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/missile/missile.cpp:1214:8: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (&goal && goal.Variable[THORNSDAMAGE_INDEX].Value && missile.SourceUnit->MapDistanceTo(goal) <= 1) {
                     ^~~~ ~~
2 warnings generated.
In file included from /home/berenger/contrib/Wyrmgus/src/missile/missile_deathcoil.cpp:43:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/missile/missile_flameshield.cpp:42:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/missile/missile_parabolic.cpp:44:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/missile/missile_tracer.cpp:45:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/pathfinder/astar.cpp:43:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/pathfinder/astar.cpp:602:8: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
        if (!&unit) {
            ~ ^~~~
2 warnings generated.
/home/berenger/contrib/Wyrmgus/src/sound/sound.cpp:312:8: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
        if (!&unit) {
            ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/sound/sound.cpp:332:8: warning: address of 'source' will always evaluate to 'true' [-Wpointer-bool-conversion]
        if (!&source) {
            ~ ^~~~~~
2 warnings generated.
In file included from /home/berenger/contrib/Wyrmgus/src/spell/spell_areaadjustvital.cpp:39:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/spell/spell_capture.cpp:44:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/spell/spell_demolish.cpp:40:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/spell/spell_polymorph.cpp:49:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/spell/spell_retrain.cpp:39:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/spell/spell_spawnmissile.cpp:41:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/spell/spell_summon.cpp:45:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/spell/spells.cpp:54:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
/home/berenger/contrib/Wyrmgus/src/stratagus/player.cpp:1483:82: warning: address of array 'unit.Type->ResInfo' will always evaluate to 'true' [-Wpointer-bool-conversion]
                if (unit.IsAlive() && unit.Type->BoolFlag[HARVESTER_INDEX].value && unit.Type->ResInfo && !unit.Removed) {
                                                                                 ~~ ~~~~~~~~~~~^~~~~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/stratagus/script_player.cpp:59:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/stratagus/selection.cpp:51:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/stratagus/selection.cpp:851:64: warning: address of array 'unit.Type->ResInfo' will always evaluate to 'true' [-Wpointer-bool-conversion]
                if (unit.Type->BoolFlag[HARVESTER_INDEX].value && unit.Type->ResInfo) { //this selection mode is not for workers
                                                               ~~ ~~~~~~~~~~~^~~~~~~
2 warnings generated.
/home/berenger/contrib/Wyrmgus/src/ui/botpanel.cpp:1377:10: warning: enumeration values 'ButtonUnit' and 'ButtonEditorUnit' not handled in switch [-Wswitch]
        switch (buttonaction.Action) {
                ^
/home/berenger/contrib/Wyrmgus/src/ui/botpanel.cpp:2021:10: warning: enumeration values 'ButtonUnit' and 'ButtonEditorUnit' not handled in switch [-Wswitch]
        switch (CurrentButtons[button].Action) {
                ^
2 warnings generated.
In file included from /home/berenger/contrib/Wyrmgus/src/ui/interface.cpp:56:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/ui/interface.cpp:702:13: warning: adding 'char' to a string pointer does not append to the string [-Wstring-plus-char]
                key = '0' + ptr - UiGroupKeys.c_str();
                      ~~~~^~~~~
/home/berenger/contrib/Wyrmgus/src/ui/interface.cpp:702:13: note: use array indexing to silence this warning
2 warnings generated.
/home/berenger/contrib/Wyrmgus/src/ui/mainscr.cpp:450:10: warning: enumeration values 'VariableChange' and 'VariableIncreaseChange' not handled in switch [-Wswitch]
        switch (e) {
                ^
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/ui/mouse.cpp:66:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/unit/build.cpp:45:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/unit/script_unit.cpp:62:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/unit/unit_draw.cpp:62:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
In file included from /home/berenger/contrib/Wyrmgus/src/unit/unit.cpp:83:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/unit/unit.cpp:4552:73: warning: address of array 'unit.GetAnimations()->Death' will always evaluate to 'true' [-Wpointer-bool-conversion]
        if (type->CorpseType || (unit.GetAnimations() && unit.GetAnimations()->Death)) {
                                                      ~~ ~~~~~~~~~~~~~~~~~~~~~~^~~~~
/home/berenger/contrib/Wyrmgus/src/unit/unit.cpp:5601:8: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false [-Wtautological-undefined-compare]
                if (&unit == NULL) {
                     ^~~~    ~~~~
1 warning generated.
In file included from /home/berenger/contrib/Wyrmgus/src/unit/unit_find.cpp:40:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/unit/unit_find.cpp:539:64: warning: address of array 'unit.Type->ResInfo' will always evaluate to 'true' [-Wpointer-bool-conversion]
                if (unit.Type->BoolFlag[HARVESTER_INDEX].value && unit.Type->ResInfo && !unit.Removed) {
                                                               ~~ ~~~~~~~~~~~^~~~~~~
3 warnings generated.
2 warnings generated.
In file included from /home/berenger/contrib/Wyrmgus/src/unit/upgrade.cpp:75:
/home/berenger/contrib/Wyrmgus/src/include/unit_find.h:224:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&type) {
                    ~ ^~~~
/home/berenger/contrib/Wyrmgus/src/unit/upgrade.cpp:1181:9: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
                if (!&unit) {
                    ~ ^~~~
2 warnings generated.


You will notice that unit_find.h:224:9 generates a lot of noise, which is normal, it's a header and is compiled every time it's included.


Thank you for the list! I've committed a bunch of fixes to them now :)

I didn't fixed some of those warns: the tolua one, which I don't understand anyway, the printf, switch not handling everything and the !GiveResource == resource one that I see you have fixed.

You might want to edit the comits I made, because I removed zombie code on several points. That zombie code is useless (git is here to keep old code, no need to do it manually) and annoying (distract from real code, and can block the feature to jump between corresponding {}() that I use a lot in vim).


I keep the zombie code mostly to mark my changes, for later integration upstream. Mainline Stratagus development is nearly dead by now, however, so there's not much point in integrating Wyrmgus features into it. I also use the zombie code as a reference so that I can easily see what I modified, finding my own mistakes faster (which is helpful to me, since I'm self-taught).

Also, I used tabulations for indentation, since I felt like it was the more common but there are 4 space indentations in the files too. That could probably be fixed in few minutes (few seconds to let sed run, and few minutes to check it didn't made things worse, or eventually use astyle) if you have any preference.´


I use tabulations too, it looks better to me. The 4-space indentations seem to mostly be from the Guichan code. Wouldn't it be better to change the indentation manually? Since four-spaces are used in the comment introduction of each file, changing all four-spaces automatically would make those comments look wonky.

True, you can also use various git features like blame and alike, but there is nothing really handy that I know about to know how much of GPL code is still present in current status, which was my point.


Yes, that's true. A list with all contributors, saying whether each has already been contacted and agreed to relicense the code to an MIT license (or the CC0) could suffice as a guide for that, though.

Games can't really be finished, from a coder point of view. There is always the little feature you can add... :D
Myself seeing this game I have various ideas coming quickly (but I know it's not easy to do): marking tiles of resources to be work on on priority (to clean path), military formations movements (keep ranged behind a nice line of melee while moving, can find that in several games like ages of empires 2), castle siege (but I guess you already have it in mind ;))... oh, and now that I think about it, I noticed you can't ask a worker which have gathered some resources to harvest the trunks in which you can hide units.
But it's easy to speak.


Military formations would be great :) It would need a significant reworking of the pathfinder, but it would be nice to have that implemented eventually.

About castle sieges, that would be pretty nice as well :) Right now in the grand strategy mode when attacking a province, if it has a stronghold the defender will have a couple of towers generated for them. Once walls are in the game (I need to commission a pixel artist to create the graphics for them first) and the map generation algorithm for them has been implemented, province defenders should begin with walls in the battle as well (if they have a stronghold). And of course, walls would also be buildable in the RTS mode and present in missions, too. Some other ideas have been floated around, such as allowing workers to dig moats. Battering rams would also be a good addition for the future.

About harvesting those trunks, it's possible actually; although their default right-click action for the trunks is to hide in them, you can still harvest them by pressing "H" (or clicking on the Harvest Resource button in the command panel), and then clicking on the trunk.

What do you mean by marking the resource tiles to be worked by priority? Right now the closest resource of the desired type is chosen.

Which explains the strategy mode, I guess. I probably still have the siege pack around, and I don't think I remember any other game having the siege feature. Sad that AI usually sucked a lot, but the feature was still fun and it's true in most games anyway.


Partially, yes. Having played Lords of the Realm 2 makes it easier to visualize how a top-down (gameplay-wise) tactical mode can fit in with a strategic map. The strategic mode is also inspired by games like Imperialism, though.
Andrettin
Wyrmsun Moderator
 
Posts: 220
Joined: 29 Mar 2015, 19:26

Who is online

Users browsing this forum: No registered users and 1 guest

cron