Implement Knowledge Base for libs/compilers bugs
authorunc0rr
Fri, 27 Oct 2006 22:07:38 +0000
changeset 208 a049157d673a
parent 207 287077789132
child 209 63b3d7afe8b6
Implement Knowledge Base for libs/compilers bugs
QTfrontend/CMakeLists.txt
QTfrontend/KB.h
QTfrontend/game.cpp
QTfrontend/hedgewars.pro
hedgewars/hwengine.dpr
hedgewars/uIO.pas
hedgewars/uMisc.pas
hedgewars/uStore.pas
--- a/QTfrontend/CMakeLists.txt	Fri Oct 27 19:37:59 2006 +0000
+++ b/QTfrontend/CMakeLists.txt	Fri Oct 27 22:07:38 2006 +0000
@@ -55,7 +55,8 @@
 	hwmap.h
 	mapContainer.h
 	tcpBase.h
-	about.h)
+	about.h
+	KB.h)
 
 
 set(hwfr_rez
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/KB.h	Fri Oct 27 22:07:38 2006 +0000
@@ -0,0 +1,34 @@
+/*
+ * Hedgewars, a worms-like game
+ * Copyright (c) 2006 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifndef KB_H
+#define KB_H
+
+#include <QString>
+
+const ulong KBmsgsCount = 1;
+
+const QString KBMessages[KBmsgsCount] =
+{
+	QT_TRANSLATE_NOOP("KB", "SDL_ttf returned error while rendering text, "
+							"most propably it is related to the bug "
+							"in freetype2. It's recommended to update your "
+							"freetype lib.")
+};
+
+#endif // KB_H
--- a/QTfrontend/game.cpp	Fri Oct 27 19:37:59 2006 +0000
+++ b/QTfrontend/game.cpp	Fri Oct 27 22:07:38 2006 +0000
@@ -29,6 +29,7 @@
 #include "hwconsts.h"
 #include "gameuiconfig.h"
 #include "gamecfgwidget.h"
+#include "kb.h"
 
 HWGame::HWGame(GameUIConfig * config, GameCFGWidget * gamecfg) :
   TCPBase(true)
@@ -126,6 +127,19 @@
 					QMessageBox::NoButton);
 			return;
 		}
+		case 'K': {
+			ulong kb = msg.mid(2).toULong();
+			if (kb && kb <= KBmsgsCount)
+			{
+				QMessageBox::information(0,
+						"Hedgewars: information",
+						KBMessages[kb - 1],
+						QMessageBox::Ok,
+						QMessageBox::NoButton,
+						QMessageBox::NoButton);
+			}
+			return;
+		}
 		case '+': {
 			if (gameType == gtNet)
 			{
--- a/QTfrontend/hedgewars.pro	Fri Oct 27 19:37:59 2006 +0000
+++ b/QTfrontend/hedgewars.pro	Fri Oct 27 22:07:38 2006 +0000
@@ -30,7 +30,8 @@
            hwmap.h \
            mapContainer.h \
            tcpBase.h \
-           about.h
+           about.h \
+           KB.h
            
 SOURCES += game.cpp \
            main.cpp \
--- a/hedgewars/hwengine.dpr	Fri Oct 27 19:37:59 2006 +0000
+++ b/hedgewars/hwengine.dpr	Fri Oct 27 22:07:38 2006 +0000
@@ -108,7 +108,7 @@
 begin
 {$IFDEF DEBUGFILE}AddFileLog('Freeing resources...');{$ENDIF}
 if isSoundEnabled then ReleaseSound;
-StoreRelease;
+StoreRelease;SendKB;
 CloseIPC;
 TTF_Quit;
 SDL_Quit;
--- a/hedgewars/uIO.pas	Fri Oct 27 19:37:59 2006 +0000
+++ b/hedgewars/uIO.pas	Fri Oct 27 22:07:38 2006 +0000
@@ -134,7 +134,10 @@
 
 procedure SendIPCRaw(p: pointer; len: Longword);
 begin
-SDLNet_TCP_Send(IPCSock, p, len)
+if IPCSock <> nil then
+   begin
+   SDLNet_TCP_Send(IPCSock, p, len)
+   end
 end;
 
 procedure SendIPCXY(cmd: char; X, Y: SmallInt);
--- a/hedgewars/uMisc.pas	Fri Oct 27 19:37:59 2006 +0000
+++ b/hedgewars/uMisc.pas	Fri Oct 27 22:07:38 2006 +0000
@@ -100,12 +100,15 @@
 procedure AddFileLog(s: shortstring);
 function RectToStr(Rect: TSDL_Rect): shortstring;
 {$ENDIF}
+procedure SetKB(n: Longword);
+procedure SendKB;
 
 var CursorPoint: TPoint;
     TargetPoint: TPoint = (X: NoPointX; Y: 0);
 
 implementation
 uses uConsole, uStore, uIO{$IFDEF FPC}, Math{$ENDIF};
+var KBnum: Longword = 0;
 {$IFDEF DEBUGFILE}
 var f: textfile;
 {$ENDIF}
@@ -184,6 +187,21 @@
 Result:= trunc(arctan2(_dY, _dX) * MaxAngleDivPI) mod cMaxAngle
 end;
 
+procedure SetKB(n: Longword);
+begin
+KBnum:= n
+end;
+
+procedure SendKB;
+var s: shortstring;
+begin
+if KBnum <> 0 then
+   begin
+   s:= 'K' + inttostr(KBnum);
+   SendIPCRaw(@s, Length(s) + 1)
+   end
+end;
+
 {$IFDEF DEBUGFILE}
 procedure AddFileLog(s: shortstring);
 begin
--- a/hedgewars/uStore.pas	Fri Oct 27 19:37:59 2006 +0000
+++ b/hedgewars/uStore.pas	Fri Oct 27 22:07:38 2006 +0000
@@ -376,7 +376,11 @@
 clr.g:= $FF;
 clr.b:= $FF;
 tmpsurf:= TTF_RenderUTF8_Solid(Fontz[Font].Handle, PChar(s), clr.value);
-SDLTry(tmpsurf <> nil, true);
+if tmpsurf = nil then
+   begin
+   SetKB(1);
+   exit
+   end;
 SDL_UpperBlit(tmpsurf, nil, Surface, @r);
 SDL_FreeSurface(tmpsurf)
 end;