try to clean a little the code...

This commit is contained in:
ALONSO Laurent
2021-10-27 09:37:42 +02:00
committed by Celtic Minstrel
parent db5dd1e273
commit 8e2cdca1f8
6 changed files with 17 additions and 41 deletions

View File

@@ -100,6 +100,10 @@ unsigned char applyShift(unsigned char c){
'~', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~',
};
if (c<' ')
return ' ';
if (c>=0x7f)
return c;
return afterShift[c - ' '];
}
@@ -112,5 +116,9 @@ unsigned char removeShift(unsigned char c){
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '[', '\\',']', '`',
};
if (c<' ')
return ' ';
if (c>=0x7f)
return c;
return afterUnShift[c - ' '];
}

View File

@@ -86,4 +86,6 @@ bool operator== (cKey a, cKey b);
/// @return true if the needle is in the haystack
bool mod_contains(eKeyMod haystack, eKeyMod needle);
unsigned char applyShift(unsigned char c);
unsigned char removeShift(unsigned char c);
#endif

View File

@@ -238,39 +238,6 @@ bool cControl::handleClick(location){
return clicked;
}
static unsigned char applyShift(unsigned char c){
static const char afterShift[] = {
' ', '!', '"', '#', '$', '%', '&', '"', '(', ')', '*', '+', '<', '_', '>', '?',
')', '!', '@', '#', '$', '%', '^', '&', '*', '(', ':', ':', '<', '+', '>', '?',
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '^', '_',
'~', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~',
};
if (c<' ')
return ' ';
if (c>=0x7f)
return c;
return afterShift[c - ' '];
}
static unsigned char removeShift(unsigned char c){
static const char afterUnShift[] = {
' ', '1', '\'','3', '4', '5', '7', '\'','9', '0', '8', '=', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ';', ';', ',', '=', '.', '/',
'2', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '[', '\\',']', '6', '-',
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '[', '\\',']', '`',
};
// ASAN: c can be called with 0 by cControl::getAttachedKeyDescription()
if (c<' ')
return ' ';
if (c>=0x7f)
return c;
return afterUnShift[c - ' '];
}
std::string cControl::getAttachedKeyDescription() {
std::string s;
if(key.spec) {

View File

@@ -1,5 +1,7 @@
#include <SFML/Graphics/RenderWindow.hpp>
#include "global.hpp"
#include "fields.hpp"
#include "location.hpp"

View File

@@ -1167,15 +1167,12 @@ void cUniverse::exportGraphics() {
used_graphics.insert(party[i].which_graphic - 10000 + j);
} else if(party[i].which_graphic >= 1000)
update_pcs[party[i].which_graphic - 1000].insert(&party[i]);
for(size_t j = 0; j < party[i].items.size(); j++) {
check_item(party[i].items[j]);
}
}
for(size_t i = 0; i < party.stored_items.size(); i++) {
for(size_t j = 0; j < party.stored_items[i].size(); j++) {
check_item(party.stored_items[i][j]);
}
for (auto &item : party[i].items)
check_item(item);
}
for (auto &items : party.stored_items)
for (auto &item : items)
check_item(item);
for(mon_num_t monst : party.imprisoned_monst) {
if(monst > 0 && monst < scenario.scen_monsters.size())
check_monst(scenario.scen_monsters[monst]);