[crossfire] Crossfire server code cleanup/janitorial

Tolga Dalman tolga.dalman at googlemail.com
Wed Apr 23 02:17:08 CDT 2014


On 04/23/2014 01:19 AM, Kevin Zheng wrote:
> I'm still not sure why this would make the project more portable,
> though. The major compiler toolchains support C just as well as C++,
> with the notable exception of Visual Studio.

It is not only the language and the employed toolchain. In my experience,
problems begin as soon as you start implementing containers and data structures
in C (which, btw, has been done in crossfire). It is then a good idea to use
standardized library functions, like, strings, lists, or hash tables. All
this is provided by C++ for free in a highly portable way.

>> I tend to agree, though, I have had some bad experience in another
>> project with a lot of false-positives using VS 2008. Using GCC, I
>> would always recommend compiling with -W -Wall.
>
> Right now the code seems to compile fairly cleanly.

Try compiling with gcc 4.8. While almost all issues are minor
(unused variables and signed compares), there is some work left
with at least GCC. I haven't tried other compilers though.

> While strlcat and strlcpy are not defined by any standards body, I
> believe that they are superior to the normal functions and should be
> used whenever possible. If you haven't noticed, I recently committed a
> small chunk of platform-dependent code that uses these two functions
> when available instead of our hacks around it.

Yes, and that's a good progress! However, I still fail to understand
why strlcat/strlcpy would be superior to strncat/strncpy.

> Right now Crossfire seems maintainable. Recently, several important bug
> fixes were made, and few new features were introduced.

As I said before, these developments have inspired me to start this
(quite long) thread. And to repeat: I believe that the overall quality
of the source code is really good. Still there is some way to go.
Thanks for your work!

> Even then, some specifics would be useful. What are you suggesting for
> networking or the server loops?

I haven't had thought about it well enough, but I can think of two
possibilities:
a) refactor/rewrite the code.
b) use third-party libraries.
My preference is of course b), however, such a step must be thoroughly
investigated beforehand.

> At the end of the day, if you believe that certain changes are worth
> your time making, please send a patch. The recent cleanups were made
> because I wanted them and nobody objected to them.

While I really appreciate the positive discussion we have had
up until now, my impression is that I should now be showing you what
I have in mind rather than doing mouth-work only :)
On github, I have created a crossfire server repository to track my
patches (based on SVN trunk rev. 19362).

   https://github.com/tdalman/crossfire

I won't be able to test any other platform than Linux and I won't be
attempting to do so either. If you think some of the changes are
worthwhile to adopt, I'd be happy of course. Likewise, please don't
hesitate to comment on my patches. I will try to keep the code in
sync, but at some point that will no longer be possible.


Best regards
Tolga Dalman




More information about the crossfire mailing list