X operations(XOPS)に非常に近いFPSゲームを制作・リメイクし、成果物をオープンソースとして公開することを目的としたプロジェクトです。
Revision | 305 (tree) |
---|---|
Zeit | 2022-04-20 00:57:46 |
Autor | ![]() |
各箇所の関数の引数判定を厳格化、一部関数の戻り値仕様を変更、一部コーディングスタイルを修正
@@ -1414,6 +1414,8 @@ | ||
1414 | 1414 | if( ObjMgr == NULL ){ return false; } |
1415 | 1415 | if( ctrlhuman == NULL ){ return false; } |
1416 | 1416 | |
1417 | + if( (id < 0)||(MAX_HUMAN-1 < id) ){ return false; } | |
1418 | + | |
1417 | 1419 | //ターゲットのクラスを取得 |
1418 | 1420 | class human* thuman; |
1419 | 1421 | thuman = ObjMgr->GetHumanObject(id); |
@@ -1809,7 +1811,7 @@ | ||
1809 | 1811 | //! @attention 移動パスに関わらず、指定した人への追尾を強制します。Init()関数を再度実行するまで元に戻せません。 |
1810 | 1812 | void AIcontrol::SetHoldTracking(int id) |
1811 | 1813 | { |
1812 | - MoveNavi->SetHoldTracking(id); | |
1814 | + if( (0 <= id)&&(id < MAX_HUMAN) ){ MoveNavi->SetHoldTracking(id); } | |
1813 | 1815 | } |
1814 | 1816 | |
1815 | 1817 | //! @brief 強制的に警戒させる |
@@ -2119,6 +2121,8 @@ | ||
2119 | 2121 | //! @attention 移動パスに関わらず、指定した人への追尾を強制します。Init()関数を再度実行するまで元に戻せません。 |
2120 | 2122 | void AIMoveNavi::SetHoldTracking(int id) |
2121 | 2123 | { |
2124 | + if( (id < 0)||(MAX_HUMAN-1 < id) ){ return; } | |
2125 | + | |
2122 | 2126 | movemode = AI_TRACKING; |
2123 | 2127 | hold = true; |
2124 | 2128 | target_humanid = id; |
@@ -62,6 +62,8 @@ | ||
62 | 62 | //! @return 成功:0 失敗:1 |
63 | 63 | int Config::LoadFile(const char *fname) |
64 | 64 | { |
65 | + if( fname == NULL ){ return 1; } | |
66 | + | |
65 | 67 | FILE *fp; |
66 | 68 | char buf; |
67 | 69 |
@@ -77,9 +79,7 @@ | ||
77 | 79 | |
78 | 80 | //ファイルを開く |
79 | 81 | fp = fopen(fname, "rb"); |
80 | - if( fp == NULL ){ | |
81 | - return 1; | |
82 | - } | |
82 | + if( fp == NULL ){ return 1; } | |
83 | 83 | |
84 | 84 | //キーコード |
85 | 85 | for(int i=0; i<TOTAL_ControlKey; i++){ |
@@ -143,6 +143,8 @@ | ||
143 | 143 | //! @return 成功:0 失敗:1 |
144 | 144 | int Config::SaveFile(const char *fname) |
145 | 145 | { |
146 | + if( fname == NULL ){ return 1; } | |
147 | + | |
146 | 148 | FILE *fp; |
147 | 149 | char buf; |
148 | 150 |
@@ -158,9 +160,7 @@ | ||
158 | 160 | |
159 | 161 | //ファイルを開く |
160 | 162 | fp = fopen(fname, "wb"); |
161 | - if( fp == NULL ){ | |
162 | - return 1; | |
163 | - } | |
163 | + if( fp == NULL ){ return 1; } | |
164 | 164 | |
165 | 165 | //キーコード |
166 | 166 | for(int i=0; i<TOTAL_ControlKey; i++){ |
@@ -512,6 +512,8 @@ | ||
512 | 512 | int Config::LoadExtFile(const char *fname) |
513 | 513 | { |
514 | 514 | #ifdef ENABLE_ADDCONFIG |
515 | + if( fname == NULL ){ return 1; } | |
516 | + | |
515 | 517 | INIFileInterface INIConfig; |
516 | 518 | int mode; |
517 | 519 |
@@ -121,6 +121,9 @@ | ||
121 | 121 | //! @return 成功:0 失敗:1 |
122 | 122 | int D3DGraphics::InitD3D(WindowControl *WindowCtrl, const char *TextureFontFilename, bool fullscreen) |
123 | 123 | { |
124 | + if( WindowCtrl == NULL ){ return 1; } | |
125 | + if( TextureFontFilename == NULL ){ return 1; } | |
126 | + | |
124 | 127 | #ifdef ENABLE_DEBUGLOG |
125 | 128 | //ログに出力 |
126 | 129 | OutputLog.WriteLog(LOG_INIT, "Graphics", "DirectX"); |
@@ -259,6 +262,8 @@ | ||
259 | 262 | //! @return 成功:0 待ち:1 失敗:2 |
260 | 263 | int D3DGraphics::ResetD3D(WindowControl *WindowCtrl) |
261 | 264 | { |
265 | + if( WindowCtrl == NULL ){ return 2; } | |
266 | + | |
262 | 267 | //フォーカスを失っているなら待たせる |
263 | 268 | if( pd3dDevice->TestCooperativeLevel() == D3DERR_DEVICELOST ){ |
264 | 269 | return 1; |
@@ -488,6 +493,8 @@ | ||
488 | 493 | //! @return 成功:モデル認識番号(0以上) 失敗:-1 |
489 | 494 | int D3DGraphics::LoadModel(const char* filename) |
490 | 495 | { |
496 | + if( filename == NULL ){ return -1; } | |
497 | + | |
491 | 498 | #ifdef ENABLE_DEBUGLOG |
492 | 499 | //ログに出力 |
493 | 500 | OutputLog.WriteLog(LOG_LOAD, "Model", filename); |
@@ -642,6 +649,8 @@ | ||
642 | 649 | //! @return 成功:テクスチャ認識番号(0以上) 失敗:-1 |
643 | 650 | int D3DGraphics::LoadTexture(const char* filename, bool texturefont, bool BlackTransparent) |
644 | 651 | { |
652 | + if( filename == NULL ){ return -1; } | |
653 | + | |
645 | 654 | int id = -1; |
646 | 655 | D3DXIMAGE_INFO info; |
647 | 656 | int MipLevels; |
@@ -844,6 +853,8 @@ | ||
844 | 853 | //無効な認識番号が指定されていたら、処理せず返す。 |
845 | 854 | if( id == -1 ){ return 1; } |
846 | 855 | if( ptextures[id] == NULL ){ return 1; } |
856 | + if( width == NULL ){ return 1; } | |
857 | + if( height == NULL ){ return 1; } | |
847 | 858 | |
848 | 859 | IDirect3DSurface9 *surface; |
849 | 860 | D3DSURFACE_DESC desc; |
@@ -1153,6 +1164,8 @@ | ||
1153 | 1164 | //! @param *z z軸を受け取るポインタ |
1154 | 1165 | void D3DGraphics::GetWorldTransformPos(float *x, float *y, float *z) |
1155 | 1166 | { |
1167 | + if( (x == NULL)||(y == NULL)||(z == NULL) ){ return; } | |
1168 | + | |
1156 | 1169 | D3DXMATRIX matWorld; |
1157 | 1170 | #if GRAPHIC_ENGINE == 0 |
1158 | 1171 | pd3dDevice->GetTransform(D3DTS_WORLD, &matWorld); |
@@ -1220,8 +1233,7 @@ | ||
1220 | 1233 | D3DXMATRIXA16 matView; |
1221 | 1234 | |
1222 | 1235 | //camera_ryを -PI〜PI の間に正規化 |
1223 | - for(; camera_ry>D3DX_PI; camera_ry -= D3DX_PI*2){} | |
1224 | - for(; camera_ry<D3DX_PI*-1; camera_ry += D3DX_PI*2){} | |
1236 | + camera_ry = AngleNormalization(camera_ry); | |
1225 | 1237 | |
1226 | 1238 | //カメラの向きを決定 |
1227 | 1239 | if( fabsf(camera_ry) == D3DX_PI/2 ){ |
@@ -1275,6 +1287,7 @@ | ||
1275 | 1287 | { |
1276 | 1288 | //ブロックデータが指定されていなければ、処理しない。 |
1277 | 1289 | if( in_blockdata == NULL ){ return; } |
1290 | + if( directory == NULL ){ return; } | |
1278 | 1291 | |
1279 | 1292 | char fname[MAX_PATH]; |
1280 | 1293 | char fnamefull[MAX_PATH]; |
@@ -1785,6 +1798,7 @@ | ||
1785 | 1798 | void D3DGraphics::Draw2DMSFontText(int x, int y, const char *str, int color) |
1786 | 1799 | { |
1787 | 1800 | //if( ptextsprite == NULL ){ return; } |
1801 | + if( str == NULL ){ return; } | |
1788 | 1802 | |
1789 | 1803 | //テキストスプライト初期化 |
1790 | 1804 | Start2DMSFontTextRender(); |
@@ -1810,6 +1824,8 @@ | ||
1810 | 1824 | //! @attention 640x480相当の解像度から現解像度へスケーリングします。それ以外はDraw2DMSFontText()関数と同等です。 |
1811 | 1825 | void D3DGraphics::Draw2DMSFontTextScaling(int x, int y, const char *str, int color) |
1812 | 1826 | { |
1827 | + if( str == NULL ){ return; } | |
1828 | + | |
1813 | 1829 | float scaling_x = (float)GameConfig.GetScreenHeight() / 480;//(float)GameConfig.GetScreenWidth() / 640; |
1814 | 1830 | float scaling_y = (float)GameConfig.GetScreenHeight() / 480; |
1815 | 1831 |
@@ -1830,6 +1846,7 @@ | ||
1830 | 1846 | void D3DGraphics::Draw2DMSFontTextCenter(int x, int y, int w, int h, const char *str, int color) |
1831 | 1847 | { |
1832 | 1848 | //if( ptextsprite == NULL ){ return; } |
1849 | + if( str == NULL ){ return; } | |
1833 | 1850 | |
1834 | 1851 | //テキストスプライト初期化 |
1835 | 1852 | Start2DMSFontTextRender(); |
@@ -1857,6 +1874,8 @@ | ||
1857 | 1874 | //! @attention 640x480相当の解像度から現解像度へスケーリングします。それ以外はDraw2DMSFontTextCenter()関数と同等です。 |
1858 | 1875 | void D3DGraphics::Draw2DMSFontTextCenterScaling(int x, int y, int w, int h, const char *str, int color) |
1859 | 1876 | { |
1877 | + if( str == NULL ){ return; } | |
1878 | + | |
1860 | 1879 | float scaling_x = (float)GameConfig.GetScreenHeight() / 480;//(float)GameConfig.GetScreenWidth() / 640; |
1861 | 1880 | float scaling_y = (float)GameConfig.GetScreenHeight() / 480; |
1862 | 1881 |
@@ -1872,6 +1891,7 @@ | ||
1872 | 1891 | void D3DGraphics::Draw2DMSSmallFontText(int x, int y, const char *str, int color) |
1873 | 1892 | { |
1874 | 1893 | //if( ptextsprite == NULL ){ return; } |
1894 | + if( str == NULL ){ return; } | |
1875 | 1895 | |
1876 | 1896 | //テキストスプライト初期化 |
1877 | 1897 | Start2DMSFontTextRender(); |
@@ -1919,6 +1939,7 @@ | ||
1919 | 1939 | { |
1920 | 1940 | //テクスチャフォントの取得に失敗していれば、処理しない |
1921 | 1941 | if( TextureFont == -1 ){ return; } |
1942 | + if( str == NULL ){ return; } | |
1922 | 1943 | |
1923 | 1944 | //2D描画用設定を適用 |
1924 | 1945 | Start2DRender(); |
@@ -1993,6 +2014,8 @@ | ||
1993 | 2014 | //! @attention 640x480相当の解像度から現解像度へスケーリングします。それ以外はDraw2DTextureFontText()関数と同等です。 |
1994 | 2015 | void D3DGraphics::Draw2DTextureFontTextScaling(int x, int y, const char *str, int color, int fontwidth, int fontheight) |
1995 | 2016 | { |
2017 | + if( str == NULL ){ return; } | |
2018 | + | |
1996 | 2019 | float scaling_x = (float)GameConfig.GetScreenHeight() / 480;//(float)GameConfig.GetScreenWidth() / 640; |
1997 | 2020 | float scaling_y = (float)GameConfig.GetScreenHeight() / 480; |
1998 | 2021 |
@@ -2009,6 +2032,8 @@ | ||
2009 | 2032 | //! @attention 文字を二重に重ねて立体感を出さないと見にくくなります。 |
2010 | 2033 | void D3DGraphics::Draw2DTextureFontTextCenter(int x, int y, const char *str, int color, int fontwidth, int fontheight) |
2011 | 2034 | { |
2035 | + if( str == NULL ){ return; } | |
2036 | + | |
2012 | 2037 | Draw2DTextureFontText((GameConfig.GetScreenWidth() - strlen(str)*fontwidth)/2 + x, y, str, color, fontwidth, fontheight); |
2013 | 2038 | } |
2014 | 2039 |
@@ -2022,6 +2047,8 @@ | ||
2022 | 2047 | //! @attention 640x480相当の解像度から現解像度へスケーリングします。それ以外はDraw2DTextureFontTextCenter()関数と同等です。 |
2023 | 2048 | void D3DGraphics::Draw2DTextureFontTextCenterScaling(int x, int y, const char *str, int color, int fontwidth, int fontheight) |
2024 | 2049 | { |
2050 | + if( str == NULL ){ return; } | |
2051 | + | |
2025 | 2052 | float scaling_x = (float)GameConfig.GetScreenHeight() / 480;//(float)GameConfig.GetScreenWidth() / 640; |
2026 | 2053 | float scaling_y = (float)GameConfig.GetScreenHeight() / 480; |
2027 | 2054 |
@@ -2038,6 +2065,8 @@ | ||
2038 | 2065 | //! @attention 文字を二重に重ねて立体感を出さないと見にくくなります。 |
2039 | 2066 | void D3DGraphics::Draw2DTextureDebugFontText(int x, int y, const char *str, int color) |
2040 | 2067 | { |
2068 | + if( str == NULL ){ return; } | |
2069 | + | |
2041 | 2070 | int fontwidth = 8; |
2042 | 2071 | int fontheight = 16; |
2043 | 2072 |
@@ -2347,6 +2376,8 @@ | ||
2347 | 2376 | //! @return 成功:true 失敗:false |
2348 | 2377 | bool D3DGraphics::SaveScreenShot(const char* filename) |
2349 | 2378 | { |
2379 | + if( filename == NULL ){ return false; } | |
2380 | + | |
2350 | 2381 | LPDIRECT3DSURFACE9 pSurface = NULL; |
2351 | 2382 | HRESULT hr; |
2352 | 2383 |
@@ -121,6 +121,9 @@ | ||
121 | 121 | //! @return 成功:0 失敗:1 |
122 | 122 | int D3DGraphics::InitD3D(WindowControl *WindowCtrl, const char *TextureFontFilename, bool fullscreen) |
123 | 123 | { |
124 | + if( WindowCtrl == NULL ){ return 1; } | |
125 | + if( TextureFontFilename == NULL ){ return 1; } | |
126 | + | |
124 | 127 | #ifdef ENABLE_DEBUGLOG |
125 | 128 | //ログに出力 |
126 | 129 | OutputLog.WriteLog(LOG_INIT, "Graphics", "OpenGL"); |
@@ -248,6 +251,8 @@ | ||
248 | 251 | //! @return 成功:0 待ち:1 失敗:2 |
249 | 252 | int D3DGraphics::ResetD3D(WindowControl *WindowCtrl) |
250 | 253 | { |
254 | + if( WindowCtrl == NULL ){ return 2; } | |
255 | + | |
251 | 256 | #ifdef ENABLE_DEBUGLOG |
252 | 257 | //ログに出力 |
253 | 258 | OutputLog.WriteLog(LOG_INIT, "Graphics", "OpenGL (Reset)"); |
@@ -420,6 +425,8 @@ | ||
420 | 425 | //! @return 成功:モデル認識番号(0以上) 失敗:-1 |
421 | 426 | int D3DGraphics::LoadModel(const char* filename) |
422 | 427 | { |
428 | + if( filename == NULL ){ return -1; } | |
429 | + | |
423 | 430 | #ifdef ENABLE_DEBUGLOG |
424 | 431 | //ログに出力 |
425 | 432 | OutputLog.WriteLog(LOG_LOAD, "Model", filename); |
@@ -451,9 +458,7 @@ | ||
451 | 458 | |
452 | 459 | //ファイルを読み込む |
453 | 460 | fp = fopen(filename, "r"); |
454 | - if( fp == NULL ){ | |
455 | - return -1; //ファイルが読めない | |
456 | - } | |
461 | + if( fp == NULL ){ return -1; } | |
457 | 462 | |
458 | 463 | //マジックコード取得 |
459 | 464 | fgets(buf, 256, fp); |
@@ -839,9 +844,7 @@ | ||
839 | 844 | |
840 | 845 | //ファイルを読み込む |
841 | 846 | fp = fopen(filename, "rb"); |
842 | - if( fp == NULL ){ | |
843 | - return false; //ファイルが読めない | |
844 | - } | |
847 | + if( fp == NULL ){ return false; } | |
845 | 848 | |
846 | 849 | //ヘッダーを読む |
847 | 850 | fread(header, 1, 4, fp); |
@@ -875,6 +878,8 @@ | ||
875 | 878 | //未使用引数対策 |
876 | 879 | UNREFERENCED_PARAMETER(texturefont); |
877 | 880 | |
881 | + if( filename == NULL ){ return -1; } | |
882 | + | |
878 | 883 | int id = -1; |
879 | 884 | int format = 0; |
880 | 885 |
@@ -1004,9 +1009,7 @@ | ||
1004 | 1009 | |
1005 | 1010 | //ファイルを読み込む |
1006 | 1011 | fp = fopen(filename, "rb"); |
1007 | - if( fp == NULL ){ | |
1008 | - return false; //ファイルが読めない | |
1009 | - } | |
1012 | + if( fp == NULL ){ return false; } | |
1010 | 1013 | |
1011 | 1014 | //ヘッダーを読む |
1012 | 1015 | fread(header, 1, 54, fp); |
@@ -1187,9 +1190,7 @@ | ||
1187 | 1190 | |
1188 | 1191 | //ファイルを読み込む |
1189 | 1192 | fp = fopen(filename, "rb"); |
1190 | - if( fp == NULL ){ | |
1191 | - return false; //ファイルが読めない | |
1192 | - } | |
1193 | + if( fp == NULL ){ return false; } | |
1193 | 1194 | |
1194 | 1195 | //ヘッダーを読む |
1195 | 1196 | fread(header, 1, 124+4, fp); |
@@ -1273,9 +1274,7 @@ | ||
1273 | 1274 | |
1274 | 1275 | //ファイルを読み込む |
1275 | 1276 | fp = fopen(filename, "rb"); |
1276 | - if( fp == NULL ){ | |
1277 | - return false; //ファイルが読めない | |
1278 | - } | |
1277 | + if( fp == NULL ){ return false; } | |
1279 | 1278 | jpeg_stdio_src(&cinfo, fp); |
1280 | 1279 | |
1281 | 1280 | //パラメータの設定 |
@@ -1366,9 +1365,7 @@ | ||
1366 | 1365 | |
1367 | 1366 | //ファイルを読み込む |
1368 | 1367 | fp = fopen(filename, "rb"); |
1369 | - if( fp == NULL ){ | |
1370 | - return false; //ファイルが読めない | |
1371 | - } | |
1368 | + if( fp == NULL ){ return false; } | |
1372 | 1369 | |
1373 | 1370 | //PNGファイルか判定 |
1374 | 1371 | fread(sig, 4, 1, fp); |
@@ -1652,6 +1649,8 @@ | ||
1652 | 1649 | //無効な認識番号が指定されていたら、処理せず返す。 |
1653 | 1650 | if( id == -1 ){ return 1; } |
1654 | 1651 | if( ptextures[id].useflag == false ){ return 1; } |
1652 | + if( width == NULL ){ return 1; } | |
1653 | + if( height == NULL ){ return 1; } | |
1655 | 1654 | |
1656 | 1655 | *width = ptextures[id].width; |
1657 | 1656 | *height = ptextures[id].height; |
@@ -1921,6 +1920,8 @@ | ||
1921 | 1920 | //! @param *z z軸を受け取るポインタ |
1922 | 1921 | void D3DGraphics::GetWorldTransformPos(float *x, float *y, float *z) |
1923 | 1922 | { |
1923 | + if( (x == NULL)||(y == NULL)||(z == NULL) ){ return; } | |
1924 | + | |
1924 | 1925 | GLfloat model[16]; |
1925 | 1926 | glMatrixMode(GL_MODELVIEW); |
1926 | 1927 | glGetFloatv(GL_MODELVIEW_MATRIX, model); |
@@ -1991,6 +1992,7 @@ | ||
1991 | 1992 | { |
1992 | 1993 | //ブロックデータが指定されていなければ、処理しない。 |
1993 | 1994 | if( in_blockdata == NULL ){ return; } |
1995 | + if( directory == NULL ){ return; } | |
1994 | 1996 | |
1995 | 1997 | char fname[MAX_PATH]; |
1996 | 1998 | char fnamefull[MAX_PATH]; |
@@ -2400,6 +2402,8 @@ | ||
2400 | 2402 | //! @todo 1文字目が欠ける場合がある。 |
2401 | 2403 | void D3DGraphics::Draw2DMSFontText(int x, int y, const char *str, int color) |
2402 | 2404 | { |
2405 | + if( str == NULL ){ return; } | |
2406 | + | |
2403 | 2407 | int len = strlen(str); |
2404 | 2408 | WCHAR *ustr; |
2405 | 2409 |
@@ -2480,6 +2484,8 @@ | ||
2480 | 2484 | //! @attention 640x480相当の解像度から現解像度へスケーリングします。それ以外はDraw2DMSFontText()関数と同等です。 |
2481 | 2485 | void D3DGraphics::Draw2DMSFontTextScaling(int x, int y, const char *str, int color) |
2482 | 2486 | { |
2487 | + if( str == NULL ){ return; } | |
2488 | + | |
2483 | 2489 | float scaling_x = (float)GameConfig.GetScreenHeight() / 480;//(float)GameConfig.GetScreenWidth() / 640; |
2484 | 2490 | float scaling_y = (float)GameConfig.GetScreenHeight() / 480; |
2485 | 2491 |
@@ -2498,6 +2504,8 @@ | ||
2498 | 2504 | //未使用引数対策 |
2499 | 2505 | UNREFERENCED_PARAMETER(h); |
2500 | 2506 | |
2507 | + if( str == NULL ){ return; } | |
2508 | + | |
2501 | 2509 | int fonthalfsize = (int)(((float)GameConfig.GetScreenHeight() / 480) * 9); |
2502 | 2510 | |
2503 | 2511 | //Draw2DMSFontText(x + (w/2 - (StrMaxLineLen(str)*9/2)), y, str, color); |
@@ -2514,6 +2522,8 @@ | ||
2514 | 2522 | //! @attention 640x480相当の解像度から現解像度へスケーリングします。それ以外はDraw2DMSFontTextCenter()関数と同等です。 |
2515 | 2523 | void D3DGraphics::Draw2DMSFontTextCenterScaling(int x, int y, int w, int h, const char *str, int color) |
2516 | 2524 | { |
2525 | + if( str == NULL ){ return; } | |
2526 | + | |
2517 | 2527 | float scaling_x = (float)GameConfig.GetScreenHeight() / 480;//(float)GameConfig.GetScreenWidth() / 640; |
2518 | 2528 | float scaling_y = (float)GameConfig.GetScreenHeight() / 480; |
2519 | 2529 |
@@ -2529,6 +2539,8 @@ | ||
2529 | 2539 | //! @todo 同一文字列を通常フォントサイズで出すとバグが出るかもしれない。(要検証) |
2530 | 2540 | void D3DGraphics::Draw2DMSSmallFontText(int x, int y, const char *str, int color) |
2531 | 2541 | { |
2542 | + if( str == NULL ){ return; } | |
2543 | + | |
2532 | 2544 | int len = strlen(str); |
2533 | 2545 | WCHAR *ustr; |
2534 | 2546 |
@@ -2629,6 +2641,7 @@ | ||
2629 | 2641 | { |
2630 | 2642 | //テクスチャフォントの取得に失敗していれば、処理しない |
2631 | 2643 | if( TextureFont == -1 ){ return; } |
2644 | + if( str == NULL ){ return; } | |
2632 | 2645 | |
2633 | 2646 | int strlens = (int)strlen(str); |
2634 | 2647 |
@@ -2718,6 +2731,8 @@ | ||
2718 | 2731 | //! @attention 640x480相当の解像度から現解像度へスケーリングします。それ以外はDraw2DTextureFontText()関数と同等です。 |
2719 | 2732 | void D3DGraphics::Draw2DTextureFontTextScaling(int x, int y, const char *str, int color, int fontwidth, int fontheight) |
2720 | 2733 | { |
2734 | + if( str == NULL ){ return; } | |
2735 | + | |
2721 | 2736 | float scaling_x = (float)GameConfig.GetScreenHeight() / 480;//(float)GameConfig.GetScreenWidth() / 640; |
2722 | 2737 | float scaling_y = (float)GameConfig.GetScreenHeight() / 480; |
2723 | 2738 |
@@ -2734,6 +2749,8 @@ | ||
2734 | 2749 | //! @attention 文字を二重に重ねて立体感を出さないと見にくくなります。 |
2735 | 2750 | void D3DGraphics::Draw2DTextureFontTextCenter(int x, int y, const char *str, int color, int fontwidth, int fontheight) |
2736 | 2751 | { |
2752 | + if( str == NULL ){ return; } | |
2753 | + | |
2737 | 2754 | Draw2DTextureFontText((GameConfig.GetScreenWidth() - strlen(str)*fontwidth)/2 + x, y, str, color, fontwidth, fontheight); |
2738 | 2755 | } |
2739 | 2756 |
@@ -2747,6 +2764,8 @@ | ||
2747 | 2764 | //! @attention 640x480相当の解像度から現解像度へスケーリングします。それ以外はDraw2DTextureFontTextCenter()関数と同等です。 |
2748 | 2765 | void D3DGraphics::Draw2DTextureFontTextCenterScaling(int x, int y, const char *str, int color, int fontwidth, int fontheight) |
2749 | 2766 | { |
2767 | + if( str == NULL ){ return; } | |
2768 | + | |
2750 | 2769 | float scaling_x = (float)GameConfig.GetScreenHeight() / 480;//(float)GameConfig.GetScreenWidth() / 640; |
2751 | 2770 | float scaling_y = (float)GameConfig.GetScreenHeight() / 480; |
2752 | 2771 |
@@ -2763,6 +2782,8 @@ | ||
2763 | 2782 | //! @attention 文字を二重に重ねて立体感を出さないと見にくくなります。 |
2764 | 2783 | void D3DGraphics::Draw2DTextureDebugFontText(int x, int y, const char *str, int color) |
2765 | 2784 | { |
2785 | + if( str == NULL ){ return; } | |
2786 | + | |
2766 | 2787 | int fontwidth = 8; |
2767 | 2788 | int fontheight = 16; |
2768 | 2789 |
@@ -3108,6 +3129,8 @@ | ||
3108 | 3129 | //! @return 成功:true 失敗:false |
3109 | 3130 | bool D3DGraphics::SaveScreenShot(const char* filename) |
3110 | 3131 | { |
3132 | + if( filename == NULL ){ return false; } | |
3133 | + | |
3111 | 3134 | HDC hDC; |
3112 | 3135 | FILE *fp; |
3113 | 3136 | unsigned char header[54]; |
@@ -49,6 +49,8 @@ | ||
49 | 49 | //未使用引数対策 |
50 | 50 | UNREFERENCED_PARAMETER(fname); |
51 | 51 | |
52 | + if( fname == NULL ){ return 1; } | |
53 | + | |
52 | 54 | return 0; |
53 | 55 | } |
54 | 56 |
@@ -101,6 +103,8 @@ | ||
101 | 103 | //! @return 成功:0 失敗:1 |
102 | 104 | int BlockDataInterface::LoadFiledata(const char *fname) |
103 | 105 | { |
106 | + if( fname == NULL ){ return 1; } | |
107 | + | |
104 | 108 | FILE *fp; |
105 | 109 | unsigned char bdata_header[2]; |
106 | 110 | float bdata_main[80]; |
@@ -118,9 +122,7 @@ | ||
118 | 122 | |
119 | 123 | //ファイルを読み込む |
120 | 124 | fp = fopen(fname, "rb"); |
121 | - if( fp == NULL ){ | |
122 | - return 1; | |
123 | - } | |
125 | + if( fp == NULL ){ return 1; } | |
124 | 126 | |
125 | 127 | //テクスチャを取得 |
126 | 128 | for(int i=0; i<TOTAL_BLOCKTEXTURE; i++){ |
@@ -274,6 +276,7 @@ | ||
274 | 276 | int BlockDataInterface::GetTexture(char *fname, int id) |
275 | 277 | { |
276 | 278 | if( data == NULL ){ return 1; } |
279 | + if( fname == NULL ){ return 2; } | |
277 | 280 | if( (id < 0)||((TOTAL_BLOCKTEXTURE -1) < id) ){ return 2; } |
278 | 281 | |
279 | 282 | //ポインタにテクスチャ名をコピー |
@@ -289,6 +292,7 @@ | ||
289 | 292 | int BlockDataInterface::Getdata(blockdata *out_data, int id) |
290 | 293 | { |
291 | 294 | if( data == NULL ){ return 1; } |
295 | + if( out_data == NULL ){ return 2; } | |
292 | 296 | if( (id < 0)||((datas -1) < id) ){ return 2; } |
293 | 297 | |
294 | 298 | //ブロックデータを取得 |
@@ -413,6 +417,8 @@ | ||
413 | 417 | //! @return 成功:0 失敗:1 |
414 | 418 | int PointDataInterface::LoadFiledata(const char *fname) |
415 | 419 | { |
420 | + if( fname == NULL ){ return 1; } | |
421 | + | |
416 | 422 | FILE *fp; |
417 | 423 | unsigned char pdata_header[2]; |
418 | 424 | float pdata_mainf[4]; |
@@ -431,9 +437,7 @@ | ||
431 | 437 | |
432 | 438 | //ファイルを読み込む |
433 | 439 | fp = fopen( fname, "rb" ); |
434 | - if( fp == NULL ){ | |
435 | - return 1; | |
436 | - } | |
440 | + if( fp == NULL ){ return 1; } | |
437 | 441 | |
438 | 442 | //データ数を取得 |
439 | 443 | fread( pdata_header, 1, 2, fp ); |
@@ -496,6 +500,8 @@ | ||
496 | 500 | //! @return 成功:0 失敗:1 |
497 | 501 | int PointDataInterface::LoadMSGFiledata(char *fname) |
498 | 502 | { |
503 | + if( fname == NULL ){ return 1; } | |
504 | + | |
499 | 505 | FILE *fp; |
500 | 506 | |
501 | 507 | #ifdef ENABLE_PATH_DELIMITER_SLASH |
@@ -545,6 +551,7 @@ | ||
545 | 551 | int PointDataInterface::Getdata(pointdata *out_data, int id) |
546 | 552 | { |
547 | 553 | if( data == NULL ){ return 1; } |
554 | + if( out_data == NULL ){ return 2; } | |
548 | 555 | if( (id < 0)||((datas -1) < id) ){ return 2; } |
549 | 556 | |
550 | 557 | //データをポインタにコピー |
@@ -581,6 +588,7 @@ | ||
581 | 588 | //! @return 成功:0 失敗:1 |
582 | 589 | int PointDataInterface::GetMessageText(char *str, int id) |
583 | 590 | { |
591 | + if( str == NULL ){ return 1; } | |
584 | 592 | if( (id < 0)||((MAX_POINTMESSAGES -1) < id) ){ return 1; } |
585 | 593 | |
586 | 594 | //ポインタにメッセージをコピー |
@@ -696,6 +704,8 @@ | ||
696 | 704 | //! @return 成功:0 失敗:1 |
697 | 705 | int MIFInterface::LoadFiledata(const char *fname) |
698 | 706 | { |
707 | + if( fname == NULL ){ return 1; } | |
708 | + | |
699 | 709 | #ifdef ENABLE_DEBUGLOG |
700 | 710 | //ログに出力 |
701 | 711 | OutputLog.WriteLog(LOG_LOAD, "MIF", fname); |
@@ -796,6 +806,8 @@ | ||
796 | 806 | //! @return 成功:0 失敗:1 |
797 | 807 | int MIFInterface::LoadDefaultTextFiledata(const char *fname) |
798 | 808 | { |
809 | + if( fname == NULL ){ return 1; } | |
810 | + | |
799 | 811 | FILE *fp; |
800 | 812 | char str[64]; |
801 | 813 |
@@ -864,6 +876,8 @@ | ||
864 | 876 | //! @return 成功:0 失敗:1 |
865 | 877 | int MIFInterface::LoadMissionInfoFiledata(const char *fname) |
866 | 878 | { |
879 | + if( fname == NULL ){ return 1; } | |
880 | + | |
867 | 881 | FILE *fp; |
868 | 882 | char str[64]; |
869 | 883 |
@@ -945,6 +959,8 @@ | ||
945 | 959 | //! @return 成功:0 失敗:1 |
946 | 960 | int MIFInterface::LoadAddSmallObjectFiledata(const char *fname) |
947 | 961 | { |
962 | + if( fname == NULL ){ return 1; } | |
963 | + | |
948 | 964 | FILE *fp; |
949 | 965 | char str1[_MAX_PATH]; |
950 | 966 | char str2[_MAX_PATH]; |
@@ -1042,6 +1058,9 @@ | ||
1042 | 1058 | //! @attention fnameのポインタを直接書き換えます。 |
1043 | 1059 | bool MIFInterface::ChangeExePathToFullPath(char *dir, char *fname) |
1044 | 1060 | { |
1061 | + if( dir == NULL ){ return false; } | |
1062 | + if( fname == NULL ){ return false; } | |
1063 | + | |
1045 | 1064 | char str[MAX_PATH]; |
1046 | 1065 | int index = 0; |
1047 | 1066 |
@@ -1105,6 +1124,9 @@ | ||
1105 | 1124 | //! @param *pointfile ポイントデータを受け取るポインタ |
1106 | 1125 | void MIFInterface::GetDatafilePath(char *blockfile, char *pointfile) |
1107 | 1126 | { |
1127 | + if( blockfile == NULL ){ return; } | |
1128 | + if( pointfile == NULL ){ return; } | |
1129 | + | |
1108 | 1130 | strcpy(blockfile, blockfile_path); |
1109 | 1131 | strcpy(pointfile, pointfile_path); |
1110 | 1132 | } |
@@ -1124,6 +1146,9 @@ | ||
1124 | 1146 | //! @attention 画像を1枚しか使用しない場合、画像ファイルBは「!」を返します。 |
1125 | 1147 | void MIFInterface::GetPicturefilePath(char *picturefileA, char *picturefileB) |
1126 | 1148 | { |
1149 | + if( picturefileA == NULL ){ return; } | |
1150 | + if( picturefileB == NULL ){ return; } | |
1151 | + | |
1127 | 1152 | strcpy(picturefileA, picturefileA_path); |
1128 | 1153 | strcpy(picturefileB, picturefileB_path); |
1129 | 1154 | } |
@@ -1231,6 +1256,8 @@ | ||
1231 | 1256 | //! @brief .mifファイルを取得 |
1232 | 1257 | void AddonList::GetMIFlist(const char *dir) |
1233 | 1258 | { |
1259 | + if( dir == NULL ){ return; } | |
1260 | + | |
1234 | 1261 | char SearchDIR[_MAX_PATH]; |
1235 | 1262 | HANDLE hFind; |
1236 | 1263 | WIN32_FIND_DATA FindFileData; |
@@ -1256,6 +1283,8 @@ | ||
1256 | 1283 | //! @brief ミッション名を取得 |
1257 | 1284 | void AddonList::GetMissionName(const char *dir) |
1258 | 1285 | { |
1286 | + if( dir == NULL ){ return; } | |
1287 | + | |
1259 | 1288 | for(int i=0; i<datas; i++){ |
1260 | 1289 | char str[_MAX_PATH]; |
1261 | 1290 | MIFInterface mifdata; |
@@ -1276,6 +1305,8 @@ | ||
1276 | 1305 | //! @brief ミッション名をソートする |
1277 | 1306 | void AddonList::Sort() |
1278 | 1307 | { |
1308 | + if( datas <= 1 ){ return; } | |
1309 | + | |
1279 | 1310 | char mission_name_c[MAX_ADDONLIST][24]; |
1280 | 1311 | char temp[_MAX_PATH]; |
1281 | 1312 | int cmp; |
@@ -1315,6 +1346,8 @@ | ||
1315 | 1346 | //! @return addonの総数 |
1316 | 1347 | int AddonList::LoadFiledata(const char *dir) |
1317 | 1348 | { |
1349 | + if( dir == NULL ){ return 0; } | |
1350 | + | |
1318 | 1351 | datas = 0; |
1319 | 1352 | |
1320 | 1353 | //.mifファイルを取得 |
@@ -1342,6 +1375,7 @@ | ||
1342 | 1375 | //! @return ミッション名 |
1343 | 1376 | char* AddonList::GetMissionName(int id) |
1344 | 1377 | { |
1378 | + if( (id < 0)||((MAX_ADDONLIST -1) < id ) ){ return NULL; } | |
1345 | 1379 | return mission_name[id]; |
1346 | 1380 | } |
1347 | 1381 |
@@ -1350,6 +1384,7 @@ | ||
1350 | 1384 | //! @return ファイル名 |
1351 | 1385 | char* AddonList::GetFileName(int id) |
1352 | 1386 | { |
1387 | + if( (id < 0)||((MAX_ADDONLIST -1) < id ) ){ return NULL; } | |
1353 | 1388 | return filename[id]; |
1354 | 1389 | } |
1355 | 1390 |
@@ -1371,6 +1406,7 @@ | ||
1371 | 1406 | //! @attention 既にINIファイルを読み込んでいる場合、ReleaseINIFile()関数を使うまで本関数は失敗します。 |
1372 | 1407 | bool INIFileInterface::LoadINIFile(const char *fname) |
1373 | 1408 | { |
1409 | + if( fname == NULL ){ return true; } | |
1374 | 1410 | if( inifp != NULL ){ return true; } |
1375 | 1411 | |
1376 | 1412 | #ifdef ENABLE_PATH_DELIMITER_SLASH |
@@ -1393,9 +1429,13 @@ | ||
1393 | 1429 | //! @return エラーコード |
1394 | 1430 | //! @attention ファイルが開かれていないか キーが見つからなければ、デフォルト値を返します。 |
1395 | 1431 | //! @attention 取得した文字列が最大文字数を超えている場合、最大文字数まで切り取ります。 |
1396 | -//! @note エラーコード 1:ファイルが開かれていない、2:値が見つからない | |
1432 | +//! @note エラーコード 1:引数異常、2:ファイルが開かれていない、3:値が見つからない | |
1397 | 1433 | int INIFileInterface::GetINIFileString(const char *sectionname, const char *keyname, const char *defaultvalue, char *valuestr, int strbuflen) |
1398 | 1434 | { |
1435 | + if( valuestr == NULL ){ return 1; } | |
1436 | + if( defaultvalue == NULL ){ strcpy(valuestr, ""); return 1; } | |
1437 | + if( keyname == NULL ){ strcpy(valuestr, defaultvalue); return 1; } | |
1438 | + | |
1399 | 1439 | int state = 0; |
1400 | 1440 | char readline[512]; |
1401 | 1441 | char buf[512]; |
@@ -1403,7 +1443,7 @@ | ||
1403 | 1443 | //ファイルが読み込まれていなければ失敗 |
1404 | 1444 | if( inifp == NULL ){ |
1405 | 1445 | strcpy(valuestr, defaultvalue); |
1406 | - return 1; | |
1446 | + return 2; | |
1407 | 1447 | } |
1408 | 1448 | |
1409 | 1449 | fseek(inifp, 0, SEEK_SET); |
@@ -1501,7 +1541,7 @@ | ||
1501 | 1541 | |
1502 | 1542 | //値が見つからなければエラーを返す |
1503 | 1543 | strcpy(valuestr, defaultvalue); |
1504 | - return 2; | |
1544 | + return 3; | |
1505 | 1545 | } |
1506 | 1546 | |
1507 | 1547 | //! @brief int値を取得 |
@@ -1511,9 +1551,11 @@ | ||
1511 | 1551 | //! @param errorcode エラーコードを取得するポインタ(NULL可) |
1512 | 1552 | //! @return 値 |
1513 | 1553 | //! @attention ファイルが開かれていないか キーが見つからなければ、デフォルト値を返します。 |
1514 | -//! @note エラーコード 1:ファイルが開かれていない、2:値が見つからない | |
1554 | +//! @note エラーコード 1:引数異常、2:ファイルが開かれていない、3:値が見つからない | |
1515 | 1555 | int INIFileInterface::GetINIFileInt(const char *sectionname, const char *keyname, int defaultvalue, int *errorcode) |
1516 | 1556 | { |
1557 | + if( keyname == NULL ){ return defaultvalue; } | |
1558 | + | |
1517 | 1559 | char defaultint[64]; |
1518 | 1560 | char buf[64]; |
1519 | 1561 | int error; |
@@ -1531,9 +1573,11 @@ | ||
1531 | 1573 | //! @param errorcode エラーコードを取得するポインタ(NULL可) |
1532 | 1574 | //! @return 値 |
1533 | 1575 | //! @attention ファイルが開かれていないか キーが見つからなければ、デフォルト値を返します。 |
1534 | -//! @note エラーコード 1:ファイルが開かれていない、2:値が見つからない | |
1576 | +//! @note エラーコード 1:引数異常、2:ファイルが開かれていない、3:値が見つからない | |
1535 | 1577 | float INIFileInterface::GetINIFileFloat(const char *sectionname, const char *keyname, float defaultvalue, int *errorcode) |
1536 | 1578 | { |
1579 | + if( keyname == NULL ){ return defaultvalue; } | |
1580 | + | |
1537 | 1581 | char defaultfloat[64]; |
1538 | 1582 | char buf[64]; |
1539 | 1583 | int error; |
@@ -1555,9 +1599,11 @@ | ||
1555 | 1599 | //! @param errorcode エラーコードを取得するポインタ(NULL可) |
1556 | 1600 | //! @return 値 |
1557 | 1601 | //! @attention ファイルが開かれていないか キーが見つからなければ、デフォルト値を返します。 |
1558 | -//! @note エラーコード 1:ファイルが開かれていない、2:値が見つからない | |
1602 | +//! @note エラーコード 1:引数異常、2:ファイルが開かれていない、3:値が見つからない | |
1559 | 1603 | bool INIFileInterface::GetINIFileBool(const char *sectionname, const char *keyname, bool defaultvalue, int *errorcode) |
1560 | 1604 | { |
1605 | + if( keyname == NULL ){ return defaultvalue; } | |
1606 | + | |
1561 | 1607 | char defaultbool[64]; |
1562 | 1608 | char buf[64]; |
1563 | 1609 | int error; |
@@ -1595,8 +1641,10 @@ | ||
1595 | 1641 | //! @brief fgets()用 改行コードを取り除く |
1596 | 1642 | //! @param str 文字列 |
1597 | 1643 | //! @return 置き換えあり:0 置き換えなし:1 |
1598 | -int DeleteLinefeed(char str[]) | |
1644 | +int DeleteLinefeed(char *str) | |
1599 | 1645 | { |
1646 | + if( str == NULL ){ return 1; } | |
1647 | + | |
1600 | 1648 | char *pstr; |
1601 | 1649 | bool flag = false; |
1602 | 1650 |
@@ -1624,6 +1672,9 @@ | ||
1624 | 1672 | //! @warning Windows環境しか想定されていません。 |
1625 | 1673 | bool CheckFullPath(const char *path) |
1626 | 1674 | { |
1675 | + if( path == NULL ){ return false; } | |
1676 | + if( strlen(path) < 2 ){ return false; } | |
1677 | + | |
1627 | 1678 | if( path[1] == ':' ){ return true; } |
1628 | 1679 | return false; |
1629 | 1680 | } |
@@ -1633,6 +1684,9 @@ | ||
1633 | 1684 | //! @param dir ディレクトリ名を受け取るポインタ |
1634 | 1685 | void GetFileDirectory(const char *path, char *dir) |
1635 | 1686 | { |
1687 | + if( path == NULL ){ return; } | |
1688 | + if( dir == NULL ){ return; } | |
1689 | + | |
1636 | 1690 | strcpy(dir, path); |
1637 | 1691 | |
1638 | 1692 | //終端から'\\'か'/'を探し、'\0'に置き換える |
@@ -1649,6 +1703,8 @@ | ||
1649 | 1703 | //! @attention 拡張子は"."込みで指定してください。大文字・小文字は区別しません。 |
1650 | 1704 | bool CheckFileExtension(const char *filepath, const char *checkstr) |
1651 | 1705 | { |
1706 | + if( filepath == NULL ){ return false; } | |
1707 | + if( checkstr == NULL ){ return false; } | |
1652 | 1708 | if( strlen(filepath) >= MAX_PATH ){ return false; } |
1653 | 1709 | if( strlen(checkstr) >= 16 ){ return false; } |
1654 | 1710 | if( strlen(filepath) < strlen(checkstr) ){ return false; } |
@@ -237,7 +237,7 @@ | ||
237 | 237 | void ReleaseINIFile(); |
238 | 238 | }; |
239 | 239 | |
240 | -int DeleteLinefeed(char str[]); | |
240 | +int DeleteLinefeed(char *str); | |
241 | 241 | bool CheckFullPath(const char *path); |
242 | 242 | void GetFileDirectory(const char *path, char *dir); |
243 | 243 | bool CheckFileExtension(const char *filepath, const char *checkstr); |
@@ -53,9 +53,7 @@ | ||
53 | 53 | FILE *fp; |
54 | 54 | |
55 | 55 | fp = fopen(fname, "a"); |
56 | - if( fp == NULL ){ | |
57 | - return; | |
58 | - } | |
56 | + if( fp == NULL ){ return; } | |
59 | 57 | |
60 | 58 | fprintf(fp, "</table>\n"); |
61 | 59 | fprintf(fp, "</body>\n"); |
@@ -100,9 +98,7 @@ | ||
100 | 98 | |
101 | 99 | |
102 | 100 | fp = fopen(fname, "w"); |
103 | - if( fp == NULL ){ | |
104 | - return true; | |
105 | - } | |
101 | + if( fp == NULL ){ return true; } | |
106 | 102 | |
107 | 103 | //ヘッダー |
108 | 104 | fprintf(fp, "<html>\n"); |
@@ -144,6 +140,8 @@ | ||
144 | 140 | //! @attention WriteLog(int tag, const char* title, const char* text)関数をオーバーロードします。 |
145 | 141 | bool DebugLog::WriteLog(int tag, const char* title, int id) |
146 | 142 | { |
143 | + if( title == NULL ){ return true; } | |
144 | + | |
147 | 145 | //出力フラグを有効なければ処理しない |
148 | 146 | if( OutputFlag == false ){ return true; } |
149 | 147 |
@@ -163,6 +161,9 @@ | ||
163 | 161 | //! @attention すなわち、初期化か読み込みを記録した場合、次に完了が記録されなければ、自動的にエラーとして記録します。 |
164 | 162 | bool DebugLog::WriteLog(int tag, const char* title, const char* text) |
165 | 163 | { |
164 | + if( title == NULL ){ return true; } | |
165 | + if( text == NULL ){ return true; } | |
166 | + | |
166 | 167 | //出力フラグを有効なければ処理しない |
167 | 168 | if( OutputFlag == false ){ return true; } |
168 | 169 |
@@ -214,9 +215,7 @@ | ||
214 | 215 | } |
215 | 216 | |
216 | 217 | fp = fopen(fname, "a"); |
217 | - if( fp == NULL ){ | |
218 | - return true; | |
219 | - } | |
218 | + if( fp == NULL ){ return true; } | |
220 | 219 | |
221 | 220 | //現在のミリ秒 |
222 | 221 | fprintf(fp, "<tr><td> %d </td>", GetTimeMS()); |
@@ -262,6 +262,11 @@ | ||
262 | 262 | //! @attention SetMessageID は、メッセージイベントが実行された場合に true になります。<b>前回から変更されたとは限りません。</b> |
263 | 263 | int EventControl::Execution(bool SkipFlag, int *endcnt, bool *complete, int *MessageID, bool *SetMessageID) |
264 | 264 | { |
265 | + if( endcnt == NULL ){ return 0; } | |
266 | + if( complete == NULL ){ return 0; } | |
267 | + if( MessageID == NULL ){ return 0; } | |
268 | + if( SetMessageID == NULL ){ return 0; } | |
269 | + | |
265 | 270 | pointdata data; |
266 | 271 | int cnt = 0; |
267 | 272 |
@@ -60,6 +60,8 @@ | ||
60 | 60 | //! @brief 基本的な初期化処理 |
61 | 61 | int InitGame(WindowControl *WindowCtrl, int mode, char *MIFpath) |
62 | 62 | { |
63 | + if( WindowCtrl == NULL ){ return 1; } | |
64 | + | |
63 | 65 | //D3DGraphicsクラス初期化 |
64 | 66 | if( d3dg.InitD3D(WindowCtrl, "data\\char.dds", GameConfig.GetFullscreenFlag()) ){ |
65 | 67 | WindowCtrl->ErrorInfo("Direct3Dの作成に失敗しました"); |
@@ -140,6 +142,8 @@ | ||
140 | 142 | //! @attention 通常は、描画処理に失敗した場合に限り呼び出してください。 |
141 | 143 | int ResetGame(WindowControl *WindowCtrl) |
142 | 144 | { |
145 | + if( WindowCtrl == NULL ){ return -1; } | |
146 | + | |
143 | 147 | //リストを正しく解放するため、予め呼ぶ。 |
144 | 148 | Resource.CleanupHumanTexture(); |
145 | 149 |
@@ -2125,6 +2129,8 @@ | ||
2125 | 2129 | //! @param MouseSensitivity 視点の移動量計算 |
2126 | 2130 | void maingame::InputPlayer(human *myHuman, int mouse_x, int mouse_y, float MouseSensitivity) |
2127 | 2131 | { |
2132 | + if( myHuman == NULL ){ return; } | |
2133 | + | |
2128 | 2134 | int PlayerID = ObjMgr.GetPlayerID(); |
2129 | 2135 | |
2130 | 2136 | if( myHuman->GetHP() > 0 ){ |
@@ -3508,6 +3514,9 @@ | ||
3508 | 3514 | //! @return 取得:true 判定外:false |
3509 | 3515 | bool maingame::GetCommandNum(const char *cmd, int *num) |
3510 | 3516 | { |
3517 | + if( cmd == NULL ){ return false; } | |
3518 | + if( num == NULL ){ return false; } | |
3519 | + | |
3511 | 3520 | //コマンド名を調べる |
3512 | 3521 | if( memcmp(NewCommand, cmd, strlen(cmd)) != 0 ){ return false; } |
3513 | 3522 | if( NewCommand[strlen(cmd)] != ' ' ){ return false; } |
@@ -4718,6 +4727,13 @@ | ||
4718 | 4727 | //! @brief screen派生クラスの初期化(クラスの設定) |
4719 | 4728 | void InitScreen(WindowControl *WindowCtrl, opening *Opening, mainmenu *MainMenu, briefing *Briefing, maingame *MainGame, result *Result) |
4720 | 4729 | { |
4730 | + if( WindowCtrl == NULL ){ return; } | |
4731 | + if( Opening == NULL ){ return; } | |
4732 | + if( MainMenu == NULL ){ return; } | |
4733 | + if( Briefing == NULL ){ return; } | |
4734 | + if( MainGame == NULL ){ return; } | |
4735 | + if( Result == NULL ){ return; } | |
4736 | + | |
4721 | 4737 | Opening->SetClass(&GameState, WindowCtrl, &d3dg, &inputCtrl, &GameSound); |
4722 | 4738 | MainMenu->SetClass(&GameState, WindowCtrl, &d3dg, &inputCtrl, &GameSound); |
4723 | 4739 | Briefing->SetClass(&GameState, WindowCtrl, &d3dg, &inputCtrl); |
@@ -4728,6 +4744,13 @@ | ||
4728 | 4744 | //! @brief screen派生クラスの実行 |
4729 | 4745 | void ProcessScreen(WindowControl *WindowCtrl, opening *Opening, mainmenu *MainMenu, briefing *Briefing, maingame *MainGame, result *Result, unsigned int framecnt) |
4730 | 4746 | { |
4747 | + if( WindowCtrl == NULL ){ return; } | |
4748 | + if( Opening == NULL ){ return; } | |
4749 | + if( MainMenu == NULL ){ return; } | |
4750 | + if( Briefing == NULL ){ return; } | |
4751 | + if( MainGame == NULL ){ return; } | |
4752 | + if( Result == NULL ){ return; } | |
4753 | + | |
4731 | 4754 | int error; |
4732 | 4755 | |
4733 | 4756 | switch(GameState.GetState()){ |
@@ -4932,6 +4955,11 @@ | ||
4932 | 4955 | //! @return 成功:0 失敗(ゲーム続行):1 失敗(ゲーム終了):2 |
4933 | 4956 | int ChangeWindowMode(WindowControl *WindowCtrl, D3DGraphics *d3dg, InputControl *inputCtrl, scene *RecoveryScene, bool fullscreen) |
4934 | 4957 | { |
4958 | + if( WindowCtrl == NULL ){ return 2; } | |
4959 | + if( d3dg == NULL ){ return 2; } | |
4960 | + if( inputCtrl == NULL ){ return 2; } | |
4961 | + if( RecoveryScene == NULL ){ return 2; } | |
4962 | + | |
4935 | 4963 | int returncode = 0; |
4936 | 4964 | bool ErrorFlag = false; |
4937 | 4965 |
@@ -204,6 +204,8 @@ | ||
204 | 204 | //! @attention 「合計アイテム数<表示するアイテム数」の場合、ノブは表示されません。 |
205 | 205 | void ScrollbarObject::Draw(class D3DGraphics *d3dg) |
206 | 206 | { |
207 | + if( d3dg == NULL ){ return; } | |
208 | + | |
207 | 209 | int color, color2; |
208 | 210 | |
209 | 211 | //エリア描画 |
@@ -81,6 +81,8 @@ | ||
81 | 81 | //! @return 成功:0 失敗:1 |
82 | 82 | int InputControl::InitInput(WindowControl *WindowCtrl) |
83 | 83 | { |
84 | + if( WindowCtrl == NULL ){ return 1; } | |
85 | + | |
84 | 86 | #ifdef ENABLE_DEBUGLOG |
85 | 87 | //ログに出力 |
86 | 88 | #if INPUT_INTERFACE == 0 |
@@ -423,6 +425,8 @@ | ||
423 | 425 | //! @return 押されてない:false 押されている:true |
424 | 426 | bool InputControl::CheckKeyNow(int id) |
425 | 427 | { |
428 | + if( (id < 0)||(256 <= id) ){ return false; } | |
429 | + | |
426 | 430 | //現在押されていれば |
427 | 431 | if( keys[id]&0x80 ){ return true; } |
428 | 432 | return false; |
@@ -432,6 +436,8 @@ | ||
432 | 436 | //! @return 押された瞬間でない:false 押された瞬間である:true |
433 | 437 | bool InputControl::CheckKeyDown(int id) |
434 | 438 | { |
439 | + if( (id < 0)||(256 <= id) ){ return false; } | |
440 | + | |
435 | 441 | //前回は押されておらず、現在押されていれば |
436 | 442 | if( ((keys_lt[id]&0x80) == 0)&&(keys[id]&0x80) ){ return true; } |
437 | 443 | return false; |
@@ -441,6 +447,8 @@ | ||
441 | 447 | //! @return 離された瞬間でない:false 離された瞬間である:true |
442 | 448 | bool InputControl::CheckKeyUp(int id) |
443 | 449 | { |
450 | + if( (id < 0)||(256 <= id) ){ return false; } | |
451 | + | |
444 | 452 | //前回を押されており、現在押されていなければ |
445 | 453 | if( (keys_lt[id]&0x80)&&((keys[id]&0x80) == 0) ){ return true; } |
446 | 454 | return false; |
@@ -452,6 +460,8 @@ | ||
452 | 460 | //! @attention 値は直前に実行した GetInputState() への引数に影響される。 |
453 | 461 | void InputControl::GetMouseMovement(int *x, int *y) |
454 | 462 | { |
463 | + if( (x == NULL)||(y == NULL) ){ return; } | |
464 | + | |
455 | 465 | //マウス座標を代入 |
456 | 466 | *x = mx; |
457 | 467 | *y = my; |
@@ -744,6 +754,8 @@ | ||
744 | 754 | //! @return 成功:true 失敗:false |
745 | 755 | bool GetDoubleKeyCode(int id, int *CodeL, int *CodeR) |
746 | 756 | { |
757 | + if( (CodeL == NULL)||(CodeR == NULL) ){ return false; } | |
758 | + | |
747 | 759 | #if INPUT_INTERFACE != 2 |
748 | 760 | //未使用引数対策 |
749 | 761 | UNREFERENCED_PARAMETER(id); |
@@ -263,6 +263,8 @@ | ||
263 | 263 | //! @attention 次の引数を判定します。>/[引数]、-[引数]、/[引数(小文字)]、-[引数(小文字)] |
264 | 264 | bool CheckCommandParameter(const char *param, const char *cmd) |
265 | 265 | { |
266 | + if( param == NULL ){ return false; } | |
267 | + if( cmd == NULL ){ return false; } | |
266 | 268 | if( strlen(param) >= 16 ){ return false; } |
267 | 269 | if( strlen(cmd) >= 16 ){ return false; } |
268 | 270 | if( strlen(param) != strlen(cmd) ){ return false; } |
@@ -407,9 +407,7 @@ | ||
407 | 407 | //! @return 成功:1 失敗:0 |
408 | 408 | int human::PickupWeapon(class weapon *in_weapon) |
409 | 409 | { |
410 | - if( in_weapon == NULL ){ | |
411 | - return 0; | |
412 | - } | |
410 | + if( in_weapon == NULL ){ return 0; } | |
413 | 411 | |
414 | 412 | if( weapon[selectweapon] == NULL ){ |
415 | 413 | //武器を正しく拾えれば、所持武器として登録 |
@@ -637,6 +635,9 @@ | ||
637 | 635 | //! @attention ゲーム上から直接呼び出すことは避け、ObjectManagerクラスから呼び出してください。 |
638 | 636 | bool human::ShotWeapon(int *weapon_paramid, int *GunsightErrorRange) |
639 | 637 | { |
638 | + if( weapon_paramid == NULL ){ return false; } | |
639 | + if( GunsightErrorRange == NULL ){ return false; } | |
640 | + | |
640 | 641 | int param_id; |
641 | 642 | |
642 | 643 | //武器切り替え中なら失敗 |
@@ -942,6 +943,8 @@ | ||
942 | 943 | //! @param ry 縦軸を取得するポインタ |
943 | 944 | void human::GetRxRy(float *rx, float *ry) |
944 | 945 | { |
946 | + if( (rx == NULL)||(ry == NULL) ){ return; } | |
947 | + | |
945 | 948 | *rx = rotation_x; |
946 | 949 | *ry = armrotation_y; |
947 | 950 | } |
@@ -1141,6 +1144,8 @@ | ||
1141 | 1144 | //! @return 静止した死体:4 倒れ終わった直後:3 倒れている最中:2 倒れ始める:1 何もしない:0 |
1142 | 1145 | int human::CheckAndProcessDead(class Collision *CollD) |
1143 | 1146 | { |
1147 | + if( CollD == NULL ){ return 0; } | |
1148 | + | |
1144 | 1149 | if( hp <= 0 ){ |
1145 | 1150 | //腕の角度 |
1146 | 1151 | if( armrotation_y < 0.0f ){ |
@@ -1491,6 +1496,9 @@ | ||
1491 | 1496 | //! @attention 空中の場合など足元にブロックがない場合、ブロックIDと面番号は -1 を返します。 |
1492 | 1497 | void human::CollisionMap(class Collision *CollD, class BlockDataInterface *inblockdata, bool AddCollisionFlag, bool player, int *underblock_id, int *underblock_face) |
1493 | 1498 | { |
1499 | + if( CollD == NULL ){ return; } | |
1500 | + if( inblockdata == NULL ){ return; } | |
1501 | + | |
1494 | 1502 | float pos_x2, pos_y2, pos_z2; |
1495 | 1503 | float dist_x, dist_y, dist_z; |
1496 | 1504 | float speed; |
@@ -1768,6 +1776,8 @@ | ||
1768 | 1776 | //! @return 成功:true 失敗:false |
1769 | 1777 | bool human::CollisionBlockScratch(class Collision *CollD, class BlockDataInterface *inblockdata, float *px, float *py, float *pz, float px_old, float py_old, float pz_old, float in_vx, float in_vy, float in_vz, int mode) |
1770 | 1778 | { |
1779 | + if( CollD == NULL ){ return false; } | |
1780 | + if( inblockdata == NULL ){ return false; } | |
1771 | 1781 | //if( (*px == px_old)&&(*py == py_old)&&(*pz == pz_old) ){ return false; } |
1772 | 1782 | |
1773 | 1783 | float px2, py2, pz2; |
@@ -1842,6 +1852,7 @@ | ||
1842 | 1852 | int human::RunFrame(class Collision *CollD, class BlockDataInterface *inblockdata, bool AddCollisionFlag, bool player, bool F5mode, int *underblock_id, int *underblock_face) |
1843 | 1853 | { |
1844 | 1854 | if( CollD == NULL ){ return 0; } |
1855 | + if( inblockdata == NULL ){ return 0; } | |
1845 | 1856 | if( EnableFlag == false ){ return 0; } |
1846 | 1857 | |
1847 | 1858 | //F5を使用していれば、強制的に上昇 |
@@ -1967,6 +1978,7 @@ | ||
1967 | 1978 | |
1968 | 1979 | //正しく初期化されていなければ、処理しない |
1969 | 1980 | if( d3dg == NULL ){ return; } |
1981 | + if( Resource == NULL ){ return; } | |
1970 | 1982 | if( EnableFlag == false ){ return; } |
1971 | 1983 | |
1972 | 1984 | //モーション取得 |
@@ -2256,6 +2268,7 @@ | ||
2256 | 2268 | { |
2257 | 2269 | //初期化されていなければ、失敗 |
2258 | 2270 | if( EnableFlag == false ){ return false; } |
2271 | + if( Resource == NULL ){ return false; } | |
2259 | 2272 | |
2260 | 2273 | //指定された設定値へ上書き |
2261 | 2274 | id_parameter = id_param; |
@@ -2798,6 +2811,8 @@ | ||
2798 | 2811 | //! @return 爆発:2 バウンド・跳ね返り:1 それ以外:0 |
2799 | 2812 | int grenade::RunFrame(class Collision *CollD) |
2800 | 2813 | { |
2814 | + if( CollD == NULL ){ return 0; } | |
2815 | + | |
2801 | 2816 | //初期化されていなければ処理しない |
2802 | 2817 | if( EnableFlag == false ){ return 0; } |
2803 | 2818 |
@@ -2978,6 +2993,8 @@ | ||
2978 | 2993 | //! @param mz Z軸移動量を受け取るポインタ |
2979 | 2994 | void effect::GetMove(float *mx, float *my, float *mz) |
2980 | 2995 | { |
2996 | + if( (mx == NULL)||(my == NULL)||(mz == NULL) ){ return; } | |
2997 | + | |
2981 | 2998 | *mx = move_x; |
2982 | 2999 | *my = move_y; |
2983 | 3000 | *mz = move_z; |
@@ -3377,12 +3394,12 @@ | ||
3377 | 3394 | //! @param legmodel 足のモデル認識番号を取得するポインタ |
3378 | 3395 | void HumanMotionControl::GetRenderMotion(float *arm_rotation_y, float *leg_rotation_x, int *upmodel, int *armmodel, int *legmodel) |
3379 | 3396 | { |
3380 | - *arm_rotation_y = armmodel_rotation_y; | |
3381 | - *leg_rotation_x = legrotation_x; | |
3397 | + if( arm_rotation_y != NULL ){ *arm_rotation_y = armmodel_rotation_y; } | |
3398 | + if( leg_rotation_x != NULL ){ *leg_rotation_x = legrotation_x; } | |
3382 | 3399 | |
3383 | - *upmodel = id_upmodel; | |
3384 | - *armmodel = armmodelid; | |
3385 | - *legmodel = legmodelid; | |
3400 | + if( upmodel != NULL ){ *upmodel = id_upmodel; } | |
3401 | + if( armmodel != NULL ){ *armmodel = armmodelid; } | |
3402 | + if( legmodel != NULL ){ *legmodel = legmodelid; } | |
3386 | 3403 | } |
3387 | 3404 | |
3388 | 3405 | //! @brief 歩き・走りモーションのカウント値取得 |
@@ -637,6 +637,9 @@ | ||
637 | 637 | //! @attention 両クラスは自動的にAddPosOrder()を用いて、お互いを押し合います。 |
638 | 638 | bool ObjectManager::CollideHuman(human *in_humanA, human *in_humanB) |
639 | 639 | { |
640 | + if( in_humanA == NULL ){ return false; } | |
641 | + if( in_humanB == NULL ){ return false; } | |
642 | + | |
640 | 643 | float h1_x, h1_y, h1_z; |
641 | 644 | float h2_x, h2_y, h2_z; |
642 | 645 | float angle, length; |
@@ -669,6 +672,8 @@ | ||
669 | 672 | //! @attention 判定に限らず、ダメージ計算や効果音再生まで一貫して行います。 |
670 | 673 | bool ObjectManager::CollideBullet(bullet *in_bullet) |
671 | 674 | { |
675 | + if( in_bullet == NULL ){ return false; } | |
676 | + | |
672 | 677 | //使用されていない弾丸ならば、処理せずに返す。 |
673 | 678 | if( in_bullet->GetEnableFlag() == false ){ return false; } |
674 | 679 |
@@ -1030,6 +1035,8 @@ | ||
1030 | 1035 | //! @attention ダメージ判定に限らず、ダメージ計算や効果音再生まで一貫して行います。 |
1031 | 1036 | bool ObjectManager::GrenadeExplosion(grenade *in_grenade) |
1032 | 1037 | { |
1038 | + if( in_grenade == NULL ){ return false; } | |
1039 | + | |
1033 | 1040 | bool returnflag = false; |
1034 | 1041 | |
1035 | 1042 | //座標を取得 |
@@ -1270,6 +1277,10 @@ | ||
1270 | 1277 | //! @return 付着する:true 付着しない:false |
1271 | 1278 | bool ObjectManager::CollideBlood(effect *in_effect, int *id, int *face, float *pos_x, float *pos_y, float *pos_z) |
1272 | 1279 | { |
1280 | + if( in_effect == NULL ){ return false; } | |
1281 | + if( (id == NULL)||(face == NULL) ){ return false; } | |
1282 | + if( (pos_x == NULL)||(pos_y == NULL)||(pos_z == NULL) ){ return false; } | |
1283 | + | |
1273 | 1284 | //無効なエフェクトならば処理しない |
1274 | 1285 | if( in_effect->GetEnableFlag() == false ){ return false; } |
1275 | 1286 | if( in_effect->GetCollideMapFlag() == false ){ return false; } |
@@ -1317,6 +1328,9 @@ | ||
1317 | 1328 | //! @attention 人の種類が ゾンビ の場合、この関数は失敗します。 |
1318 | 1329 | void ObjectManager::PickupWeapon(human *in_human, weapon *in_weapon) |
1319 | 1330 | { |
1331 | + if( in_human == NULL ){ return; } | |
1332 | + if( in_weapon == NULL ){ return; } | |
1333 | + | |
1320 | 1334 | //無効な人ならば処理しない |
1321 | 1335 | if( in_human->GetEnableFlag() == false ){ return; } |
1322 | 1336 | if( in_human->GetHP() <= 0 ){ return; } |
@@ -1655,6 +1669,8 @@ | ||
1655 | 1669 | //! @return データ番号 (エラー:-1) |
1656 | 1670 | int ObjectManager::GetHumanObjectID(human* object) |
1657 | 1671 | { |
1672 | + if( object == NULL ){ return -1; } | |
1673 | + | |
1658 | 1674 | for(int i=0; i<MAX_HUMAN; i++){ |
1659 | 1675 | if( &(HumanIndex[i]) == object ){ |
1660 | 1676 | return i; |
@@ -1696,6 +1712,8 @@ | ||
1696 | 1712 | //! @return データ番号 (エラー:-1) |
1697 | 1713 | int ObjectManager::GetBulletObjectID(bullet* object) |
1698 | 1714 | { |
1715 | + if( object == NULL ){ return -1; } | |
1716 | + | |
1699 | 1717 | for(int i=0; i<MAX_BULLET; i++){ |
1700 | 1718 | if( &(BulletIndex[i]) == object ){ |
1701 | 1719 | return i; |
@@ -2036,6 +2054,9 @@ | ||
2036 | 2054 | //! @attention この関数の呼び出しタイミングを誤ると、銃口に対してマズルフラッシュが合いません。 |
2037 | 2055 | void ObjectManager::ShotWeaponEffect(int humanid) |
2038 | 2056 | { |
2057 | + //値の範囲をチェック | |
2058 | + if( (humanid < 0)||(MAX_HUMAN <= humanid) ){ return; } | |
2059 | + | |
2039 | 2060 | float pos_x, pos_y, pos_z; |
2040 | 2061 | float rotation_x, armrotation_y; |
2041 | 2062 | int weapon_paramid; |
@@ -2373,6 +2394,7 @@ | ||
2373 | 2394 | //! @param EnemyHuman 攻撃を受けた人オブジェクトのポインタ |
2374 | 2395 | void ObjectManager::HitZombieAttack(human* MyHuman, human* EnemyHuman) |
2375 | 2396 | { |
2397 | + if( MyHuman == NULL ){ return; } | |
2376 | 2398 | if( EnemyHuman == NULL ){ return; } |
2377 | 2399 | |
2378 | 2400 | //使用されていないか、死亡していれば処理しない。 |
@@ -2538,6 +2560,9 @@ | ||
2538 | 2560 | //! @return 表示情報あり:true 表示情報なし:false |
2539 | 2561 | bool ObjectManager::GetObjectInfoTag(float camera_x, float camera_y, float camera_z, float camera_rx, float camera_ry, int *color, char *infostr) |
2540 | 2562 | { |
2563 | + if( color == NULL ){ return false; } | |
2564 | + if( infostr == NULL ){ return false; } | |
2565 | + | |
2541 | 2566 | float dist = 50.0f; |
2542 | 2567 | float px, py, pz; |
2543 | 2568 | float rx, ry; |
@@ -2870,6 +2895,8 @@ | ||
2870 | 2895 | bool ObjectManager::GetHumanShotInfo(int id, float *ontarget, int *kill, int *headshot) |
2871 | 2896 | { |
2872 | 2897 | if( (id < 0)||(MAX_HUMAN-1 < id) ){ return false; } |
2898 | + if( (ontarget == NULL)||(kill == NULL)||(headshot == NULL) ){ return false; } | |
2899 | + | |
2873 | 2900 | *ontarget = Human_ontarget[id]; |
2874 | 2901 | *kill = Human_kill[id]; |
2875 | 2902 | *headshot = Human_headshot[id]; |
@@ -3125,6 +3152,7 @@ | ||
3125 | 3152 | //! @param str 文字列 (改行コード:<b>不可</b>) |
3126 | 3153 | void ObjectManagerLog::InfoLog(const char *str) |
3127 | 3154 | { |
3155 | + if( str == NULL ){ return; } | |
3128 | 3156 | AddTextLog(MAX_OBJECTMANAGER_LOGCNT, str, d3dg->GetColorCode(0.0f,1.0f,0.0f,1.0f)); |
3129 | 3157 | } |
3130 | 3158 |
@@ -3219,6 +3247,8 @@ | ||
3219 | 3247 | //! @return 1行上書き:true 追加のみ:false |
3220 | 3248 | bool ObjectManagerLog::AddTextLog(int cnt, const char *str, int color) |
3221 | 3249 | { |
3250 | + if( str == NULL ){ return false; } | |
3251 | + | |
3222 | 3252 | //空いている行があるなら、その行に書いて終了 |
3223 | 3253 | for(int i=0; i<MAX_OBJECTMANAGER_LOGLEN; i++){ |
3224 | 3254 | if( TextCnt[i] == -1 ){ |
@@ -1780,6 +1780,7 @@ | ||
1780 | 1780 | //! @return 成功:0 失敗:1 |
1781 | 1781 | int ParameterInfo::GetHuman(int id, HumanParameter *out_data) |
1782 | 1782 | { |
1783 | + if( out_data == NULL ){ return 1; } | |
1783 | 1784 | if( (id < 0)||((TOTAL_PARAMETERINFO_HUMAN -1) < id ) ){ return 1; } |
1784 | 1785 | |
1785 | 1786 | *out_data = Human[id]; |
@@ -1792,6 +1793,7 @@ | ||
1792 | 1793 | //! @return 成功:0 失敗:1 |
1793 | 1794 | int ParameterInfo::GetHumanTexturePath(int id, char *out_str) |
1794 | 1795 | { |
1796 | + if( out_str == NULL ){ return 1; } | |
1795 | 1797 | if( (id < 0)||((TOTAL_HUMANTEXTURE -1) < id ) ){ return 1; } |
1796 | 1798 | |
1797 | 1799 | strcpy(out_str, HumanTexturePath[id]); |
@@ -1804,6 +1806,7 @@ | ||
1804 | 1806 | //! @return 成功:0 失敗:1 |
1805 | 1807 | int ParameterInfo::GetWeapon(int id, WeaponParameter *out_data) |
1806 | 1808 | { |
1809 | + if( out_data == NULL ){ return 1; } | |
1807 | 1810 | if( (id < 0)||((TOTAL_PARAMETERINFO_WEAPON -1) < id ) ){ |
1808 | 1811 | #ifdef ENABLE_BUG_HUMANWEAPON |
1809 | 1812 | return GetBugWeapon(id, out_data); |
@@ -1825,6 +1828,7 @@ | ||
1825 | 1828 | //! @attention バグ武器を追加する場合は、ResourceManagerクラスの GetBugWeaponModelTexture() 関数も編集してください。 |
1826 | 1829 | int ParameterInfo::GetBugWeapon(int id, WeaponParameter *out_data) |
1827 | 1830 | { |
1831 | + if( out_data == NULL ){ return 1; } | |
1828 | 1832 | if( (id == 23)||(id == 24)||(id == 30)||(id == 53) ){ |
1829 | 1833 | *out_data = BugWeapon[0]; |
1830 | 1834 | return 0; |
@@ -1842,6 +1846,7 @@ | ||
1842 | 1846 | //! @warning 追加小物の情報は取得できません。追加小物の情報は MIFInterfaceクラス から取得してください。 |
1843 | 1847 | int ParameterInfo::GetSmallObject(int id, SmallObjectParameter *out_data) |
1844 | 1848 | { |
1849 | + if( out_data == NULL ){ return 1; } | |
1845 | 1850 | if( (id < 0)||((TOTAL_PARAMETERINFO_SMALLOBJECT -1) < id ) ){ return 1; } |
1846 | 1851 | |
1847 | 1852 | *out_data = SmallObject[id]; |
@@ -1854,6 +1859,7 @@ | ||
1854 | 1859 | //! @return 成功:0 失敗:1 |
1855 | 1860 | int ParameterInfo::GetBullet(int id, BulletParameter *out_data) |
1856 | 1861 | { |
1862 | + if( out_data == NULL ){ return 1; } | |
1857 | 1863 | if( (id < 0)||((TOTAL_PARAMETERINFO_BULLET -1) < id ) ){ return 1; } |
1858 | 1864 | |
1859 | 1865 | *out_data = Bullet[id]; |
@@ -1889,6 +1895,7 @@ | ||
1889 | 1895 | //! @return 成功:0 失敗:1 |
1890 | 1896 | int ParameterInfo::GetAIlevel(int level, AIParameter **out_AIlevel) |
1891 | 1897 | { |
1898 | + if( out_AIlevel == NULL ){ return 1; } | |
1892 | 1899 | if( (level < 0)||((TOTAL_PARAMETERINFO_AILEVEL -1) < level ) ){ return 1; } |
1893 | 1900 | *out_AIlevel = &(AIlevel[level]); |
1894 | 1901 | return 0; |
@@ -348,6 +348,9 @@ | ||
348 | 348 | //! @return 成功:0 失敗:1 |
349 | 349 | int ResourceManager::GetWeaponModelTexture(int id, int *model, int *texture) |
350 | 350 | { |
351 | + if( model == NULL ){ return 1; } | |
352 | + if( texture == NULL ){ return 1; } | |
353 | + | |
351 | 354 | if( (id < 0)||((TOTAL_PARAMETERINFO_WEAPON -1) < id ) ){ |
352 | 355 | #ifdef ENABLE_BUG_HUMANWEAPON |
353 | 356 | return GetBugWeaponModelTexture(id, model, texture); |
@@ -369,6 +372,8 @@ | ||
369 | 372 | int ResourceManager::GetBugWeaponModelTexture(int id, int *model, int *texture) |
370 | 373 | { |
371 | 374 | if( d3dg == NULL ){ return 1; } |
375 | + if( model == NULL ){ return 1; } | |
376 | + if( texture == NULL ){ return 1; } | |
372 | 377 | |
373 | 378 | if( id == 23 ){ |
374 | 379 | *model = human_upmodel[0]; |
@@ -519,6 +524,8 @@ | ||
519 | 524 | //! @return 成功:0 失敗:1 |
520 | 525 | int ResourceManager::GetSmallObjectModelTexture(int id, int *model, int *texture) |
521 | 526 | { |
527 | + if( model == NULL ){ return 1; } | |
528 | + if( texture == NULL ){ return 1; } | |
522 | 529 | if( (id < 0)||((TOTAL_PARAMETERINFO_SMALLOBJECT + MAX_ADDSMALLOBJECT -1) < id ) ){ return 1; } |
523 | 530 | |
524 | 531 | *model = smallobject_model[id]; |
@@ -605,6 +612,9 @@ | ||
605 | 612 | { |
606 | 613 | if( d3dg == NULL ){ return 1; } |
607 | 614 | if( SoundCtrl == NULL ){ return 1; } |
615 | + if( modelpath == NULL ){ return 1; } | |
616 | + if( texturepath == NULL ){ return 1; } | |
617 | + if( soundpath == NULL ){ return 1; } | |
608 | 618 | if( (id < 0)||(MAX_ADDSMALLOBJECT-1 < id) ){ return 1; } |
609 | 619 | |
610 | 620 | int dataid = TOTAL_PARAMETERINFO_SMALLOBJECT + id; |
@@ -665,6 +675,8 @@ | ||
665 | 675 | //! @return 成功:0 失敗:1 |
666 | 676 | int ResourceManager::GetBulletModelTexture(int id, int *model, int *texture) |
667 | 677 | { |
678 | + if( model == NULL ){ return 1; } | |
679 | + if( texture == NULL ){ return 1; } | |
668 | 680 | if( (id < 0)||((TOTAL_PARAMETERINFO_BULLET -1) < id ) ){ return 1; } |
669 | 681 | |
670 | 682 | *model = bullet_model[id]; |
@@ -739,6 +751,9 @@ | ||
739 | 751 | //! @brief 背景空のモデルとテクスチャを取得 |
740 | 752 | void ResourceManager::GetSkyModelTexture(int *model, int *texture) |
741 | 753 | { |
754 | + if( model == NULL ){ return; } | |
755 | + if( texture == NULL ){ return; } | |
756 | + | |
742 | 757 | *model = skymodel; |
743 | 758 | *texture = skytexture; |
744 | 759 | } |
@@ -57,6 +57,8 @@ | ||
57 | 57 | //! @return 成功:0 失敗:1 |
58 | 58 | int SoundControl::InitSound(WindowControl *WindowCtrl) |
59 | 59 | { |
60 | + if( WindowCtrl == NULL ){ return 1; } | |
61 | + | |
60 | 62 | #ifdef ENABLE_DEBUGLOG |
61 | 63 | //ログに出力 |
62 | 64 | OutputLog.WriteLog(LOG_INIT, "Sound", "DirectSound"); |
@@ -148,6 +150,7 @@ | ||
148 | 150 | int SoundControl::LoadSound(const char* filename) |
149 | 151 | { |
150 | 152 | if( pDSound == NULL ){ return -1; } |
153 | + if( filename == NULL ){ return -1; } | |
151 | 154 | |
152 | 155 | #ifdef ENABLE_DEBUGLOG |
153 | 156 | //ログに出力 |
@@ -68,6 +68,8 @@ | ||
68 | 68 | //! @return 成功:0 失敗:1 |
69 | 69 | int SoundControl::InitSound(WindowControl *WindowCtrl) |
70 | 70 | { |
71 | + if( WindowCtrl == NULL ){ return 1; } | |
72 | + | |
71 | 73 | #ifdef ENABLE_DEBUGLOG |
72 | 74 | //ログに出力 |
73 | 75 | OutputLog.WriteLog(LOG_INIT, "Sound", "ezds.dll"); |
@@ -164,6 +166,7 @@ | ||
164 | 166 | int SoundControl::LoadSound(const char* filename) |
165 | 167 | { |
166 | 168 | if( lib == NULL ){ return -1; } |
169 | + if( filename == NULL ){ return -1; } | |
167 | 170 | |
168 | 171 | #ifdef ENABLE_DEBUGLOG |
169 | 172 | //ログに出力 |
@@ -308,6 +308,8 @@ | ||
308 | 308 | //! @return 返す(サウンドリストの)音源の数 |
309 | 309 | int SoundManager::GetWorldSound(float pos_x, float pos_y, float pos_z, int teamID, soundlist *psoundlist) |
310 | 310 | { |
311 | + if( psoundlist == NULL ){ return 0; } | |
312 | + | |
311 | 313 | int lists; |
312 | 314 | soundlist *getlist = NULL; |
313 | 315 | int newlists = 0; |
@@ -65,6 +65,9 @@ | ||
65 | 65 | //! @warning 先にSetParam()関数で設定しておく必要があります。 |
66 | 66 | bool WindowControl::InitWindow(const char* title, int width, int height, bool fullscreen) |
67 | 67 | { |
68 | + if( title == NULL ){ return false; } | |
69 | + if( (width <= 0)||(height <= 0) ){ return false; } | |
70 | + | |
68 | 71 | WNDCLASS wc; |
69 | 72 | int x, y; |
70 | 73 | RECT Rect; |
@@ -213,6 +216,8 @@ | ||
213 | 216 | //! @param *str メッセージ |
214 | 217 | void WindowControl::ErrorInfo(const char *str) |
215 | 218 | { |
219 | + if( str == NULL ){ return; } | |
220 | + | |
216 | 221 | MessageBox(hWnd, str, "error", MB_OK); |
217 | 222 | } |
218 | 223 |
@@ -256,6 +261,8 @@ | ||
256 | 261 | //! @return fps数 |
257 | 262 | float GetFps(int getcnt) |
258 | 263 | { |
264 | + if( getcnt <= 0 ){ return 0.0f; } | |
265 | + | |
259 | 266 | static unsigned int ptimeg = 0; |
260 | 267 | unsigned int nowtime; |
261 | 268 | static float pfps = 0.0f; |
@@ -318,6 +325,8 @@ | ||
318 | 325 | //! @param str 文字列を受け取るポインタ |
319 | 326 | void GetTimeName(char *str) |
320 | 327 | { |
328 | + if( str == NULL ){ return; } | |
329 | + | |
321 | 330 | time_t timer; |
322 | 331 | struct tm *local; |
323 | 332 |
@@ -338,6 +347,8 @@ | ||
338 | 347 | //! @return 0〜num-1 |
339 | 348 | int GetRand(int num) |
340 | 349 | { |
350 | + if( num <= 0 ){ return 0; } | |
351 | + | |
341 | 352 | return rand()%num; |
342 | 353 | |
343 | 354 | //return rand() / (RAND_MAX/num); |
@@ -366,6 +377,8 @@ | ||
366 | 377 | //! @note '\'を'/'へ置き換えます。 |
367 | 378 | char* ChangePathDelimiter(char *str) |
368 | 379 | { |
380 | + if( str == NULL ){ return NULL; } | |
381 | + | |
369 | 382 | static char newstr[MAX_PATH]; |
370 | 383 | strcpy(newstr, str); |
371 | 384 |