Author Topic: Custom soldier names  (Read 5727 times)

Offline Sharp

  • Colonel
  • ****
  • Posts: 181
    • View Profile
Custom soldier names
« on: October 16, 2013, 04:59:40 pm »
I know you can create/edit/delete the .nam files but I was wondering if there was a cleaner way of being able to choose names from a pool instead of just random generation.

A hack way to do it is put in the custom names you want as first-names then get rid of all the last names except for one which you can put SOH or STX control char, this makes it appear invisible although has interesting results, using SOH means any text after will appear white in battle-scape while in soldier list in base-scape it can be other colours (has been dark blue with highlight and orange for me so far). Using STX means any text after actually appears below the soldier name.

Is there a way to modify it so YAML is just happy with nothing in last-name so you don't even get a space?

The hacks work fine and have interesting results. I wonder what else can be done as this does look like a case of not filtering input (not a big deal for a game on your own computer though), this does seem coincidental with me just recently watching videos on SQL Injection as well :P

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
Re: Custom soldier names
« Reply #1 on: October 16, 2013, 08:35:16 pm »
If you call a hack using control characters for what they're for, sure. You can also just use non-printable characters that have no effect like a space. Or just use "maleLast: []".

Offline Sharp

  • Colonel
  • ****
  • Posts: 181
    • View Profile
Re: Custom soldier names
« Reply #2 on: October 16, 2013, 10:10:04 pm »
Well I can't get maleLast: [] to work, it either comes up with a YAML error or crashes on starting a game.

Unless you mean maleLast in the actual code which I could do maybe. I would also have the additional if femaleFirst.empty() then femaleFirst = maleFirst as well

I can't actually find a non-prinable character which has no effect, NULL has YAML error (although it actually says what line and column is the problem!) and only SOH and STX appear blank (although are actually doing seperate things) YAML won't accept space and I haven't tested all of them but most of the other control characters which are supposed to be non-printing will print a ?.

Still SOH and STX work but yeah I would call them hacks when I have to use them instead of space or NULL to work :P

Offline moriarty

  • Commander
  • *****
  • Posts: 1421
    • View Profile
    • Luke's OX mod site
Re: Custom soldier names
« Reply #3 on: October 16, 2013, 11:05:23 pm »
Well I can't get maleLast: [] to work, it either comes up with a YAML error or crashes on starting a game.

did you try a null quote with {} ? I think that was the solution to another problem recently.

Offline Sharp

  • Colonel
  • ****
  • Posts: 181
    • View Profile
Re: Custom soldier names
« Reply #4 on: October 16, 2013, 11:39:24 pm »
I tried lots of variations.

maleLast: []
maleLast: [NULL(control char not just writing null)]
maleLast:{}
maleLast: {NULL}
maleLast:
 - NULL

etc....

some of them came with YAML errors and other crashed on starting a game, the only ones which have worked are SOH and STX, the other control chars will print a ?.

Anyway it's not a big issue, the hack works and at the very least if anyone wants to do something similar they can see a hack version of doing it.

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
Re: Custom soldier names
« Reply #5 on: October 17, 2013, 10:42:38 pm »
Ok I fixed it so you can just omit the maleLast now.

Offline Sharp

  • Colonel
  • ****
  • Posts: 181
    • View Profile
Re: Custom soldier names
« Reply #6 on: October 17, 2013, 10:48:55 pm »
Cool thx :D

I think I will still save SOH for special soldiers though, but don't worry, not going to ask for a code change to allow control char in-game entry :P