該当のソースコード
C++
1cGrBoard::grDispCarBoard1(tCarElt *car, tSituation *s) 2{ 3 int x, x2, y; 4 const int BUFSIZE=256; 5 char buf[BUFSIZE]; 6 float *clr; 7 int dy, dy2, dx; 8 9 x = 10; 10 x2 = 110; 11 dy = GfuiFontHeight(GFUI_FONT_MEDIUM_C); 12 dy2 = GfuiFontHeight(GFUI_FONT_SMALL_C); 13 y = Winy + Winh - dy - 5; 14 snprintf(buf, BUFSIZE, "%d/%d - %s", car->_pos, s->_ncars, car->_name); 15 dx = GfuiFontWidth(GFUI_FONT_MEDIUM_C, buf); 16 dx = MAX(dx, (x2-x)); 17 18 glEnable(GL_BLEND); 19 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ; 20 glBegin(GL_QUADS); 21 glColor4f(0.1, 0.1, 0.1, 0.8); 22 glVertex2f(x-5, y + dy); 23 glVertex2f(x+dx+5, y + dy); 24 glVertex2f(x+dx+5, y-5 - dy2 * 12 /* lines */); 25 glVertex2f(x-5, y-5 - dy2 * 12 /* lines */); 26 glEnd(); 27 glDisable(GL_BLEND); 28 29 GfuiPrintString(buf, grCarInfo[car->index].iconColor, GFUI_FONT_MEDIUM_C, x, y, GFUI_ALIGN_HL_VB); 30 y -= dy; 31 32 dy = GfuiFontHeight(GFUI_FONT_SMALL_C); 33 34 GfuiPrintString("Fuel:", grWhite, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); 35 if (car->_fuel < 5.0) { 36 clr = grRed; 37 } else { 38 clr = grWhite; 39 } 40 snprintf(buf, BUFSIZE, "%.1f l", car->_fuel); 41 GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); 42 y -= dy; 43 44 if (car->_state & RM_CAR_STATE_BROKEN) { 45 clr = grRed; 46 } else { 47 clr = grWhite; 48 } 49 50 GfuiPrintString("Damage:", clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); 51 snprintf(buf, BUFSIZE, "%d", car->_dammage); 52 GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); 53 y -= dy; 54 clr = grWhite; 55 56 GfuiPrintString("Laps:", clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); 57 snprintf(buf, BUFSIZE, "%d / %d", car->_laps, s->_totLaps); 58 GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); 59 y -= dy; 60 61 GfuiPrintString("Total:", clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); 62 grWriteTime(clr, GFUI_FONT_SMALL_C, x2, y, s->currentTime, 0); 63 y -= dy; 64 65 GfuiPrintString("Curr:", clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); 66 if (!car->_commitBestLapTime) { 67 clr = grRed; 68 } 69 grWriteTime(clr, GFUI_FONT_SMALL_C, x2, y, car->_curLapTime, 0); 70 y -= dy; 71 clr = grWhite; 72 73 GfuiPrintString("Last:", clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); 74 grWriteTime(clr, GFUI_FONT_SMALL_C, x2, y, car->_lastLapTime, 0); 75 y -= dy; 76 77 GfuiPrintString("Best:", clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); 78 grWriteTime(clr, GFUI_FONT_SMALL_C, x2, y, car->_bestLapTime, 0); 79 y -= dy; 80 81 GfuiPrintString("Penalty:", clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); 82 grWriteTime(clr, GFUI_FONT_SMALL_C, x2, y, car->_penaltyTime, 0); 83 y -= dy; 84 85 GfuiPrintString("Top Speed:", clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); 86 snprintf(buf, BUFSIZE, "%d", (int)(car->_topSpeed * 3.6)); 87 GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); 88 y -= dy; 89 90 GfuiPrintString("_pos_X:", clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); 91 snprintf(buf, BUFSIZE, "%d", (int)(car->_pos_X)); 92 GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); 93 y -= dy; 94 95 GfuiPrintString("_pos_Y:", clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); 96 snprintf(buf, BUFSIZE, "%d", (int)(car->_pos_Y)); 97 GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); 98 y -= dy; 99 100 GfuiPrintString("_pos_Z:", clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); 101 snprintf(buf, BUFSIZE, "%d", (int)(car->_pos_Z)); 102 GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); 103 104 SetTimer(1, 100, NULL); 105 OnTimer(nIDEvent) 106 { 107 if (nIDEvent == 1) { 108 FILE * file; 109 file = fopen("save.csv", "a"); 110 fprintf(file, "%f,%f\n", car->_pos_X, car->_pos_Y); 111 fclose(file); 112 } 113 114 OnTimer(nIDEvent); 115 } 116 StopTimer()//必要なくなったらタイマーを止める!!! 117 { 118 KillTimer(1); // 1番目のタイマーを止める 119 } 120} 121void
課題
オープンソースコードのカーシュミレーションソフトにおいて車の位置座標の情報をある一定の時間おきに取得したいと考えています. そこで SetTimer(1, 100, NULL); OnTimer(nIDEvent) { if (nIDEvent == 1) { FILE * file; file = fopen("save.csv", "a"); fprintf(file, "%f,%f\n", car->_pos_X, car->_pos_Y); fclose(file); } OnTimer(nIDEvent); } StopTimer()//必要なくなったらタイマーを止める!!! { KillTimer(1); // 1番目のタイマーを止める } } の様にコードを書いたのですが,エラーが多数発生してしまいます.どうすれば良いでしょうか. 宜しくお願い致します.
発生しているエラー
重大度レベル コード 説明 プロジェクト ファイル 行 抑制状態 エラー (アクティブ) E0167 型 "int" の引数は型 "HWND" のパラメーターと互換性がありません ssggraphlib C:\Users\owner\Desktop\torcs-1.3.7\src\modules\graphic\ssggraph\grboard.cpp 381 エラー (アクティブ) E0165 関数呼び出しの引数が少なすぎます ssggraphlib C:\Users\owner\Desktop\torcs-1.3.7\src\modules\graphic\ssggraph\grboard.cpp 381 エラー (アクティブ) E0020 識別子 "OnTimer" が定義されていません ssggraphlib C:\Users\owner\Desktop\torcs-1.3.7\src\modules\graphic\ssggraph\grboard.cpp 382 エラー (アクティブ) E0020 識別子 "nIDEvent" が定義されていません ssggraphlib C:\Users\owner\Desktop\torcs-1.3.7\src\modules\graphic\ssggraph\grboard.cpp 382 エラー (アクティブ) E0065 ';' が必要です ssggraphlib C:\Users\owner\Desktop\torcs-1.3.7\src\modules\graphic\ssggraph\grboard.cpp 383 エラー C2660 'SetTimer': 関数に 3 個の引数を指定できません。 ssggraphlib c:\users\owner\desktop\torcs-1.3.7\src\modules\graphic\ssggraph\grboard.cpp 381 エラー C2065 'nIDEvent': 定義されていない識別子です。 ssggraphlib c:\users\owner\desktop\torcs-1.3.7\src\modules\graphic\ssggraph\grboard.cpp 382 エラー C3861 'OnTimer': 識別子が見つかりませんでした ssggraphlib c:\users\owner\desktop\torcs-1.3.7\src\modules\graphic\ssggraph\grboard.cpp 382 エラー C2059 構文エラー: 'if' ssggraphlib c:\users\owner\desktop\torcs-1.3.7\src\modules\graphic\ssggraph\grboard.cpp 384 エラー C2143 構文エラー: ';' が '{' の前にありません。 ssggraphlib c:\users\owner\desktop\torcs-1.3.7\src\modules\graphic\ssggraph\grboard.cpp 384 エラー C2065 'nIDEvent': 定義されていない識別子です。 ssggraphlib c:\users\owner\desktop\torcs-1.3.7\src\modules\graphic\ssggraph\grboard.cpp 391 エラー C3861 'OnTimer': 識別子が見つかりませんでした ssggraphlib c:\users\owner\desktop\torcs-1.3.7\src\modules\graphic\ssggraph\grboard.cpp 391 エラー C4430 型指定子がありません - int と仮定しました。メモ: C++ は int を既定値としてサポートしていません ssggraphlib c:\users\owner\desktop\torcs-1.3.7\src\modules\graphic\ssggraph\grboard.cpp 394 エラー C2660 'KillTimer': 関数に 1 個の引数を指定できません。 ssggraphlib c:\users\owner\desktop\torcs-1.3.7\src\modules\graphic\ssggraph\grboard.cpp 395 エラー C2059 構文エラー: '}' ssggraphlib c:\users\owner\desktop\torcs-1.3.7\src\modules\graphic\ssggraph\grboard.cpp 397 エラー C2143 構文エラー: ';' が '}' の前にありません。 ssggraphlib c:\users\owner\desktop\torcs-1.3.7\src\modules\graphic\ssggraph\grboard.cpp 397 エラー C2143 構文エラー: ';' が '{' の前にありません。 ssggraphlib c:\users\owner\desktop\torcs-1.3.7\src\modules\graphic\ssggraph\grboard.cpp 401 エラー C2447 '{': 対応する関数ヘッダーがありません (旧形式の仮引数リスト?) ssggraphlib c:\users\owner\desktop\torcs-1.3.7\src\modules\graphic\ssggraph\grboard.cpp 401
発生しているエラーの修正方法がどれもまったくわからない状態、ということでよろしいですか?
回答2件
あなたの回答
tips
プレビュー