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

Tileset loading refactoring #13151

Merged

Conversation

Projects
None yet
8 participants
@VlasovVitaly
Copy link
Contributor

commented Aug 1, 2015

This is fix of #12800

After merging all tilesets authors MUST write path in config files strongly relative.

Tested on Linux.

TODO:

  • Replace all paths in JSON and TILESET values in all tileset.txt files to related values.
  • Replace all path from json configs to related values
  • New var in FILENAMES which contain default config name.
  • New global mapping TILESETS(string, string) which store all tilesets names and their directories with PREFIX support.
  • Cache TILESETS mapping at options loading time.
  • Refactoring of get_tile_information() and other function related to tilesets path.
  • Doxygen documentation.
@VlasovVitaly

This comment has been minimized.

Copy link
Owner Author

commented on src/path_info.cpp in e7ff724 Aug 1, 2015

Not so sure about that ifdef, but works for me. Linux curses, sdl builds

VlasovVitaly added some commits Aug 1, 2015

Not related to PR. Minior fixes in options.
initOptions() renames to init_options(), like save_options(), load_options() and others.
options_data::* moved to begin of file like other classes methods.
New global vat TILESE. Contail all tilesets found.
New function in options that fill TILESETS mapping.
Move some functional into upper level(init()).
Removed ags from init() and reinit(). Used FILENAMES["gfxdir"] instead.
Fixed headers.
Build is broken with -WError.
@VlasovVitaly

This comment has been minimized.

Copy link
Contributor Author

commented Aug 1, 2015

Ok. Test this on Linux with and without PREFIX, with make and cmake build.
Right now i am wrinting doxygen and fixing var names and making minor changes. This can be done by separate PR,

All working. So Request for comment and testers. Need tests on Windows (with and without CLion) and MacOSX

@VlasovVitaly VlasovVitaly changed the title [WIP] Tileset loading refactoring [RFC] Tileset loading refactoring Aug 1, 2015

@chaosvolt

This comment has been minimized.

Copy link
Contributor

commented Aug 1, 2015

After merging all tilesets authors MUST write path in config files strongly relative.

If you're relying on all the tileset authors fixing this on their end instead of adding the required tweaks in this PR, things is going to break royally. :V

@narc0tiq

This comment has been minimized.

Copy link
Contributor

commented Aug 1, 2015

We'll fix the ones we're including, but we can't cleanly allow a legacy
option here (and things were fairly broken before, so keeping that legacy
means keeping known-bad code).

On Sat, Aug 1, 2015 at 6:54 PM Chaosvolt notifications@github.com wrote:

After merging all tilesets authors MUST write path in config files
strongly relative.

If you're relying on all the tileset authors fixing this on their end
instead of adding the required tweaks in this PR, things is going to break
royally. :V


Reply to this email directly or view it on GitHub
#13151 (comment)
.

@chaosvolt

This comment has been minimized.

Copy link
Contributor

commented Aug 1, 2015

Ah, so this will only be a hazard to modders making their own tilesets that haven't been PR'd, then?

@narc0tiq

This comment has been minimized.

Copy link
Contributor

commented Aug 1, 2015

Yes. You can see the diff on this PR: it updates all the tilesets to use the correct kind of references, right from the first commit (2751bf3).

@chaosvolt

This comment has been minimized.

Copy link
Contributor

commented Aug 1, 2015

Ah, right. Doh. >.<

void options_data::add_value( const std::string &lvar, const std::string &lval,
std::string lvalname )
{
static const std::string blank_value( 1, 001 );

This comment has been minimized.

Copy link
@DavidKeaton

DavidKeaton Aug 1, 2015

Contributor

you could move this to the top of the source, so the entire source can reference the same one, as you use this more than once! :-)

This comment has been minimized.

Copy link
@VlasovVitaly

VlasovVitaly Aug 2, 2015

Author Contributor

This piece of code is move on top. Was on bottom of file.

This comment has been minimized.

Copy link
@BevapDin

BevapDin Aug 7, 2015

Contributor

Why exactly did you move the definitions of those options_data functions? They can be "used" once they have been declared (which happens in option.h, which is include at the very top of this file), the place of their definition does not matter at all. Have those functions actually been changed?

@chaosvolt

This comment has been minimized.

Copy link
Contributor

commented Aug 1, 2015

Hmm. Just realized, I have been finding yet more stuff I oughta add to a tileset update, which I was planning to do when I wasn't juggling half a dozen PRs. Though to avoid breaking stuff, I'll want to wait until after this is merged since it includes edits to tile_config.

Good, gives me more time for spriting. I am going to dread the day I stop putting off making sprites for the animatronic and dinosaur mods. XP

@VlasovVitaly VlasovVitaly changed the title [RFC] Tileset loading refactoring Tileset loading refactoring Aug 2, 2015

VlasovVitaly added some commits Aug 2, 2015

@VlasovVitaly

This comment has been minimized.

Copy link
Contributor Author

commented Aug 5, 2015

Was merged with upstream.

@chaosvolt

This comment has been minimized.

Copy link
Contributor

