Proposed fix for coverity #29372
[supertux.git] / src / scripting / scripting.cpp
index 4efac9a..b19c13b 100644 (file)
@@ -23,7 +23,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 
-#include "physfs/ifile_stream.hpp"
+#include "physfs/buffered_ifile_stream.hpp"
 #include "scripting/squirrel_error.hpp"
 #include "scripting/wrapper.hpp"
 #include "squirrel_util.hpp"
@@ -48,7 +48,7 @@ void printfunc(HSQUIRRELVM, const char* fmt, ...)
   va_list arglist;
   va_start(arglist, fmt);
   vsnprintf(buf, sizeof(buf), fmt, arglist);
-  ConsoleBuffer::output << (const char*) buf << std::flush;
+  ConsoleBuffer::output << "[SQUIRREL] " << (const char*) buf << std::flush;
   va_end(arglist);
 }
 
@@ -106,8 +106,9 @@ Scripting::Scripting(bool enable_debugger)
   // try to load default script
   try {
     std::string filename = "scripts/default.nut";
-    IFileStream stream(filename);
-    scripting::compile_and_run(global_vm, stream, filename);
+    BufferedIFileStream* buffered_stream = new BufferedIFileStream(filename);
+    IFileStream* stream = buffered_stream->get_stream();
+    scripting::compile_and_run(global_vm, *stream, filename);
   } catch(std::exception& e) {
     log_warning << "Couldn't load default.nut: " << e.what() << std::endl;
   }
@@ -127,7 +128,7 @@ Scripting::~Scripting()
 
   global_vm = NULL;
 }
-  
+
 void
 Scripting::update_debugger()
 {