// Create groupcaps table
lua_newtable(L);
// For each groupcap
- for(std::map<std::string, ToolGroupCap>::const_iterator
- i = toolcap.groupcaps.begin(); i != toolcap.groupcaps.end(); i++){
+ for (ToolGCMap::const_iterator i = toolcap.groupcaps.begin();
+ i != toolcap.groupcaps.end(); i++) {
// Create groupcap table
lua_newtable(L);
const std::string &name = i->first;
const ToolGroupCap &groupcap = i->second;
// Create subtable "times"
lua_newtable(L);
- for(std::map<int, float>::const_iterator
- i = groupcap.times.begin(); i != groupcap.times.end(); i++){
- int rating = i->first;
- float time = i->second;
- lua_pushinteger(L, rating);
- lua_pushnumber(L, time);
+ for (UNORDERED_MAP<int, float>::const_iterator
+ i = groupcap.times.begin(); i != groupcap.times.end(); i++) {
+ lua_pushinteger(L, i->first);
+ lua_pushnumber(L, i->second);
lua_settable(L, -3);
}
// Set subtable "times"
//Create damage_groups table
lua_newtable(L);
// For each damage group
- for(std::map<std::string, s16>::const_iterator
- i = toolcap.damageGroups.begin(); i != toolcap.damageGroups.end(); i++){
+ for (DamageGroup::const_iterator i = toolcap.damageGroups.begin();
+ i != toolcap.damageGroups.end(); i++) {
// Create damage group table
lua_pushinteger(L, i->second);
lua_setfield(L, -2, i->first.c_str());
#include "util/string.h"
#include "threading/mutex.h"
#include <string>
-#include <map>
+#include "util/cpp11_container.h"
#include <list>
#include <set>
>
> SettingsCallbackList;
-typedef std::map<std::string, SettingsCallbackList> SettingsCallbackMap;
+typedef UNORDERED_MAP<std::string, SettingsCallbackList> SettingsCallbackMap;
enum ValueType {
VALUETYPE_STRING,
#include "log.h"
#include "util/numeric.h" // myrand()
#include "porting.h"
-#include <map>
#include <vector>
#include <fstream>
+#include "util/cpp11_container.h"
#define BUFFER_SIZE 30000
ALCdevice *m_device;
ALCcontext *m_context;
int m_next_id;
- std::map<std::string, std::vector<SoundBuffer*> > m_buffers;
- std::map<int, PlayingSound*> m_sounds_playing;
+ UNORDERED_MAP<std::string, std::vector<SoundBuffer*> > m_buffers;
+ UNORDERED_MAP<int, PlayingSound*> m_sounds_playing;
v3f m_listener_pos;
public:
bool m_is_initialized;
alcCloseDevice(m_device);
m_device = NULL;
- for (std::map<std::string, std::vector<SoundBuffer*> >::iterator i = m_buffers.begin();
+ for (UNORDERED_MAP<std::string, std::vector<SoundBuffer*> >::iterator i = m_buffers.begin();
i != m_buffers.end(); ++i) {
for (std::vector<SoundBuffer*>::iterator iter = (*i).second.begin();
iter != (*i).second.end(); ++iter) {
void addBuffer(const std::string &name, SoundBuffer *buf)
{
- std::map<std::string, std::vector<SoundBuffer*> >::iterator i =
+ UNORDERED_MAP<std::string, std::vector<SoundBuffer*> >::iterator i =
m_buffers.find(name);
if(i != m_buffers.end()){
i->second.push_back(buf);
SoundBuffer* getBuffer(const std::string &name)
{
- std::map<std::string, std::vector<SoundBuffer*> >::iterator i =
+ UNORDERED_MAP<std::string, std::vector<SoundBuffer*> >::iterator i =
m_buffers.find(name);
if(i == m_buffers.end())
return NULL;
void deleteSound(int id)
{
- std::map<int, PlayingSound*>::iterator i =
- m_sounds_playing.find(id);
+ UNORDERED_MAP<int, PlayingSound*>::iterator i = m_sounds_playing.find(id);
if(i == m_sounds_playing.end())
return;
PlayingSound *sound = i->second;
<<m_sounds_playing.size()<<" playing sounds, "
<<m_buffers.size()<<" sound names loaded"<<std::endl;
std::set<int> del_list;
- for(std::map<int, PlayingSound*>::iterator
- i = m_sounds_playing.begin();
- i != m_sounds_playing.end(); ++i)
- {
+ for(UNORDERED_MAP<int, PlayingSound*>::iterator i = m_sounds_playing.begin();
+ i != m_sounds_playing.end(); ++i) {
int id = i->first;
PlayingSound *sound = i->second;
// If not playing, remove it
}
void updateSoundPosition(int id, v3f pos)
{
- std::map<int, PlayingSound*>::iterator i =
- m_sounds_playing.find(id);
- if(i == m_sounds_playing.end())
+ UNORDERED_MAP<int, PlayingSound*>::iterator i = m_sounds_playing.find(id);
+ if (i == m_sounds_playing.end())
return;
PlayingSound *sound = i->second;
writeF1000(os, full_punch_interval);
writeS16(os, max_drop_level);
writeU32(os, groupcaps.size());
- for(std::map<std::string, ToolGroupCap>::const_iterator
- i = groupcaps.begin(); i != groupcaps.end(); ++i){
+ for (ToolGCMap::const_iterator i = groupcaps.begin(); i != groupcaps.end(); ++i) {
const std::string *name = &i->first;
const ToolGroupCap *cap = &i->second;
os<<serializeString(*name);
writeS16(os, cap->uses);
writeS16(os, cap->maxlevel);
writeU32(os, cap->times.size());
- for(std::map<int, float>::const_iterator
- i = cap->times.begin(); i != cap->times.end(); ++i){
+ for (UNORDERED_MAP<int, float>::const_iterator
+ i = cap->times.begin(); i != cap->times.end(); ++i) {
writeS16(os, i->first);
writeF1000(os, i->second);
}
}
if(protocol_version > 17){
writeU32(os, damageGroups.size());
- for(std::map<std::string, s16>::const_iterator
- i = damageGroups.begin(); i != damageGroups.end(); ++i){
+ for (DamageGroup::const_iterator i = damageGroups.begin();
+ i != damageGroups.end(); ++i) {
os<<serializeString(i->first);
writeS16(os, i->second);
}
default:
break;
}
-
+
// Values to be returned (with a bit of conversion)
bool result_diggable = false;
float result_time = 0.0;
int level = itemgroup_get(groups, "level");
//infostream<<"level="<<level<<std::endl;
- for(std::map<std::string, ToolGroupCap>::const_iterator
- i = tp->groupcaps.begin(); i != tp->groupcaps.end(); ++i){
+ for (ToolGCMap::const_iterator i = tp->groupcaps.begin();
+ i != tp->groupcaps.end(); ++i) {
const std::string &name = i->first;
//infostream<<"group="<<name<<std::endl;
const ToolGroupCap &cap = i->second;
s16 damage = 0;
float full_punch_interval = tp->full_punch_interval;
- for(std::map<std::string, s16>::const_iterator
- i = tp->damageGroups.begin(); i != tp->damageGroups.end(); ++i){
+ for (DamageGroup::const_iterator i = tp->damageGroups.begin();
+ i != tp->damageGroups.end(); ++i) {
s16 armor = itemgroup_get(armor_groups, i->first);
damage += i->second * rangelim(time_from_last_punch / full_punch_interval, 0.0, 1.0)
* armor / 100.0;
do_hit = false;
}
}
-
+
PunchDamageResult result;
if(do_hit)
{
#include "irrlichttypes.h"
#include <string>
#include <iostream>
-#include <map>
+#include "util/cpp11_container.h"
#include "itemgroup.h"
struct ToolGroupCap
{
- std::map<int, float> times;
+ UNORDERED_MAP<int, float> times;
int maxlevel;
int uses;
bool getTime(int rating, float *time) const
{
- std::map<int, float>::const_iterator i = times.find(rating);
- if(i == times.end()){
+ UNORDERED_MAP<int, float>::const_iterator i = times.find(rating);
+ if (i == times.end()) {
*time = 0;
return false;
}
};
-// CLANG SUCKS DONKEY BALLS
-typedef std::map<std::string, struct ToolGroupCap> ToolGCMap;
-typedef std::map<std::string, s16> DamageGroup;
+typedef UNORDERED_MAP<std::string, struct ToolGroupCap> ToolGCMap;
+typedef UNORDERED_MAP<std::string, s16> DamageGroup;
struct ToolCapabilities
{
float full_punch_interval;
int max_drop_level;
- // CLANG SUCKS DONKEY BALLS
ToolGCMap groupcaps;
DamageGroup damageGroups;
ToolCapabilities(
float full_punch_interval_=1.4,
int max_drop_level_=1,
- // CLANG SUCKS DONKEY BALLS
ToolGCMap groupcaps_=ToolGCMap(),
DamageGroup damageGroups_=DamageGroup()
):