From 548db2d06ed0e8a30eea81b3b767ef90154224cc Mon Sep 17 00:00:00 2001 From: janwas Date: Sat, 28 Feb 2009 16:42:46 +0000 Subject: [PATCH] Pyrogenesis.cpp: add svn_revision to log ScriptGlue.cpp: add svn_revision to build information in main menu Interact.cpp: fix: do not add anglebias when computed via atan2 NetMessage.cpp: fix typo This was SVN commit r6713. --- source/network/NetMessage.cpp | 2 +- source/ps/Interact.cpp | 14 +++++------ source/ps/Pyrogenesis.cpp | 3 +++ source/scripting/ScriptGlue.cpp | 43 +++++++++++++++++++++++---------- 4 files changed, 41 insertions(+), 21 deletions(-) diff --git a/source/network/NetMessage.cpp b/source/network/NetMessage.cpp index 0dce1d1021..0aa962ad54 100644 --- a/source/network/NetMessage.cpp +++ b/source/network/NetMessage.cpp @@ -74,7 +74,7 @@ u8* CNetMessage::Serialize( u8* pBuffer ) const //----------------------------------------------------------------------------- // Name: Deserialize() -// Desc: Loads this message from the specifie buffer parameter +// Desc: Loads this message from the specified buffer parameter //----------------------------------------------------------------------------- const u8* CNetMessage::Deserialize( const u8* pStart, const u8* pEnd ) { diff --git a/source/ps/Interact.cpp b/source/ps/Interact.cpp index 51b00bee88..fa22fbcee8 100644 --- a/source/ps/Interact.cpp +++ b/source/ps/Interact.cpp @@ -1410,9 +1410,11 @@ void CBuildingPlacer::MouseReleased() { Deactivate(); // do it first in case we fail for any reason + m_clicked = false; + if( m_valid ) { - // issue a place object command accross the network + // issue a place object command across the network CPlaceObjectMessage *msg = new CPlaceObjectMessage(); msg->m_IsQueued = hotkeys[HOTKEY_ORDER_QUEUE]; msg->m_Entities = g_Selection.m_selected; @@ -1455,16 +1457,15 @@ void CBuildingPlacer::Update( float timeStep ) CVector3D mousePos = camera.GetWorldCoordinates(); CVector3D dif = mousePos - clickPos; float x = dif.X, z = dif.Z; - if(x*x + z*z < 3*3) { + if(x*x + z*z < 3*3) + { if(m_dragged || m_timeSinceClick > 0.2f) - { m_angle += timeStep * PI; - } } else { m_dragged = true; - m_angle = atan2(x, z) + angleBias; + m_angle = atan2(x, z); } } @@ -1488,14 +1489,13 @@ void CBuildingPlacer::Update( float timeStep ) if( ent && ent->m_classes.IsMember( m_template->m_socket ) ) // if it's a socket, snap to it { onSocket = true; - m_angle = atan2f( ent->m_ahead.x, ent->m_ahead.y ) + angleBias; + m_angle = atan2f( ent->m_ahead.x, ent->m_ahead.y ); pos = ent->m_position; clickPos = ent->m_position; } } // Set position and angle to the location we decided on - CMatrix3D m; m.SetYRotation(m_angle + PI); m.Translate(pos); diff --git a/source/ps/Pyrogenesis.cpp b/source/ps/Pyrogenesis.cpp index 778ad018d9..fbe9b0c121 100644 --- a/source/ps/Pyrogenesis.cpp +++ b/source/ps/Pyrogenesis.cpp @@ -6,6 +6,7 @@ #include "lib/sysdep/sysdep.h" #include "lib/file/path.h" #include "lib/path_util.h" +#include "lib/svn_revision.h" DEFINE_ERROR(PS_OK, "OK"); DEFINE_ERROR(PS_FAIL, "Fail"); @@ -73,6 +74,8 @@ static void AppendAsciiFile(FILE* out, const char* in_filename) // for user convenience, bundle all logs into this file: void psBundleLogs(FILE* f) { + fwprintf(f, L"SVN Revision: %s\n\n", svn_revision); + fwprintf(f, L"System info:\n\n"); Path path1("../logs/system_info.txt"); AppendAsciiFile(f, path1.external_file_string().c_str()); diff --git a/source/scripting/ScriptGlue.cpp b/source/scripting/ScriptGlue.cpp index ac15a4fa13..d063a01f0f 100644 --- a/source/scripting/ScriptGlue.cpp +++ b/source/scripting/ScriptGlue.cpp @@ -21,6 +21,7 @@ #include "graphics/scripting/JSInterface_LightEnv.h" #include "gui/CGUI.h" #include "lib/timer.h" +#include "lib/svn_revision.h" #include "lib/frequency_filter.h" #include "maths/scripting/JSInterface_Vector3D.h" #include "network/NetClient.h" @@ -1025,28 +1026,44 @@ JSBool SetCameraTarget( JSContext* cx, JSObject* UNUSED(obj), uintN argc, jsval* //----------------------------------------------------------------------------- // Return the date/time at which the current executable was compiled. -// params: none (-> "date time") OR -// what to display [int]: 0 (-> "date"); 1 (-> "time") -// returns: date and/or time [string] +// params: none (-> "date time (svn revision)") OR an integer specifying +// what to display: 0 for date, 1 for time, 2 for svn revision +// returns: string with the requested timestamp info // notes: // - Displayed on main menu screen; tells non-programmers which auto-build // they are running. Could also be determined via .EXE file properties, // but that's a bit more trouble. // - To be exact, the date/time returned is when scriptglue.cpp was -// last compiled; since the auto-build does full rebuilds, that is moot. +// last compiled, but the auto-build does full rebuilds. +// - svn revision is generated by calling svnversion and cached in +// lib/svn_revision.cpp. it is useful to know when attempting to +// reproduce bugs (the main EXE and PDB should be temporarily reverted to +// that revision so that they match user-submitted crashdumps). JSBool GetBuildTimestamp( JSContext* cx, JSObject*, uintN argc, jsval* argv, jsval* rval ) { JSU_REQUIRE_PARAM_RANGE(0, 1); - // no param => "date time" - // param = 0 => "date" - // param = 1 => "time" - JSString* s = JS_NewStringCopyZ(cx, - argc && argv[0]==JSVAL_ONE ? __TIME__ - : argc ? __DATE__ - : __DATE__" "__TIME__ - ); - *rval = STRING_TO_JSVAL(s); + char buf[200]; + + // see function documentation + const int mode = argc? JSVAL_TO_INT(argv[0]) : -1; + switch(mode) + { + case -1: + sprintf_s(buf, ARRAY_SIZE(buf), "%s %s (%ws)", __DATE__, __TIME__, svn_revision); + break; + case 0: + sprintf_s(buf, ARRAY_SIZE(buf), "%s", __DATE__); + break; + case 1: + sprintf_s(buf, ARRAY_SIZE(buf), "%s", __TIME__); + break; + case 2: + sprintf_s(buf, ARRAY_SIZE(buf), "%ws", svn_revision); + break; + } + + *rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, buf)); return JS_TRUE; }