commented Aug 5, 2015

Doh? Such confuse, very derp. :V

EDIT: You sure any of this has been merged? Doesn't look like it.

@Zireael07

This comment has been minimized.

Copy link
Contributor

commented Aug 5, 2015

Not merged into master, master merged into it to avoid any conflicts.

@chaosvolt

This comment has been minimized.

Copy link
Contributor

commented Aug 5, 2015

Ah right.

@@ -456,7 +500,81 @@ bool cOpt::operator!=(const std::string sCompare) const
return !(*this == sCompare);
}

void initOptions()
/** Fill TILESETS mapping with values.
* Scans all directores in gfx directory for file named "tileset.txt".

This comment has been minimized.

Copy link
@BevapDin

BevapDin Aug 7, 2015

Contributor

Actually it scans the FILENAMES["gfxdir"] directory for files names FILENAMES["tileset-conf"]. Both entries of the FILENAMES map may contain any string, not just "gfx" and "tileset.txt".

This comment has been minimized.

Copy link
@VlasovVitaly

VlasovVitaly Aug 7, 2015

Author Contributor

Yeah. Trying to make this description shorter. Guess it's better to fix that message.


fin.open( file.c_str() );
if(!fin.is_open()) {
fin.close();

This comment has been minimized.

Copy link
@BevapDin

BevapDin Aug 7, 2015

Contributor

It's not open, why close it?

This comment has been minimized.

Copy link
@VlasovVitaly

VlasovVitaly Aug 7, 2015

Author Contributor

This is old behavior. Really i don't know why close() is calling. Will be fixed.


if(tileset_names == "") {
optionNames["deon"] = _("Deon's"); // more standards
optionNames["hoder"] = _("Hoder's");

This comment has been minimized.

Copy link
@BevapDin

BevapDin Aug 7, 2015

Contributor

Hmmm, those are the only translated tileset names. The other tileset go untranslated. Either they should not be translated at all (they are names anyway), or the lang/extract_json_strings.py or lang/update_pot.sh need to be changed to extract the tileset names. See also line 554, where untranslated entries are added to optionNames.

This comment has been minimized.

Copy link
@VlasovVitaly

VlasovVitaly Aug 8, 2015

Author Contributor

Hmm. I have found that several languages have own translation of "Deon's" and "Hoder's" strings.
I will add viewname to extractor in separate PR.

if (sOption.find("NAME") != std::string::npos) {
tileset_name = "";
fin >> tileset_name;
if(first_tileset_name) {

This comment has been minimized.

Copy link
@BevapDin

BevapDin Aug 7, 2015

Contributor

Instead of having first_tileset_name (and setting it correctly), why don't you just check tileset_names.empty()? If it's empty, the current tileset is the first and no "," needs to be added.

This comment has been minimized.

Copy link
@VlasovVitaly

VlasovVitaly Aug 7, 2015

Author Contributor

Yeah. Is't better. Will be fixed.

*/
void load_tilejson_from_file(std::ifstream &f, const std::string &imagepath);
void load_tilejson_from_file(const std::string tileset_dir, std::ifstream &f, const std::string &image_path);

This comment has been minimized.

Copy link
@BevapDin

BevapDin Aug 7, 2015

Contributor

As you already made it const, it should also be a reference, not a copy. Just like image_path.

This comment has been minimized.

Copy link
@VlasovVitaly

VlasovVitaly Aug 7, 2015

Author Contributor

Ok. i will fix that.
Where i can read about this difference. Any link?

@kevingranade kevingranade merged commit ca58abb into CleverRaven:master Aug 7, 2015

1 check passed

default
Details
@chaosvolt

This comment has been minimized.

Copy link
Contributor

commented Aug 7, 2015

Ah delicious, more things to give me plenty of time to work on my tileset updates. Still only halfway done. XP

@VlasovVitaly

This comment has been minimized.

Copy link
Contributor Author

commented Aug 7, 2015

Fixes from @BevapDin will be in separate PR.

So at this moment paths in all new tileset must be related.
@chaosvolt @kevingranade please warn authors in IRC and forum.

@chaosvolt

This comment has been minimized.

Copy link
Contributor

commented Aug 7, 2015

please warm authors in IRC and forum.

So long as they don't give me the cold shoulder, I guess I'll do so. XP

@VlasovVitaly

This comment has been minimized.

Copy link
Contributor Author

commented Aug 7, 2015

:p

@chaosvolt

This comment has been minimized.

Copy link
Contributor

commented Aug 7, 2015

Posted a thread in Lab forum, hope that's the ideal spot in the forums for said warning. I've never actually mucked about on the IRC, so...

@CIB

This comment has been minimized.

Copy link
Contributor

commented Aug 8, 2015

Should be fairly easy to write a small script for conversion.. It's JSON, after all, can be read and written in any language.

@VlasovVitaly VlasovVitaly referenced this pull request Aug 8, 2015

Merged

Fixups after 13151 #13219

@VlasovVitaly VlasovVitaly deleted the VlasovVitaly:fix-filenames-tiles-loading branch Aug 11, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.