Fix horrible errors and make MSVC shut upt about non-issues.

develop
Petr Mrázek 2012-03-01 01:29:55 +01:00
parent c6fd508ee3
commit 2682c54fce
6 changed files with 35 additions and 44 deletions

@ -104,7 +104,7 @@ void cheap_tokenise(string const& input, vector<string> &output)
string *cur = NULL; string *cur = NULL;
for (size_t i = 0; i < input.size(); i++) { for (size_t i = 0; i < input.size(); i++) {
char c = input[i]; unsigned char c = input[i];
if (isspace(c)) { if (isspace(c)) {
cur = NULL; cur = NULL;
} else { } else {
@ -470,28 +470,11 @@ static void runInteractiveCommand(Core *core, PluginManager *plug_mgr, int &clue
} }
else else
{ {
vector <string> parts; command_result res = plug_mgr->InvokeCommand(first, parts);
cheap_tokenise(command,parts); if(res == CR_NOT_IMPLEMENTED)
if(parts.size() == 0)
{ {
clueless_counter++; con.printerr("%s is not a recognized command.\n", first.c_str());
} clueless_counter ++;
else
{
string first = parts[0];
parts.erase(parts.begin());
command_result res = plug_mgr->InvokeCommand(first, parts);
if(res == CR_NOT_IMPLEMENTED)
{
con.printerr("%s is not a recognized command.\n", first.c_str());
clueless_counter ++;
}
/*
else if(res == CR_FAILURE)
{
con.printerr("ERROR!\n");
}
*/
} }
} }
} }

@ -60,7 +60,6 @@ void VersionInfoFactory::clear()
VersionInfo * VersionInfoFactory::getVersionInfoByMD5(string hash) VersionInfo * VersionInfoFactory::getVersionInfoByMD5(string hash)
{ {
VersionInfo * vinfo;
for(size_t i = 0; i < versions.size();i++) for(size_t i = 0; i < versions.size();i++)
{ {
if(versions[i]->hasMD5(hash)) if(versions[i]->hasMD5(hash))
@ -167,7 +166,6 @@ bool VersionInfoFactory::loadFile(string path_to_xml)
TiXmlHandle hDoc(&doc); TiXmlHandle hDoc(&doc);
TiXmlElement* pElem; TiXmlElement* pElem;
TiXmlHandle hRoot(0); TiXmlHandle hRoot(0);
VersionInfo *mem;
// block: name // block: name
{ {

@ -29,6 +29,7 @@ distribution.
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <sstream> #include <sstream>
#include <exception>
//#include <ostream> //#include <ostream>
namespace DFHack namespace DFHack
{ {
@ -62,7 +63,10 @@ namespace DFHack
{ {
if (newsize == size) if (newsize == size)
return; return;
bits = (uint8_t*)realloc(bits, newsize); uint8_t* mem = (uint8_t *) realloc(bits, newsize);
if(!mem)
throw std::bad_alloc();
bits = mem;
if (newsize > size) if (newsize > size)
memset(bits+size, 0, newsize-size); memset(bits+size, 0, newsize-size);
size = newsize; size = newsize;
@ -197,7 +201,10 @@ namespace DFHack
} }
else else
{ {
m_data = (T*)realloc(m_data, sizeof(T)*new_size); T* mem = (T*) realloc(m_data, sizeof(T)*new_size);
if(!mem)
throw std::bad_alloc();
m_data = mem;
} }
if (new_size > m_size) if (new_size > m_size)
memset(m_data+sizeof(T)*m_size, 0, sizeof(T)*(new_size - m_size)); memset(m_data+sizeof(T)*m_size, 0, sizeof(T)*(new_size - m_size));

@ -51,6 +51,9 @@ distribution.
#pragma warning( disable: 4068 ) #pragma warning( disable: 4068 )
// no signed value outside enum range bs // no signed value outside enum range bs
#pragma warning( disable: 4341) #pragma warning( disable: 4341)
// just shut up already.
#pragma warning( disable: 4244)
#pragma warning( disable: 4018)
#endif #endif
#endif #endif

@ -241,19 +241,19 @@ df::job *DFHack::getSelectedJob(Core *c, bool quiet)
{ {
df::viewscreen *top = c->getTopViewscreen(); df::viewscreen *top = c->getTopViewscreen();
if (VIRTUAL_CAST_VAR(screen, df::viewscreen_joblistst, top)) if (VIRTUAL_CAST_VAR(joblist, df::viewscreen_joblistst, top))
{ {
df::job *job = vector_get(screen->jobs, screen->cursor_pos); df::job *job = vector_get(joblist->jobs, joblist->cursor_pos);
if (!job && !quiet) if (!job && !quiet)
c->con.printerr("Selected unit has no job\n"); c->con.printerr("Selected unit has no job\n");
return job; return job;
} }
else if (VIRTUAL_CAST_VAR(screen, df::viewscreen_unitlistst, top)) else if (VIRTUAL_CAST_VAR(unitlist, df::viewscreen_unitlistst, top))
{ {
int page = screen->page; int page = unitlist->page;
df::job *job = vector_get(screen->jobs[page], screen->cursor_pos[page]); df::job *job = vector_get(unitlist->jobs[page], unitlist->cursor_pos[page]);
if (!job && !quiet) if (!job && !quiet)
c->con.printerr("Selected unit has no job\n"); c->con.printerr("Selected unit has no job\n");

@ -771,19 +771,19 @@ bool Materials::ReadCreatureTypesEx (void)
caste.recuperation[k] = ca->attributes.phys_att_range[physical_attribute_type::RECUPERATION][k]; caste.recuperation[k] = ca->attributes.phys_att_range[physical_attribute_type::RECUPERATION][k];
caste.disease_resistance[k] = ca->attributes.phys_att_range[physical_attribute_type::DISEASE_RESISTANCE][k]; caste.disease_resistance[k] = ca->attributes.phys_att_range[physical_attribute_type::DISEASE_RESISTANCE][k];
caste.analytical_ability[k] = ca->attributes.phys_att_range[mental_attribute_type::ANALYTICAL_ABILITY][k]; caste.analytical_ability[k] = ca->attributes.ment_att_range[mental_attribute_type::ANALYTICAL_ABILITY][k];
caste.focus[k] = ca->attributes.phys_att_range[mental_attribute_type::FOCUS][k]; caste.focus[k] = ca->attributes.ment_att_range[mental_attribute_type::FOCUS][k];
caste.willpower[k] = ca->attributes.phys_att_range[mental_attribute_type::WILLPOWER][k]; caste.willpower[k] = ca->attributes.ment_att_range[mental_attribute_type::WILLPOWER][k];
caste.creativity[k] = ca->attributes.phys_att_range[mental_attribute_type::CREATIVITY][k]; caste.creativity[k] = ca->attributes.ment_att_range[mental_attribute_type::CREATIVITY][k];
caste.intuition[k] = ca->attributes.phys_att_range[mental_attribute_type::INTUITION][k]; caste.intuition[k] = ca->attributes.ment_att_range[mental_attribute_type::INTUITION][k];
caste.patience[k] = ca->attributes.phys_att_range[mental_attribute_type::PATIENCE][k]; caste.patience[k] = ca->attributes.ment_att_range[mental_attribute_type::PATIENCE][k];
caste.memory[k] = ca->attributes.phys_att_range[mental_attribute_type::MEMORY][k]; caste.memory[k] = ca->attributes.ment_att_range[mental_attribute_type::MEMORY][k];
caste.linguistic_ability[k] = ca->attributes.phys_att_range[mental_attribute_type::LINGUISTIC_ABILITY][k]; caste.linguistic_ability[k] = ca->attributes.ment_att_range[mental_attribute_type::LINGUISTIC_ABILITY][k];
caste.spatial_sense[k] = ca->attributes.phys_att_range[mental_attribute_type::SPATIAL_SENSE][k]; caste.spatial_sense[k] = ca->attributes.ment_att_range[mental_attribute_type::SPATIAL_SENSE][k];
caste.musicality[k] = ca->attributes.phys_att_range[mental_attribute_type::MUSICALITY][k]; caste.musicality[k] = ca->attributes.ment_att_range[mental_attribute_type::MUSICALITY][k];
caste.kinesthetic_sense[k] = ca->attributes.phys_att_range[mental_attribute_type::KINESTHETIC_SENSE][k]; caste.kinesthetic_sense[k] = ca->attributes.ment_att_range[mental_attribute_type::KINESTHETIC_SENSE][k];
caste.empathy[k] = ca->attributes.phys_att_range[mental_attribute_type::EMPATHY][k]; caste.empathy[k] = ca->attributes.ment_att_range[mental_attribute_type::EMPATHY][k];
caste.social_awareness[k] = ca->attributes.phys_att_range[mental_attribute_type::SOCIAL_AWARENESS][k]; caste.social_awareness[k] = ca->attributes.ment_att_range[mental_attribute_type::SOCIAL_AWARENESS][k];
} }
mat.castes.push_back(caste); mat.castes.push_back(caste);
} }