equalpants / pigmap

Minecraft map generator
https://github.com/equalpants/pigmap/wiki/Example-maps
GNU General Public License v3.0
129 stars 43 forks source link

Won't compile - overloaded tostring function ambiguous #19

Closed Drakonas closed 13 years ago

Drakonas commented 13 years ago

Server output: g++ -c pigmap.cpp -O3 In file included from blockimages.h:23, from pigmap.cpp:45: rgba.h:91:17: warning: no newline at end of file In file included from pigmap.cpp:45: blockimages.h:189:24: warning: no newline at end of file In file included from pigmap.cpp:47: map.h:331:16: warning: no newline at end of file In file included from pigmap.cpp:49: tables.h:376:19: warning: no newline at end of file In file included from chunk.h:28, from pigmap.cpp:50: region.h:100:19: warning: no newline at end of file In file included from pigmap.cpp:50: chunk.h:154:18: warning: no newline at end of file In file included from pigmap.cpp:51: render.h:210:19: warning: no newline at end of file In file included from pigmap.cpp:52: world.h:69:18: warning: no newline at end of file pigmap.cpp: In function âvoid writeHTML(const RenderJob&, const std::string&)â: pigmap.cpp:382: error: call of overloaded âtostring(time_t)â is ambiguous utils.h:71: note: candidates are: std::string tostring(int) utils.h:72: note: std::string tostring(int64_t) make: *\ [pigmap.o] Error 1

I was able to get it to compile by commenting out line 72 of utils.h, except it has a runtime error when trying to generate tiles: [*]/pigmap/terrain/blocks-6.png is missing some blocks; will try to fill them in from terrain.png region-format world detected processing regionlist... rendering tiles... single thread will render 776 base tiles terminate called after throwing an instance of 'std::bad_alloc' what(): St9bad_alloc

This needs to be fixed. I don't think anybody is able to use pigmap at this point, but I'm not sure why I haven't heard anything about it.

Thanks in advance, Drakonas

equalpants commented 13 years ago

The bug is in your code, not mine. You need to resolve the ambiguity on line pigmap.cpp:382 by explicitly casting your time_t to either int or int64_t.

Here are some good resources for learning C++: http://www.cplusplus.com/

http://www.parashift.com/c++-faq-lite/

equalpants commented 13 years ago

P.S. Github has a useful tool called "blame" for determining which code is yours and which comes from upstream. If you view a source file, there's a "blame" button at the top-right of the file, on the same line as the file size/line count; clicking this will show you which commit every line of code came from.

equalpants commented 13 years ago

Uh, just realized that the code you're compiling isn't even in your repo, so that last comment isn't useful. Git itself also has "blame", of course, so you can use it on your working copy. Here are the instructions:

http://www.kernel.org/pub/software/scm/git/docs/git-blame.html

Drakonas commented 13 years ago

Hmm.. Ok, I forgot I had some changes with my pigmap. I apologize for that.

Thanks for the help. I can take care of it then.

Drakonas commented 13 years ago

I stashed my changes to try and fix it (first post), and returned to where I was with the error on compiling. I explicitely casted the returned time_t value to int, with luck on compiling, but I still get the same error when running pigmap. I'm going to contact Billiam, and see if I can figure out what's wrong. He is the one I got the other pieces of code from.

equalpants commented 13 years ago

bad_alloc is thrown when new (or new[]) can't allocate the requested amount of memory. The most likely causes are:

  1. actually ran out of memory
  2. accidentally asked new[] for some outrageously huge amount of memory, probably due to the variable holding the requested size being uninitialized or getting trashed somehow pigmap needs somewhere around 250-300 MB per thread, so probably you're not running out of memory with only a single thread, but if this is a lower-end VPS you're using, maybe it's possible. Quickest way to find out which allocation is going wrong is with an actual debugger like gdb, but printf/cout-style debugging will be good enough for this problem.