Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert sorm.h to c-style #465

Closed
wants to merge 1 commit into from
Closed

Convert sorm.h to c-style #465

wants to merge 1 commit into from

Conversation

AJenbo
Copy link
Member

@AJenbo AJenbo commented Nov 18, 2018

No description provided.

@squidcc
Copy link
Contributor

squidcc commented Nov 18, 2018

The struct definitions should be changed to look like this:

typedef struct XYZ {
...
} XYZ;

Then you don't need to add "struct" all through the source files.

@AJenbo
Copy link
Member Author

AJenbo commented Nov 18, 2018

@squidcc thanks that makes things a bit easier going forward (PR has been adjusted).

@mewmew removing reference form CelDecDatLightEntry's signature compiles, but the game crashes. Any other suggestions as how to convert it to C?

@squidcc
Copy link
Contributor

squidcc commented Nov 18, 2018

CelDecDatLightEntry isn't actually meant to be a separate function, it's an inline ASM block inside CelDecDatLightOnly that explicitly uses call and ret instructions.

The easy fix in this situation is to remove its declaration from engine.h and make it static.
The proper fix is to stop including every header in every source, eliminating the need to change practically every single file in the project just to enable this PR to compile.

@AJenbo
Copy link
Member Author

AJenbo commented Nov 19, 2018

player.cpp uses functions from the following:

#include "Source/appfat.h"
#include "Source/control.h"
#include "Source/cursor.h"
#include "Source/dead.h"
#include "Source/diablo.h"
#include "Source/effects.h"
#include "Source/engine.h"
#include "Source/gamemenu.h"
#include "Source/gendung.h"
#include "Source/inv.h"
#include "Source/items.h"
#include "Source/lighting.h"
#include "Source/minitext.h"
#include "Source/missiles.h"
#include "Source/monster.h"
#include "Source/msg.h"
#include "Source/multi.h"
#include "Source/objects.h"
#include "Source/path.h"
#include "Source/player.h"
#include "Source/portal.h"
#include "Source/spells.h"
#include "Source/stores.h"
#include "Source/towners.h"
#include "Source/wave.h"

So more then a third of the files would still be included :/

We pretty much concluded that we need to convert the whole project to c-style before it makes sens to switch the compiler so making CelDecDatLightEntry static won't really solve the problem.

@squidcc

This comment has been minimized.

@AJenbo

This comment has been minimized.

@squidcc

This comment has been minimized.

@AJenbo

This comment has been minimized.

@mewmew
Copy link
Contributor

mewmew commented Nov 19, 2018

@squidcc I don't have much experience with nmake, but would be happy to integrate it into the build process if you could submit a PR adding it? We can then later figure out how to update the docker, etc, to also include nmake, so it will be available to other OSes than Windows.

@AJenbo
Copy link
Member Author

AJenbo commented Nov 26, 2018

In an effort to make this PR more digestible I have separated out the enum.h/struct.h file changes: #479

@AJenbo
Copy link
Member Author

AJenbo commented Nov 26, 2018

The PR has been split and this now only contains variable initialization and storm changes, bring it down to +484/-324 (split over 6 commits).

@mewmew
Copy link
Contributor

mewmew commented Dec 13, 2018

@AJenbo does the project still compile with these changes? I.e. do we know how to handle linking of C/C++ code.

@AJenbo
Copy link
Member Author

AJenbo commented Dec 13, 2018

Things are still compiled as C++ but these changes are a prerequisite to switching over to compile the project as C.
The way I'm going about it is to compile a single file as C, fix all compiler errors, then make sure that the project still compiles as C++.
After this has been done we will still need to fig some general issue like INFINITY and other things I haven't been able to solve my self and at that point switch the compiler to treat all files as C.

@mewmew
Copy link
Contributor

mewmew commented Dec 13, 2018

The way I'm going about it is to compile a single file as C, fix all compiler errors, then make sure that the project still compiles as C++.

Sounds like a sound approach.

@AJenbo
Copy link
Member Author

AJenbo commented Dec 13, 2018

I'm going to split this one up one more time so that the storm.h file is separate from the others. This should also limit the changes to mostly be pulling variable declarations to the top of functions.

@AJenbo AJenbo changed the title Convert player.cpp to c-style Convert sorm.h to c-style Dec 14, 2018
@AJenbo
Copy link
Member Author

AJenbo commented Dec 14, 2018

Only storm.h is now affected in this PR, I'm closing it and opening a new one to have a clean review history for it.

@AJenbo AJenbo closed this Dec 14, 2018
@AJenbo AJenbo deleted the player.c branch December 14, 2018 01:23
@ghost
Copy link

ghost commented Jan 9, 2019

@squidcc

Hey mate, I think there is some miscommunication here. And I want to offer you a way to use your talents. It seems to many that you are unsportsmanlike or a rough to work with. This has led for a push to have you banned from the project. Please keep in mind that the team would love to have you commit and work on things because you have the ability; Your attitude though is not enjoyable . I just want to ensure that before any of that happens, that we have given a fair chance to explain our desires to not do this , but to have you on board.

Anyway about my project, you are welcome to add and make PRs. It's mainly a port to Linux but I would welcome any good clean up simplification to code if you want to do that. If you know SDL that would be awesome!

Anyway, I hate drama like I hate chick-flicks. Feel free to contribute here and you can of course help with my project if you so decide.

Cheers

https://github.com/diasurgical/devilutionX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants