Andrettin / Wyrmsun

Strategy game based on history, mythology and fiction
http://andrettin.github.io/
GNU General Public License v2.0
307 stars 48 forks source link

Filter input during hero creation #50

Closed KroArtem closed 8 years ago

KroArtem commented 8 years ago

It's possible to create custom hero with just spaces, so it looks odd with no name and surname. I suggest trimming spaces or doing a simple check.

KroArtem commented 8 years ago

I'm rephrasing this ticket as there could be some problems when creating non-standard heroes. Let's say I want to create a hero with name ../Modsognir, it will rewrite an existing Modsognir hero.

Luckily it's not possible to rewrite savegames as delimiters like \n doesn't seem to work in user input.

Another thing is that when you create an inappropriate hero with name e.g. /\/\yCoolHero, its' profile won't be created and it will be accessible only during this launch.

Andrettin commented 8 years ago

You are right, those are serious concerns. Thanks for bringing this up!

I've fixed the issue now, and also made the check which sees whether another hero of the same name exists case-insensitive (since Windows cannot have two files with the same name even if they are written with letters in different cases).

I've also added a check to see if the name has only spaces in it.

https://github.com/Andrettin/Wyrmsun/commit/7e7a5158ca43e127f412e9d3841d510266f0c48c https://github.com/Andrettin/Wyrmsun/commit/0cdabf54fb7f5c0a8f6432b8f3e58dd0b21a1672 https://github.com/Andrettin/Wyrmgus/commit/b3403364157da94e1722dd35b3a5de483e87abc8

KroArtem commented 8 years ago

Is it ok that hero can have empty name with space in it and valid surname? Usually name is required, surname is optional. Other cases seem to be covered now.

Andrettin commented 8 years ago

Now that you mention it, that shouldn't be possible, thanks for letting me know. I've fixed it now: https://github.com/Andrettin/Wyrmgus/commit/7b2d306079204bc01e4a0966f437ed0101bca2f1

KroArtem commented 8 years ago

Well, I'm still not satisfied. ;) If I try to create any hero I don't get anything except "error in error handling" in terminal.

Andrettin commented 8 years ago

Ops, I forgot to upload the corresponding Wyrmsun repository commit: https://github.com/Andrettin/Wyrmsun/commit/65aa3d35632f8feda3600f2620a0f399ef000d38