diff --git a/source/src/Makefile b/source/src/Makefile index f00e07cc..240b90be 100644 --- a/source/src/Makefile +++ b/source/src/Makefile @@ -14,7 +14,6 @@ endif endif MV=mv - ifneq (,$(findstring MINGW,$(PLATFORM))) WINDRES= windres CLIENT_INCLUDES= $(INCLUDES) -I../include @@ -160,7 +159,6 @@ client: libenet $(CLIENT_OBJS) server: libenet $(SERVER_OBJS) $(CXX) $(CXXFLAGS) -o ac_server $(SERVER_OBJS) $(SERVER_LIBS) - master: libenet $(MASTER_OBJS) $(CXX) $(CXXFLAGS) -o ac_master $(MASTER_OBJS) $(SERVER_LIBS) diff --git a/source/src/audiomanager.cpp b/source/src/audiomanager.cpp index 88b3be5b..1ed146cc 100644 --- a/source/src/audiomanager.cpp +++ b/source/src/audiomanager.cpp @@ -89,7 +89,7 @@ void audiomanager::initsound() } } -void audiomanager::music(char *name, char *millis, char *cmd) +void audiomanager::music(char *name, int millis, char *cmd) { if(nosound) return; stopsound(); @@ -100,11 +100,11 @@ void audiomanager::music(char *name, char *millis, char *cmd) if(gamemusic->open(name)) { // fade - if(atoi(millis) > 0) + if(millis > 0) { const int fadetime = 1000; gamemusic->fadein(lastmillis, fadetime); - gamemusic->fadeout(lastmillis+atoi(millis), fadetime); + gamemusic->fadeout(lastmillis+millis, fadetime); } // play @@ -428,14 +428,14 @@ void voicecom(char *sound, char *text) } } -COMMAND(voicecom, ARG_2STR); +COMMAND(voicecom, "ss"); void soundtest() { loopi(S_NULL) audiomgr.playsound(i, rnd(SP_HIGH+1)); } -COMMAND(soundtest, ARG_NONE); +COMMAND(soundtest, ""); // sound configuration @@ -754,30 +754,30 @@ bool staticreference::operator==(const worldobjreference &other) audiomanager audiomgr; -COMMANDF(sound, ARG_1INT, (int n) +COMMANDF(sound, "i", (int *n) { - audiomgr.playsound(n); + audiomgr.playsound(*n); }); -COMMANDF(applymapsoundchanges, ARG_NONE, (){ +COMMANDF(applymapsoundchanges, "", (){ audiomgr.applymapsoundchanges(); }); -COMMANDF(unmuteallsounds, ARG_NONE, () { +COMMANDF(unmuteallsounds, "", () { audiomgr.unmuteallsounds(); }); -COMMANDF(mutesound, ARG_2INT, (int n, int off) +COMMANDF(mutesound, "ii", (int *n, int *off) { - audiomgr.mutesound(n, off); + audiomgr.mutesound(*n, *off); }); -ICOMMANDF(soundmuted, ARG_1EXP, (int n) +COMMANDF(soundmuted, "i", (int *n) { - return audiomgr.soundmuted(n); + intret(audiomgr.soundmuted(*n)); }); -COMMANDF(mapsoundreset, ARG_NONE, () +COMMANDF(mapsoundreset, "", () { audiomgr.mapsoundreset(); }); @@ -786,28 +786,28 @@ VARF(soundchannels, 4, 32, 1024, audiomgr.setchannels(soundchannels); ); VARFP(soundvol, 0, 128, 255, audiomgr.setlistenervol(soundvol); ); -COMMANDF(registersound, ARG_4STR, (char *name, char *vol, char *loop, char *audibleradius) +COMMANDF(registersound, "siii", (char *name, int *vol, int *loop, int *audibleradius) { - intret(audiomgr.addsound(name, atoi(vol), -1, atoi(loop) != 0, gamesounds, true, atoi(audibleradius))); + intret(audiomgr.addsound(name, *vol, -1, *loop != 0, gamesounds, true, *audibleradius)); }); -COMMANDF(mapsound, ARG_2STR, (char *name, char *maxuses) +COMMANDF(mapsound, "si", (char *name, int *maxuses) { - audiomgr.addsound(name, 255, atoi(maxuses), true, mapsounds, false, 0); + audiomgr.addsound(name, 255, *maxuses, true, mapsounds, false, 0); }); -COMMANDF(registermusic, ARG_1STR, (char *name) +COMMANDF(registermusic, "s", (char *name) { audiomgr.registermusic(name); }); -COMMANDF(musicpreload, ARG_1INT, (int id) +COMMANDF(musicpreload, "i", (int *id) { - audiomgr.musicpreload(id); + audiomgr.musicpreload(*id); }); -COMMANDF(music, ARG_3STR, (char *name, char *millis, char *cmd) +COMMANDF(music, "sis", (char *name, int *millis, char *cmd) { - audiomgr.music(name, millis, cmd); + audiomgr.music(name, *millis, cmd); }); diff --git a/source/src/bot/bot_waypoint.cpp b/source/src/bot/bot_waypoint.cpp index 332a963f..2cffb269 100644 --- a/source/src/bot/bot_waypoint.cpp +++ b/source/src/bot/bot_waypoint.cpp @@ -32,7 +32,7 @@ CWaypointClass::CWaypointClass(void) : m_bDrawWaypoints(false), m_bDrawWPPaths(t m_bDrawWPText(false), m_vLastCreatedWP(g_vecZero), m_bFlooding(false), m_bFilteringNodes(false), m_iFloodStartTime(0), m_iCurFloodX(0), - m_iCurFloodY(0), m_iFloodSize(0), + m_iCurFloodY(0), m_iFloodSize(0), m_iFilteredNodes(0), m_iWaypointCount(0) { loopi(MAX_MAP_GRIDS) @@ -43,7 +43,7 @@ CWaypointClass::CWaypointClass(void) : m_bDrawWaypoints(false), m_bDrawWPPaths(t delete m_Waypoints[i][j].Pop(); } } - + m_szMapName[0] = 0; } @@ -80,7 +80,7 @@ void CWaypointClass::Clear() delete p; } } - } + } } //fixme @@ -105,12 +105,12 @@ bool CWaypointClass::LoadWaypoints() bfp = openfile(filename, "rb"); BotManager.m_sCurrentTriggerNr = -1; - + // if file exists, read the waypoint structure from it if (bfp != NULL) { bfp->read(&header, sizeof(header)); - + header.szFileType[sizeof(header.szFileType)-1] = 0; if (strcmp(header.szFileType, "cube_bot") == 0) { @@ -124,27 +124,27 @@ bool CWaypointClass::LoadWaypoints() if (header.iFileVersion == 1) { // First version, works with an big array and has a limit - + waypoint_version_1_s WPs[1024]; int path_index; - - m_iWaypointCount = header.iWPCount; + + m_iWaypointCount = header.iWPCount; for (i=0; i < header.iWPCount; i++) { bfp->read(&WPs[i], sizeof(WPs[0])); WPs[i].ConnectedWPs.Reset(); // We get garbage when we read this from // a file, so just clear it - + // Convert to new waypoint structure node_s *pNode = new node_s(WPs[i].v_origin, WPs[i].iFlags, 0); - + short x, y; GetNodeIndexes(pNode->v_origin, &x, &y); - + m_Waypoints[x][y].AddNode(pNode); BotManager.AddWaypoint(pNode); } - + // read and add waypoint paths... for (i=0; i < m_iWaypointCount; i++) { @@ -153,73 +153,73 @@ bool CWaypointClass::LoadWaypoints() // See which waypoint the current is node_s *pCurrent = GetWaypointFromVec(WPs[i].v_origin); - + if (!pCurrent) { conoutf("Error: NULL path in waypoint file"); continue; } - + for (j=0; j < num; j++) { bfp->read(&path_index, sizeof(path_index)); - + // See which waypoint this is node_s *pTo = GetWaypointFromVec(WPs[path_index].v_origin); - + if (!pTo) { conoutf("Error: NULL path in waypoint file"); continue; } - + AddPath(pCurrent, pTo); - } + } } conoutf("Old waypoint version(%d) converted to new version(%d)", header.iFileVersion, WAYPOINT_VERSION); conoutf("Use the wpsave command to convert permently"); - + } else if (header.iFileVersion == 2) { m_iWaypointCount = header.iWPCount; - + for (i=0; i < header.iWPCount; i++) { bfp->read(&from, sizeof(from)); // Read origin bfp->read(&flags, sizeof(flags)); // Read waypoint flags bfp->read(&triggernr, sizeof(triggernr)); // Read trigger nr bfp->read(&yaw, sizeof(yaw)); // Read target yaw - + node_s *pNode = new node_s(from, flags, triggernr, yaw); - + short x, y; GetNodeIndexes(pNode->v_origin, &x, &y); - + m_Waypoints[x][y].AddNode(pNode); BotManager.AddWaypoint(pNode); - + if ((BotManager.m_sCurrentTriggerNr == -1) || (triggernr < BotManager.m_sCurrentTriggerNr)) BotManager.m_sCurrentTriggerNr = triggernr; } - + for (i=0; i < header.iWPCount; i++) { // read the number of paths from this node... bfp->read(&num, sizeof(num)); bfp->read(&from, sizeof(from)); - + if (!num) continue; - + node_s *pCurrent = GetWaypointFromVec(from); - + if (!pCurrent) { conoutf("Error: NULL path in waypoint file"); - + for(j=0;jread(&to, sizeof(to)); // Read rest of block continue; } @@ -230,7 +230,7 @@ bool CWaypointClass::LoadWaypoints() node_s *p = GetWaypointFromVec(to); if (p) AddPath(pCurrent, p); - } + } } } else if (header.iFileVersion > WAYPOINT_VERSION) @@ -275,9 +275,9 @@ bool CWaypointClass::LoadWaypoints() if (BotManager.m_sCurrentTriggerNr == -1) BotManager.m_sCurrentTriggerNr = 0; - + ReCalcCosts(); - + conoutf("Waypoints for map %s loaded", (m_szMapName)); testx = m_Waypoints[1][1].pNodeList; @@ -318,10 +318,10 @@ void CWaypointClass::SaveWaypoints() "the right permissions are set"); return; } - + // write the waypoint header to the file... bfp->write(&header, sizeof(header)); - + // write the waypoint data to the file... loopi(MAX_MAP_GRIDS) { @@ -334,29 +334,29 @@ void CWaypointClass::SaveWaypoints() bfp->write(&p->Entry->iFlags, sizeof(p->Entry->iFlags)); // Write waypoint flags bfp->write(&p->Entry->sTriggerNr, sizeof(p->Entry->sTriggerNr)); // Write trigger nr bfp->write(&p->Entry->sYaw, sizeof(p->Entry->sYaw)); // Write target yaw - + p = p->next; - } + } } } - + loopi(MAX_MAP_GRIDS) { loopj(MAX_MAP_GRIDS) { TLinkedList::node_s *p = m_Waypoints[i][j].GetFirst(); while(p) - { + { // save the waypoint paths... - + // count the number of paths from this node... pPath = p->Entry->ConnectedWPs.GetFirst(); num = p->Entry->ConnectedWPs.NodeCount(); - + bfp->write(&num, sizeof(num)); // write the count bfp->write(&p->Entry->v_origin, sizeof(p->Entry->v_origin)); // write the origin of this path - - // now write out each path... + + // now write out each path... while (pPath != NULL) { bfp->write(&pPath->Entry->v_origin, sizeof(pPath->Entry->v_origin)); @@ -366,7 +366,7 @@ void CWaypointClass::SaveWaypoints() } } } - + delete bfp; } @@ -382,7 +382,7 @@ bool CWaypointClass::LoadWPExpFile() if (m_iWaypointCount == 0) return false; - + strcpy(szWPFileName, m_szMapName); strcat(szWPFileName, ".exp"); @@ -394,7 +394,7 @@ bool CWaypointClass::LoadWPExpFile() if (bfp != NULL) { fread(&header, sizeof(header), 1, bfp); - + header.szFileType[sizeof(header.szFileType)-1] = 0; if (strcmp(header.szFileType, "cube_bot") == 0) { @@ -404,17 +404,17 @@ bool CWaypointClass::LoadWPExpFile() { // Check which waypoint file version this is, handle each of them different if (header.iFileVersion == 1) - { + { for (i=0; i < header.iWPCount; i++) { // read the number of paths from this node... fread(&num, sizeof(num), 1, bfp); fread(&from, sizeof(vec), 1, bfp); - + if (!num) continue; - + node_s *pCurrent = GetWaypointFromVec(from); - + if (!pCurrent) { conoutf("Error: NULL node in waypoint experience file"); @@ -429,7 +429,7 @@ bool CWaypointClass::LoadWPExpFile() { pCurrent->FailedGoalList.AddNode(p); } - } + } } } else if (header.iFileVersion > EXP_WP_VERSION) @@ -480,7 +480,7 @@ void CWaypointClass::SaveWPExpFile() { if (!m_iWaypointCount) return; - + char filename[256]; char mapname[64]; waypoint_header_s header; @@ -511,11 +511,11 @@ void CWaypointClass::SaveWPExpFile() "the right permissions are set"); return; } - + // write the waypoint header to the file... fwrite(&header, sizeof(header), 1, bfp); - - // save the waypoint experience data... + + // save the waypoint experience data... loopi(MAX_MAP_GRIDS) { loopj(MAX_MAP_GRIDS) @@ -523,12 +523,12 @@ void CWaypointClass::SaveWPExpFile() TLinkedList::node_s *p = m_Waypoints[i][j].GetFirst(); while(p) { - // count the number of paths from this node... + // count the number of paths from this node... TLinkedList::node_s *p2 = p->Entry->FailedGoalList.GetFirst(); num = p->Entry->FailedGoalList.NodeCount(); if (!num || !p2) continue; - + fwrite(&num, sizeof(num), 1, bfp); // write the count fwrite(&p->Entry->v_origin, sizeof(vec), 1, bfp); // write the origin of this node @@ -542,18 +542,18 @@ void CWaypointClass::SaveWPExpFile() } } } - + fclose(bfp); } void CWaypointClass::Think() { if (dedserv) return; - + #ifdef WP_FLOOD FloodThink(); #endif - + if (m_bAutoWaypoint) // is auto waypoint on? { // find the distance from the last used waypoint @@ -561,7 +561,7 @@ void CWaypointClass::Think() bool NoLastCreatedWP = ((m_vLastCreatedWP.x == 0) && (m_vLastCreatedWP.y == 0) && (m_vLastCreatedWP.z == 0)); - + if ((flDistance > 3.0f) || NoLastCreatedWP) { // check that no other reachable waypoints are nearby... @@ -576,18 +576,18 @@ void CWaypointClass::Think() if (m_bDrawWPText) { node_s *nearestwp = GetNearestWaypoint(player1, 20.0f); - + #ifdef WP_FLOOD if (!nearestwp) nearestwp = GetNearestFloodWP(player1, 10.0f); #endif - + if (nearestwp) { char szWPInfo[256]; sprintf(szWPInfo, "Distance nearest waypoint: %f", GetDistance(player1->o, nearestwp->v_origin)); AddScreenText(szWPInfo); - + strcpy(szWPInfo, "Flags: "); if (nearestwp->iFlags & W_FL_TELEPORT) strcat(szWPInfo, "Teleport "); @@ -605,19 +605,19 @@ void CWaypointClass::Think() strcat(szWPInfo, "In tagged cube(s) "); if (strlen(szWPInfo) == 7) strcat(szWPInfo, "None"); - + AddScreenText(szWPInfo); - + if (nearestwp->sYaw != -1) AddScreenText("yaw %d", nearestwp->sYaw); - + sprintf(szWPInfo, "Waypoint has %d connections", nearestwp->ConnectedWPs.NodeCount()); AddScreenText(szWPInfo); AddScreenText("Base Cost: %d", nearestwp->sCost); } } - + if (m_bDrawWaypoints) // display the waypoints if turned on... { DrawNearWaypoints(); @@ -650,12 +650,12 @@ void CWaypointClass::DrawNearWaypoints() MaxJ = MAX_MAP_GRIDS - 1; node_s *nearestwp = WaypointClass.GetNearestWaypoint(curselection, 20.0f); - + #ifdef WP_FLOOD if (!nearestwp) nearestwp = GetNearestFloodWP(player1, 20.0f); #endif - + for (int x=MinI;x<=MaxI;x++) { for(int y=MinJ;y<=MaxJ;y++) @@ -671,12 +671,12 @@ void CWaypointClass::DrawNearWaypoints() vec e = o; o.z -= 2; e.z += 2; - + if (pNode->Entry->iFlags & W_FL_JUMP) { // draw a red waypoint linestyle(2.5f, 0xFF, 0x40, 0x40); - } + } else if (nearestwp == pNode->Entry) { // draw a green waypoint @@ -687,14 +687,14 @@ void CWaypointClass::DrawNearWaypoints() // draw a blue waypoint linestyle(2.5f, 0x40, 0x40, 0xFF); } - - line(int(o.x), int(o.y), int(o.z), int(e.x), int(e.y), int(e.z)); - + + line(int(o.x), int(o.y), int(o.z), int(e.x), int(e.y), int(e.z)); + if (flNearestDist > flDist) { flNearestDist = flDist; pNearest = pNode->Entry; - } + } } pNode = pNode->next; @@ -705,38 +705,38 @@ void CWaypointClass::DrawNearWaypoints() if (pNearest) { pNode = pNearest->ConnectedWPs.GetFirst(); - + linestyle(2.0f, 0xFF, 0xFF, 0xFF); - + while(pNode) { vec o = pNode->Entry->v_origin; vec e = pNearest->v_origin; - + line(int(o.x), int(o.y), int(o.z), int(e.x), int(e.y), int(e.z)); - + pNode = pNode->next; } - + // Has this waypoint an target yaw? if (pNearest->sYaw != -1) { vec angles(0, pNearest->sYaw, 0); vec from = pNearest->v_origin, end = pNearest->v_origin; vec forward, right, up; - + from.z = end.z = (pNearest->v_origin.z-1.0f); - + AnglesToVectors(angles, forward, right, up); forward.mul(5.0f); end.add(forward); - + linestyle(2.0f, 0xFF, 0x40, 0x40); line(int(from.x), int(from.y), int(from.z), int(end.x), int(end.y), int(end.z)); } } -#ifndef RELEASE_BUILD +#ifndef RELEASE_BUILD // check if path waypointing is on... if (m_bDrawWPPaths) { @@ -748,36 +748,36 @@ void CWaypointClass::DrawNearWaypoints() if (!pB->m_bCalculatingAStarPath && !pB->m_AStarNodeList.Empty()) { TLinkedList::node_s *pNode = pB->m_AStarNodeList.GetFirst(), *pNext; - + linestyle(2.5f, 0xFF, 0x40, 0x40); - + line((int)pB->m_pCurrentWaypoint->pNode->v_origin.x, (int)pB->m_pCurrentWaypoint->pNode->v_origin.y, (int)pB->m_pCurrentWaypoint->pNode->v_origin.z, (int)pNode->Entry->pNode->v_origin.x, (int)pNode->Entry->pNode->v_origin.y, (int)pNode->Entry->pNode->v_origin.z); - + while(pNode && pNode->next) { pNext = pNode->next; vec &v1 = pNode->Entry->pNode->v_origin; vec &v2 = pNext->Entry->pNode->v_origin; - + line(int(v1.x), int(v1.y), int(v1.z), int(v2.x), int(v2.y), int(v2.z)); - + pNode = pNode->next; } } - } + } } #endif - + glEnable(GL_CULL_FACE); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); if (intermission) return; - + /*for(int i=0;iPrevLocations.prevloc[i]==g_vecZero) continue; @@ -796,7 +796,7 @@ node_s *CWaypointClass::AddWaypoint(vec o, bool connectwp) short x, y; int flags = 0; if (S((int)o.x, (int)o.y)->tag) flags |= W_FL_INTAG; - + node_s *pNode = new node_s(o, flags, 0); m_vLastCreatedWP = o; @@ -804,19 +804,19 @@ node_s *CWaypointClass::AddWaypoint(vec o, bool connectwp) m_Waypoints[x][y].AddNode(pNode); BotManager.AddWaypoint(pNode); - + m_iWaypointCount++; - + if (connectwp && m_bAutoPlacePaths) { // Connect new waypoint with other near waypoints. - + loopi(MAX_MAP_GRIDS) { loopj(MAX_MAP_GRIDS) { TLinkedList::node_s *p = m_Waypoints[i][j].GetFirst(); - + while(p) { if (p->Entry == pNode) @@ -830,13 +830,13 @@ node_s *CWaypointClass::AddWaypoint(vec o, bool connectwp) AddPath(pNode, p->Entry); // Add a path from a to b if (WPIsReachable(p->Entry->v_origin, pNode->v_origin)) AddPath(p->Entry, pNode); // Add a path from b to a - + p = p->next; } } } } - + return pNode; } @@ -851,20 +851,20 @@ void CWaypointClass::DeleteWaypoint(vec v_src) conoutf("Error: Couldnīt find near waypoint"); return; } - + BotManager.DelWaypoint(pWP); - + // delete any paths that lead to this index... DeletePath(pWP); - + short x, y; GetNodeIndexes(pWP->v_origin, &x, &y); - + m_Waypoints[x][y].DeleteEntry(pWP); - + pWP->ConnectedWPs.DeleteAllNodes(); pWP->ConnectedWPsWithMe.DeleteAllNodes(); - + m_iWaypointCount--; delete pWP; } @@ -927,7 +927,7 @@ void CWaypointClass::ManuallyCreatePath(vec v_src, int iCmd, bool TwoWay) conoutf("Error: First waypoint unset"); return; } - + waypoint2 = GetNearestWaypoint(v_src, 7.0f); if (!waypoint2) @@ -968,7 +968,7 @@ void CWaypointClass::ManuallyDeletePath(vec v_src, int iCmd, bool TwoWay) conoutf("Error: First waypoint unset"); return; } - + waypoint2 = GetNearestWaypoint(v_src, 7.0f); if (!waypoint2) @@ -995,7 +995,7 @@ bool CWaypointClass::WPIsReachable(vec from, vec to) if (distance < REACHABLE_RANGE) { if (IsVisible(from, to)) - { + { if (UnderWater(from) && UnderWater(to)) { // No need to worry about heights in water @@ -1154,7 +1154,7 @@ node_s *CWaypointClass::GetNearestTriggerWaypoint(vec v_src, float flRange) pNode = pNode->next; continue; } - + flDist = GetDistance(v_src, pNode->Entry->v_origin); if ((flDist < flNearestDist) && (flDist <= flRange)) { @@ -1176,16 +1176,16 @@ node_s *CWaypointClass::GetWaypointFromVec(const vec &v_src) { static TLinkedList::node_s *pNode; static short x, y; - + GetNodeIndexes(v_src, &x, &y); - + pNode = m_Waypoints[x][y].GetFirst(); while(pNode) { if (pNode->Entry->v_origin==v_src) return pNode->Entry; - + pNode = pNode->next; } return NULL; @@ -1199,7 +1199,7 @@ void CWaypointClass::CalcCost(node_s *pNode) int x = int(pNode->v_origin.x); int y = int(pNode->v_origin.y); int a, b, row; - + for (row=0;row<=1;row++) { if (row==0) b = y - 6; @@ -1208,10 +1208,10 @@ void CWaypointClass::CalcCost(node_s *pNode) for (a=(x-6);a<=(x+6);a++) { if (OUTBORD(a, b)) continue; - + vec to(a, b, GetCubeFloor(a, b) + 1.0f); - - // See if there is a obstacle(cube or mapmodel) nearby + + // See if there is a obstacle(cube or mapmodel) nearby traceresult_s tr; TraceLine(pNode->v_origin, to, NULL, false, &tr); if (tr.collided) @@ -1220,26 +1220,26 @@ void CWaypointClass::CalcCost(node_s *pNode) GetDistance(pNode->v_origin, to)); flCost += (1.0f-flFraction)*0.5f; } - + if ((abs(a) > 4) || (abs(b) > 4)) continue; - + vec from = to; to.z -= (JUMP_HEIGHT - 1.0f); TraceLine(from, to, NULL, false, &tr); if (!tr.collided) flCost += 0.5f; } - + if (row==0) a = x - 6; else a = x + 6; for (b=(y-6);b<=(y+6);b++) { if (OUTBORD(a, b)) continue; - + vec to(a, b, GetCubeFloor(a, b) + 1.0f); - - // See if there is a obstacle(cube or mapmodel) nearby + + // See if there is a obstacle(cube or mapmodel) nearby traceresult_s tr; TraceLine(pNode->v_origin, to, NULL, false, &tr); if (tr.collided) @@ -1248,9 +1248,9 @@ void CWaypointClass::CalcCost(node_s *pNode) GetDistance(pNode->v_origin, to)); flCost += (1.0f-flFraction)*0.5f; } - + if ((abs(a) > 4) || (abs(b) > 4)) continue; - + vec from = to; to.z -= (JUMP_HEIGHT - 1.0f); TraceLine(from, to, NULL, false, &tr); @@ -1258,11 +1258,11 @@ void CWaypointClass::CalcCost(node_s *pNode) flCost += 0.5f; } } - + if (UnderWater(pNode->v_origin)) // Water is annoying flCost += 5.0f; - - pNode->sCost = (short)flCost; + + pNode->sCost = (short)flCost; } void CWaypointClass::ReCalcCosts(void) @@ -1286,7 +1286,7 @@ void CWaypointClass::ReCalcCosts(void) void CWaypointClass::StartFlood() { if (m_bFlooding) return; - + conoutf("Starting flood, this may take a while on large maps...."); m_bFlooding = true; m_iFloodStartTime = SDL_GetTicks(); @@ -1297,10 +1297,10 @@ void CWaypointClass::StartFlood() void CWaypointClass::FloodThink() { if (!m_bFlooding) return; - + static int x, y, count; count = 0; - + if (!m_bFilteringNodes) { // loop through ALL cubes and check if we should add a waypoint here @@ -1313,14 +1313,14 @@ void CWaypointClass::FloodThink() m_iCurFloodX = x; return; } - + count++; for (y=MINBORD; y<(ssize-MINBORD); y+=4) - { + { vec from(x, y, GetCubeFloor(x, y)+2.0f); bool bFound = CanPlaceNodeHere(from); - + if (!bFound) { for (int a=x-2;a<=(x+2);a++) @@ -1336,41 +1336,41 @@ void CWaypointClass::FloodThink() break; } } - + if (bFound) break; } } - + if (!bFound) continue; - + // Add WP int flags = W_FL_FLOOD; if (S((int)from.x, (int)from.y)->tag) flags |= W_FL_INTAG; - + node_s *pWP = new node_s(from, flags, 0); - + short i, j; GetNodeIndexes(from, &i, &j); m_Waypoints[i][j].PushNode(pWP); BotManager.AddWaypoint(pWP); m_iFloodSize += sizeof(node_s); - m_iWaypointCount++; - + m_iWaypointCount++; + // Connect with other nearby nodes ConnectFloodWP(pWP); } } } - + if (!m_bFilteringNodes) { m_bFilteringNodes = true; m_iCurFloodX = m_iCurFloodY = 0; m_iFilteredNodes = 0; } - + count = 0; - + // Filter all nodes which aren't connected to any other nodes for (x=m_iCurFloodX;x::node_s *pNode = m_Waypoints[x][y].GetFirst(), *pTemp; @@ -1408,20 +1408,20 @@ void CWaypointClass::FloodThink() } } } - + // Done with flooding m_bFlooding = false; m_bFilteringNodes = false; - + //ReCalcCosts(); BotManager.PickNextTrigger(); - + m_iFloodSize += sizeof(m_Waypoints); conoutf("Added %d wps in %d milliseconds", m_iWaypointCount, SDL_GetTicks()-m_iFloodStartTime); conoutf("Filtered %d wps", m_iFilteredNodes); - + BotManager.CalculateMaxAStarCount(); - + char szSize[64]; sprintf(szSize, "Total size: %.2f Kb", float(m_iFloodSize)/1024.0f); conoutf(szSize); @@ -1432,23 +1432,23 @@ bool CWaypointClass::CanPlaceNodeHere(const vec &from) static short x, y, a, b; static traceresult_s tr; static vec to, v1, v2; - + x = short(from.x); y = short(from.y); - + sqr *s = S(x, y); if (SOLID(s)) { return false; } - + if (fabs((float)(s->ceil - s->floor)) < player1->radius) { return false; } if (GetNearestFloodWP(from, 2.0f, NULL)) return false; - + for (a=(x-1);a<=(x+1);a++) { for (b=(y-1);b<=(y+1);b++) @@ -1458,10 +1458,10 @@ bool CWaypointClass::CanPlaceNodeHere(const vec &from) makevec(&v1, a, b, from.z); v2 = v1; v2.z -= 1000.0f; - + TraceLine(v1, v2, NULL, false, &tr, true); to = tr.end; - + if ((a >= (x-1)) && (a <= (x+1)) && (b >= (y-1)) && (b <= (y+1))) { if (!tr.collided || (to.z < (from.z-4.0f))) @@ -1469,14 +1469,14 @@ bool CWaypointClass::CanPlaceNodeHere(const vec &from) return false; } } - + to.z += 2.0f; - + if (from.z < (to.z-JUMP_HEIGHT)) { return false; - } - + } + TraceLine(from, to, NULL, false, &tr, true); if (tr.collided) return false; @@ -1489,13 +1489,13 @@ bool CWaypointClass::CanPlaceNodeHere(const vec &from) void CWaypointClass::ConnectFloodWP(node_s *pWP) { if (!pWP) return; - + static float flRange; static TLinkedList::node_s *pNode; static short i, j, MinI, MaxI, MinJ, MaxJ, x, y, Offset; static float flDist; static node_s *p; - + // Calculate range, based on distance to nearest node p = GetNearestFloodWP(pWP->v_origin, 15.0f, pWP, true); if (p) @@ -1506,7 +1506,7 @@ void CWaypointClass::ConnectFloodWP(node_s *pWP) } else return; - + Offset = (short)ceil(flRange / MAX_MAP_GRIDS); GetNodeIndexes(pWP->v_origin, &i, &j); @@ -1546,11 +1546,11 @@ void CWaypointClass::ConnectFloodWP(node_s *pWP) // Connect a with b pWP->ConnectedWPs.AddNode(pNode->Entry); pNode->Entry->ConnectedWPsWithMe.AddNode(pWP); - + // Connect b with a pNode->Entry->ConnectedWPs.AddNode(pWP); pWP->ConnectedWPsWithMe.AddNode(pNode->Entry); - + m_iFloodSize += (2 * sizeof(node_s *)); } } @@ -1691,8 +1691,8 @@ void CWaypointClass::GetNodeIndexes(const vec &v_origin, short *i, short *j) // AC waypoint class begin void CACWaypointClass::StartFlood() -{ - // UNDONE? +{ + // UNDONE? CWaypointClass::StartFlood(); } @@ -1705,19 +1705,19 @@ void CACWaypointClass::StartFlood() void CCubeWaypointClass::StartFlood() { CWaypointClass::StartFlood(); - + // Add wps at triggers and teleporters and their destination loopv(ents) { entity &e = ents[i]; - + if (OUTBORD(e.x, e.y)) continue; if (e.type == TELEPORT) { vec telepos = { e.x, e.y, S(e.x, e.y)->floor+player1->eyeheight }, teledestpos = g_vecZero; - - // Find the teleport destination + + // Find the teleport destination int n = -1, tag = e.attr1, beenhere = -1; for(;;) { @@ -1732,65 +1732,65 @@ void CCubeWaypointClass::StartFlood() break; } } - + if (vis(teledestpos, g_vecZero)) continue; - + int flags = (W_FL_FLOOD | W_FL_TELEPORT); if (S((int)telepos.x, (int)telepos.y)->tag) flags |= W_FL_INTAG; - + // Add waypoint at teleporter and teleport destination node_s *pWP = new node_s(telepos, flags, 0); - + short i, j; GetNodeIndexes(telepos, &i, &j); m_Waypoints[i][j].PushNode(pWP); BotManager.AddWaypoint(pWP); - m_iFloodSize += sizeof(node_s); + m_iFloodSize += sizeof(node_s); m_iWaypointCount++; - + flags = (W_FL_FLOOD | W_FL_TELEPORTDEST); if (S((int)teledestpos.x, (int)teledestpos.y)->tag) flags |= W_FL_INTAG; node_s *pWP2 = new node_s(teledestpos, flags, 0); - + GetNodeIndexes(teledestpos, &i, &j); m_Waypoints[i][j].PushNode(pWP2); BotManager.AddWaypoint(pWP2); - m_iFloodSize += sizeof(node_s); + m_iFloodSize += sizeof(node_s); m_iWaypointCount++; - + // Connect the teleporter waypoint with the teleport-destination waypoint(1 way) AddPath(pWP, pWP2); - + // Connect with other nearby nodes - ConnectFloodWP(pWP); + ConnectFloodWP(pWP); } else if (e.type == CARROT) { vec pos = { e.x, e.y, S(e.x, e.y)->floor+player1->eyeheight }; - + int flags = (W_FL_FLOOD | W_FL_TRIGGER); if (S(e.x, e.y)->tag) flags |= W_FL_INTAG; - + node_s *pWP = new node_s(pos, flags, 0); - + short i, j; GetNodeIndexes(pos, &i, &j); m_Waypoints[i][j].PushNode(pWP); BotManager.AddWaypoint(pWP); - m_iFloodSize += sizeof(node_s); + m_iFloodSize += sizeof(node_s); m_iWaypointCount++; - + // Connect with other nearby nodes - ConnectFloodWP(pWP); + ConnectFloodWP(pWP); } else if (e.type == MAPMODEL) { mapmodelinfo &mmi = getmminfo(e.attr2); if(!&mmi || !mmi.h || !mmi.rad) continue; - + float floor = (float)(S(e.x, e.y)->floor+mmi.zoff+e.attr3)+mmi.h; - + float x1 = e.x - mmi.rad; float x2 = e.x + mmi.rad; float y1 = e.y - mmi.rad; @@ -1803,25 +1803,25 @@ void CCubeWaypointClass::StartFlood() { vec from = { x, y, floor+2.0f }; if (GetNearestFloodWP(from, 2.0f, NULL)) continue; - + // Add WP int flags = W_FL_FLOOD; if (S((int)x, (int)y)->tag) flags |= W_FL_INTAG; - + node_s *pWP = new node_s(from, flags, 0); - + short i, j; GetNodeIndexes(from, &i, &j); m_Waypoints[i][j].PushNode(pWP); BotManager.AddWaypoint(pWP); - m_iFloodSize += sizeof(node_s); + m_iFloodSize += sizeof(node_s); m_iWaypointCount++; - + // Connect with other nearby nodes ConnectFloodWP(pWP); } } - } + } } CWaypointClass::StartFlood(); } @@ -1831,13 +1831,13 @@ void CCubeWaypointClass::CreateWPsAtTeleporters() loopv(ents) { entity &e = ents[i]; - + if (e.type != TELEPORT) continue; if (OUTBORD(e.x, e.y)) continue; vec telepos = { e.x, e.y, S(e.x, e.y)->floor+player1->eyeheight }, teledestpos = g_vecZero; - - // Find the teleport destination + + // Find the teleport destination int n = -1, tag = e.attr1, beenhere = -1; for(;;) { @@ -1852,38 +1852,38 @@ void CCubeWaypointClass::CreateWPsAtTeleporters() break; } } - + if (vis(teledestpos, g_vecZero)) continue; - + // Add waypoint at teleporter and teleport destination node_s *telewp = AddWaypoint(telepos, false); node_s *teledestwp = AddWaypoint(teledestpos, false); - + if (telewp && teledestwp) { // Connect the teleporter waypoint with the teleport-destination waypoint(1 way) AddPath(telewp, teledestwp); - + // Flag waypoints telewp->iFlags = W_FL_TELEPORT; teledestwp->iFlags = W_FL_TELEPORTDEST; } } } - + void CCubeWaypointClass::CreateWPsAtTriggers() { loopv(ents) { entity &e = ents[i]; - + if (e.type != CARROT) continue; if (OUTBORD(e.x, e.y)) continue; vec pos = { e.x, e.y, S(e.x, e.y)->floor+player1->eyeheight }; - + node_s *wp = AddWaypoint(pos, false); - + if (wp) { // Flag waypoints @@ -1898,65 +1898,65 @@ void CCubeWaypointClass::CreateWPsAtTriggers() // Waypoint commands begin -void addwp(int autoconnect) +void addwp(int *autoconnect) { WaypointClass.SetWaypointsVisible(true); - WaypointClass.AddWaypoint(curselection, autoconnect!=0); + WaypointClass.AddWaypoint(curselection, *autoconnect!=0); } -COMMAND(addwp, ARG_1INT); +COMMAND(addwp, "i"); void delwp(void) { WaypointClass.SetWaypointsVisible(true); WaypointClass.DeleteWaypoint(curselection); } - -COMMAND(delwp, ARG_NONE); -void wpvisible(int on) +COMMAND(delwp, ""); + +void wpvisible(int *on) { - WaypointClass.SetWaypointsVisible(on!=0); + WaypointClass.SetWaypointsVisible(*on!=0); } -COMMAND(wpvisible, ARG_1INT); +COMMAND(wpvisible, "i"); void wpsave(void) { WaypointClass.SaveWaypoints(); } -COMMAND(wpsave, ARG_NONE); +COMMAND(wpsave, ""); void wpload(void) { WaypointClass.LoadWaypoints(); } -COMMAND(wpload, ARG_NONE); +COMMAND(wpload, ""); void wpclear(void) { WaypointClass.Clear(); } -COMMAND(wpclear, ARG_NONE); +COMMAND(wpclear, ""); -void autowp(int on) +void autowp(int *on) { WaypointClass.SetWaypointsVisible(true); - WaypointClass.SetAutoWaypoint(on!=0); + WaypointClass.SetAutoWaypoint(*on!=0); } -COMMAND(autowp, ARG_1INT); +COMMAND(autowp, "i"); -void wpinfo(int on) +void wpinfo(int *on) { WaypointClass.SetWaypointsVisible(true); - WaypointClass.SetWPInfo(on!=0); + WaypointClass.SetWPInfo(*on!=0); } -COMMAND(wpinfo, ARG_1INT); +COMMAND(wpinfo, "i"); void addpath1way1(void) { @@ -1964,7 +1964,7 @@ void addpath1way1(void) WaypointClass.ManuallyCreatePath(curselection, 1, false); } -COMMAND(addpath1way1, ARG_NONE); +COMMAND(addpath1way1, ""); void addpath1way2(void) { @@ -1972,7 +1972,7 @@ void addpath1way2(void) WaypointClass.ManuallyCreatePath(curselection, 2, false); } -COMMAND(addpath1way2, ARG_NONE); +COMMAND(addpath1way2, ""); void addpath2way1(void) { @@ -1980,7 +1980,7 @@ void addpath2way1(void) WaypointClass.ManuallyCreatePath(curselection, 1, true); } -COMMAND(addpath2way1, ARG_NONE); +COMMAND(addpath2way1, ""); void addpath2way2(void) { @@ -1988,7 +1988,7 @@ void addpath2way2(void) WaypointClass.ManuallyCreatePath(curselection, 2, true); } -COMMAND(addpath2way2, ARG_NONE); +COMMAND(addpath2way2, ""); void delpath1way1(void) { @@ -1996,7 +1996,7 @@ void delpath1way1(void) WaypointClass.ManuallyDeletePath(curselection, 1, false); } -COMMAND(delpath1way1, ARG_NONE); +COMMAND(delpath1way1, ""); void delpath1way2(void) { @@ -2004,7 +2004,7 @@ void delpath1way2(void) WaypointClass.ManuallyDeletePath(curselection, 2, false); } -COMMAND(delpath1way2, ARG_NONE); +COMMAND(delpath1way2, ""); void delpath2way1(void) { @@ -2012,7 +2012,7 @@ void delpath2way1(void) WaypointClass.ManuallyDeletePath(curselection, 1, true); } -COMMAND(delpath2way1, ARG_NONE); +COMMAND(delpath2way1, ""); void delpath2way2(void) { @@ -2020,7 +2020,7 @@ void delpath2way2(void) WaypointClass.ManuallyDeletePath(curselection, 2, true); } -COMMAND(delpath2way2, ARG_NONE); +COMMAND(delpath2way2, ""); void setjumpwp(void) { @@ -2031,7 +2031,7 @@ void setjumpwp(void) } } -COMMAND(setjumpwp, ARG_NONE); +COMMAND(setjumpwp, ""); void unsetjumpwp(void) { @@ -2042,18 +2042,18 @@ void unsetjumpwp(void) } } -COMMAND(unsetjumpwp, ARG_NONE); +COMMAND(unsetjumpwp, ""); -void setwptriggernr(int nr) +void setwptriggernr(int *nr) { node_s *wp = WaypointClass.GetNearestWaypoint(curselection, 20.0f); if (wp) { - WaypointClass.SetWPTriggerNr(wp, nr); + WaypointClass.SetWPTriggerNr(wp, *nr); } } -COMMAND(setwptriggernr, ARG_1INT); +COMMAND(setwptriggernr, "i"); void setwpyaw(void) { @@ -2064,7 +2064,7 @@ void setwpyaw(void) } } -COMMAND(setwpyaw, ARG_NONE); +COMMAND(setwpyaw, ""); #ifdef WP_FLOOD void wpflood(void) @@ -2072,7 +2072,7 @@ void wpflood(void) WaypointClass.StartFlood(); } -COMMAND(wpflood, ARG_NONE); +COMMAND(wpflood, ""); #endif #ifdef VANILLA_CUBE @@ -2083,7 +2083,7 @@ void addtelewps(void) WaypointClass.CreateWPsAtTeleporters(); } -COMMAND(addtelewps, ARG_NONE); +COMMAND(addtelewps, ""); void addtriggerwps(void) { @@ -2091,7 +2091,7 @@ void addtriggerwps(void) WaypointClass.CreateWPsAtTriggers(); } -COMMAND(addtriggerwps, ARG_NONE); +COMMAND(addtriggerwps, ""); #endif // Debug functions @@ -2108,22 +2108,22 @@ void botsheadtome(void) } } -COMMAND(botsheadtome, ARG_NONE); +COMMAND(botsheadtome, ""); void setdebuggoal(void) { v_debuggoal = player1->o; }; -COMMAND(setdebuggoal, ARG_NONE); +COMMAND(setdebuggoal, ""); void botsheadtodebuggoal(void) { loopv(bots) { if (!bots[i] || !bots[i]->pBot) continue; - + bots[i]->pBot->GoToDebugGoal(v_debuggoal); } } -COMMAND(botsheadtodebuggoal, ARG_NONE); +COMMAND(botsheadtodebuggoal, ""); #endif // RELEASE_BUILD @@ -2158,14 +2158,14 @@ bool CBot::FindWaypoint() pNode = pNode->next; continue; } - + wp = GetWPFromNode(pNode->Entry); if (!wp) { pNode = pNode->next; continue; } - + // if index is not a current or recent previous waypoint... if ((wp != m_pCurrentWaypoint) && (wp != m_pPrevWaypoints[0]) && @@ -2281,7 +2281,7 @@ bool CBot::HeadToWaypoint() !IsVisible(m_AStarNodeList.GetFirst()->Entry->pNode->v_origin)) Touching = false; } - + // save current distance as previous m_fPrevWaypointDistance = WPDist; @@ -2294,16 +2294,16 @@ bool CBot::HeadToWaypoint() // UNDONE: Inhuman m_pMyEnt->yaw = m_pMyEnt->targetyaw = m_pCurrentWaypoint->pNode->sYaw; } - + // Reached a jump waypoint? if (m_pCurrentWaypoint->pNode->iFlags & W_FL_JUMP) m_pMyEnt->jumpnext = true; - + m_fPrevWaypointDistance = 0.0f; // Does the bot has a goal? if (m_pCurrentGoalWaypoint) - { + { if (m_pCurrentWaypoint != m_pCurrentGoalWaypoint) { if (m_AStarNodeList.Empty()) @@ -2324,10 +2324,10 @@ bool CBot::HeadToWaypoint() } } } - + m_pCurrentWaypoint = m_AStarNodeList.Pop(); - if (!IsVisible(m_pCurrentWaypoint->pNode->v_origin)) + if (!IsVisible(m_pCurrentWaypoint->pNode->v_origin)) //(!(m_pCurrentWaypoint->iFlags & W_FL_TELEPORT))) { //m_UnreachableNodes.PushNode(unreachable_node_s(m_pCurrentGoalWaypoint, gpGlobals->time)); @@ -2367,7 +2367,7 @@ bool CBot::HeadToWaypoint() } } m_iWaypointHeadPauseTime = lastmillis + 75; - m_iWaypointTime += 75; + m_iWaypointTime += 75; } // keep turning towards the waypoint... @@ -2409,7 +2409,7 @@ bool CBot::HeadToWaypoint() m_pMyEnt->jumpnext = true; condebug("Low wall in HeadToWaypoint()"); } - + // Check if bot has to strafe if (m_iStrafeTime > lastmillis) SetMoveDir(m_iMoveDir, true); @@ -2417,17 +2417,17 @@ bool CBot::HeadToWaypoint() { m_iStrafeTime = 0; m_iMoveDir = DIR_NONE; - + vec forward, up, right; AnglesToVectors(GetViewAngles(), forward, right, up); - - float flLeftDist = -1.0f, flRightDist = -1.0f; + + float flLeftDist = -1.0f, flRightDist = -1.0f; vec dir = right; bool bStrafe = false; int iStrafeDir = 0; - + dir.mul(m_pMyEnt->radius); - + // Check left from = m_pMyEnt->o; from.sub(dir); @@ -2439,7 +2439,7 @@ bool CBot::HeadToWaypoint() from.add(dir); if (IsVisible(from, FORWARD, 3.0f, false, &flRightDist)) flRightDist = -1.0f; - + if ((flLeftDist != -1.0f) && (flRightDist != -1.0f)) { if (flLeftDist < flRightDist) @@ -2476,7 +2476,7 @@ bool CBot::HeadToWaypoint() bStrafe = true; iStrafeDir = LEFT; } - + if (bStrafe) { SetMoveDir(iStrafeDir, true); @@ -2485,7 +2485,7 @@ bool CBot::HeadToWaypoint() } } } - + return true; } @@ -2523,23 +2523,23 @@ bool CBot::HeadToGoal() return true; // else just wait a little bit longer } //ResetMoveSpeed(); - //return true; + //return true; } else { // Current waypoint isn't reachable, search new one waypoint_s *pWP = NULL; -#ifdef WP_FLOOD +#ifdef WP_FLOOD if (m_pCurrentGoalWaypoint->pNode->iFlags & W_FL_FLOOD) pWP = GetNearestFloodWP(8.0f); else -#endif +#endif pWP = GetNearestWaypoint(15.0f); if (!pWP || (pWP == m_pCurrentWaypoint)) return false; - + SetCurrentWaypoint(pWP); if (AStar()) { @@ -2552,13 +2552,13 @@ bool CBot::HeadToGoal() return true; } } - - //debugbeam(m_pMyEnt->o, m_pCurrentWaypoint->pNode->v_origin); + + //debugbeam(m_pMyEnt->o, m_pCurrentWaypoint->pNode->v_origin); } } else return false; - + return HeadToWaypoint(); } @@ -2574,7 +2574,7 @@ bool CBot::AStar() } return true; } - + // Ideas by PMB : // * Make locals static to speed up a bit // * MaxCycles per frame and make it fps dependent @@ -2598,34 +2598,34 @@ bool CBot::AStar() { return true; } - + BotManager.m_sUsingAStarBotsCount++; - + CleanAStarLists(false); - + m_pCurrentWaypoint->g[0] = m_pCurrentWaypoint->g[1] = 0; - m_pCurrentWaypoint->pParent[0] = m_pCurrentWaypoint->pParent[1] = NULL; + m_pCurrentWaypoint->pParent[0] = m_pCurrentWaypoint->pParent[1] = NULL; m_pCurrentGoalWaypoint->g[0] = m_pCurrentGoalWaypoint->g[1] = 0; m_pCurrentGoalWaypoint->pParent[0] = m_pCurrentGoalWaypoint->pParent[1] = NULL; m_AStarNodeList.DeleteAllNodes(); - + m_AStarOpenList[0].Clear(); m_AStarOpenList[1].Clear(); m_AStarClosedList[0].DeleteAllNodes(); m_AStarClosedList[1].DeleteAllNodes(); - + m_AStarOpenList[0].AddEntry(m_pCurrentWaypoint, GetDistance(m_pCurrentGoalWaypoint->pNode->v_origin)); m_AStarOpenList[1].AddEntry(m_pCurrentGoalWaypoint, GetDistance(m_pCurrentGoalWaypoint->pNode->v_origin)); - + m_pCurrentWaypoint->bIsOpen[0] = m_pCurrentGoalWaypoint->bIsOpen[1] = true; m_pCurrentWaypoint->bIsOpen[1] = m_pCurrentGoalWaypoint->bIsOpen[0] = false; m_pCurrentWaypoint->bIsClosed[0] = m_pCurrentGoalWaypoint->bIsClosed[1] = false; m_pCurrentWaypoint->bIsClosed[1] = m_pCurrentGoalWaypoint->bIsClosed[0] = false; } - + while(!m_AStarOpenList[0].Empty()) { if (iCurrentCycles >= (iMaxCycles/2)) @@ -2636,27 +2636,27 @@ bool CBot::AStar() n = m_AStarOpenList[0].Pop(); n->bIsOpen[0] = false; - + if (n->pNode->FailedGoalList.IsInList(m_pCurrentGoalWaypoint->pNode)) { bPathFailed = true; break; // Can't make path to goal } - + // Done with calculating if (n == m_pCurrentGoalWaypoint) { m_bCalculatingAStarPath = false; BotManager.m_sUsingAStarBotsCount--; - + while(n) { - m_AStarNodeList.PushNode(n); + m_AStarNodeList.PushNode(n); n = n->pParent[0]; } - CleanAStarLists(false); - + CleanAStarLists(false); + return true; } @@ -2669,37 +2669,37 @@ bool CBot::AStar() pPath = pPath->next; continue; } - + n2 = GetWPFromNode(pPath->Entry); - + if (!n2) { pPath = pPath->next; continue; } - + if (n2->bIsClosed[1]) { m_bCalculatingAStarPath = false; BotManager.m_sUsingAStarBotsCount--; - + while(n2) { m_AStarNodeList.AddNode(n2); n2 = n2->pParent[1]; } - + while(n) { - m_AStarNodeList.PushNode(n); + m_AStarNodeList.PushNode(n); n = n->pParent[0]; } CleanAStarLists(false); - + return true; } - + newg = n->g[0] + (short)AStarCost(n, n2); if ((n2->g[0] <= newg) && (n2->bIsOpen[0] || n2->bIsClosed[0])) @@ -2707,7 +2707,7 @@ bool CBot::AStar() pPath = pPath->next; continue; } - + n2->pParent[0] = n; n2->g[0] = newg; n2->bIsClosed[0] = false; @@ -2720,12 +2720,12 @@ bool CBot::AStar() } pPath = pPath->next; } - + m_AStarClosedList[0].PushNode(n); n->bIsClosed[0] = true; iCurrentCycles++; } - + if (!bPathFailed) { while(!m_AStarOpenList[1].Empty()) @@ -2738,27 +2738,27 @@ bool CBot::AStar() n = m_AStarOpenList[1].Pop(); n->bIsOpen[1] = false; - + if (n->pNode->FailedGoalList.IsInList(m_pCurrentWaypoint->pNode)) { bPathFailed = true; break; // Can't make path to goal } - + // Done with calculating if (n == m_pCurrentWaypoint) { m_bCalculatingAStarPath = false; BotManager.m_sUsingAStarBotsCount--; - + while(n) { - m_AStarNodeList.AddNode(n); + m_AStarNodeList.AddNode(n); n = n->pParent[1]; - } + } + + CleanAStarLists(false); - CleanAStarLists(false); - return true; } @@ -2771,37 +2771,37 @@ bool CBot::AStar() pPath = pPath->next; continue; } - + n2 = GetWPFromNode(pPath->Entry); - + if (!n2) { pPath = pPath->next; continue; } - + if (n2->bIsClosed[0]) { m_bCalculatingAStarPath = false; BotManager.m_sUsingAStarBotsCount--; - + while(n2) { m_AStarNodeList.PushNode(n2); n2 = n2->pParent[0]; } - + while(n) { - m_AStarNodeList.AddNode(n); + m_AStarNodeList.AddNode(n); n = n->pParent[1]; } - CleanAStarLists(false); - + CleanAStarLists(false); + return true; } - + newg = n->g[1] + (short)AStarCost(n, n2); if ((n2->g[1] <= newg) && (n2->bIsOpen[1] || n2->bIsClosed[1])) @@ -2809,7 +2809,7 @@ bool CBot::AStar() pPath = pPath->next; continue; } - + n2->pParent[1] = n; n2->g[1] = newg; n2->bIsClosed[1] = false; @@ -2822,16 +2822,16 @@ bool CBot::AStar() } pPath = pPath->next; } - + m_AStarClosedList[1].PushNode(n); n->bIsClosed[1] = true; iCurrentCycles++; } } - - // Failed making path + + // Failed making path condebug("Path failed"); - + CleanAStarLists(true); m_bCalculatingAStarPath = false; BotManager.m_sUsingAStarBotsCount--; @@ -2854,7 +2854,7 @@ void CBot::CleanAStarLists(bool bPathFailed) p->pParent[0] = p->pParent[1] = NULL; p->g[0] = p->g[1] = 0; } - + while(m_AStarOpenList[1].Empty() == false) { waypoint_s *p = m_AStarOpenList[1].Pop(); @@ -2863,7 +2863,7 @@ void CBot::CleanAStarLists(bool bPathFailed) p->pParent[0] = p->pParent[1] = NULL; p->g[0] = p->g[1] = 0; } - + while(m_AStarClosedList[0].Empty() == false) { waypoint_s *p = m_AStarClosedList[0].Pop(); @@ -2874,7 +2874,7 @@ void CBot::CleanAStarLists(bool bPathFailed) if (bPathFailed) p->pNode->FailedGoalList.AddNode(m_pCurrentGoalWaypoint->pNode); } - + while(m_AStarClosedList[1].Empty() == false) { waypoint_s *p = m_AStarClosedList[1].Pop(); @@ -2916,7 +2916,7 @@ void CBot::SetCurrentWaypoint(node_s *pNode) #ifndef RELEASE_BUILD if (!pWP || !pNode) condebug("NULL WP In SetCurrentWP"); #endif - + m_pCurrentWaypoint = pWP; m_iWaypointTime = lastmillis; } @@ -2926,7 +2926,7 @@ void CBot::SetCurrentWaypoint(waypoint_s *pWP) #ifndef RELEASE_BUILD if (!pWP) condebug("NULL WP In SetCurrentWP(2)"); #endif - + m_pCurrentWaypoint = pWP; m_iWaypointTime = lastmillis; } @@ -2937,7 +2937,7 @@ void CBot::SetCurrentGoalWaypoint(node_s *pNode) #ifndef RELEASE_BUILD if (!pWP || !pNode) condebug("NULL WP In SetCurrentGoalWP"); #endif - + m_pCurrentGoalWaypoint = pWP; } @@ -2946,7 +2946,7 @@ void CBot::SetCurrentGoalWaypoint(waypoint_s *pWP) #ifndef RELEASE_BUILD if (!pWP) condebug("NULL WP In SetCurrentGoalWP(2)"); #endif - + m_pCurrentGoalWaypoint = pWP; } @@ -2957,19 +2957,19 @@ bool CBot::CurrentWPIsValid() //condebug("Invalid WP: Is NULL"); return false; } - + // check if the bot has been trying to get to this waypoint for a while... if ((m_iWaypointTime + 5000) < lastmillis) - { + { condebug("Invalid WP: time over"); return false; } -#ifndef RELEASE_BUILD +#ifndef RELEASE_BUILD if (!IsVisible(m_pCurrentWaypoint->pNode->v_origin)) condebug("Invalid WP: Not visible"); #endif - + return (IsVisible(m_pCurrentWaypoint->pNode->v_origin)); } @@ -2988,19 +2988,19 @@ bool CBot::ReachedGoalWP() waypoint_s *CBot::GetWPFromNode(node_s *pNode) { if (!pNode) return NULL; - + short x, y; WaypointClass.GetNodeIndexes(pNode->v_origin, &x, &y); - + TLinkedList::node_s *p = m_WaypointList[x][y].GetFirst(); while(p) { if (p->Entry->pNode == pNode) return p->Entry; - + p = p->next; } - + return NULL; } @@ -3039,7 +3039,7 @@ waypoint_s *CBot::GetNearestWaypoint(vec v_src, float flRange) p = p->next; continue; } - + flDist = GetDistance(v_src, p->Entry->pNode->v_origin); if ((flDist < flNearestDist) && (flDist <= flRange)) { @@ -3092,7 +3092,7 @@ waypoint_s *CBot::GetNearestTriggerWaypoint(vec v_src, float flRange) p = p->next; continue; } - + flDist = GetDistance(v_src, p->Entry->pNode->v_origin); if ((flDist < flNearestDist) && (flDist <= flRange)) { @@ -3115,7 +3115,7 @@ void CBot::SyncWaypoints() { short x, y; TLinkedList::node_s *p; - + // Clean everything first for (x=0;xpNode = p->Entry; m_WaypointList[x][y].AddNode(pWP); - + #ifndef RELEASE_BUILD if (!GetWPFromNode(p->Entry)) condebug("Error adding bot wp!"); -#endif - +#endif + p = p->next; } } } } - + #ifdef WP_FLOOD waypoint_s *CBot::GetNearestFloodWP(vec v_origin, float flRange) { @@ -3184,7 +3184,7 @@ waypoint_s *CBot::GetNearestFloodWP(vec v_origin, float flRange) p = p->next; continue; } - + flDist = GetDistance(v_origin, p->Entry->pNode->v_origin); if ((flDist < flNearestDist) && (flDist <= flRange)) { @@ -3237,7 +3237,7 @@ waypoint_s *CBot::GetNearestTriggerFloodWP(vec v_origin, float flRange) p = p->next; continue; } - + flDist = GetDistance(v_origin, p->Entry->pNode->v_origin); if ((flDist < flNearestDist) && (flDist <= flRange)) { @@ -3258,17 +3258,17 @@ waypoint_s *CBot::GetNearestTriggerFloodWP(vec v_origin, float flRange) void CBot::GoToDebugGoal(vec o) { ResetWaypointVars(); - + node_s *wp = WaypointClass.GetNearestWaypoint(m_pMyEnt, 20.0f); node_s *goalwp = WaypointClass.GetNearestWaypoint(player1, 20.0f); - + if (!wp || !goalwp) { wp = WaypointClass.GetNearestFloodWP(m_pMyEnt, 8.0f); goalwp = WaypointClass.GetNearestFloodWP(player1, 5.0f); } if (!wp || !goalwp) { condebug("No near WP"); return; } - + SetCurrentWaypoint(wp); SetCurrentGoalWaypoint(goalwp); m_vGoal = o; diff --git a/source/src/bot/botmanager.cpp b/source/src/bot/botmanager.cpp index 70b0a1df..eb9bcd22 100644 --- a/source/src/bot/botmanager.cpp +++ b/source/src/bot/botmanager.cpp @@ -993,7 +993,7 @@ void addbot(char *arg1, char *arg2, char *arg3) if (b) conoutf("connected: %s", b->name); else { conoutf("Error: Couldn't create bot!"); return; } } -COMMAND(addbot, ARG_3STR); +COMMAND(addbot, "sss"); void addnbot(char *arg1, char *arg2, char *arg3) { @@ -1008,11 +1008,11 @@ void addnbot(char *arg1, char *arg2, char *arg3) i--; } } -COMMAND(addnbot, ARG_3STR); +COMMAND(addnbot, "sss"); -void botsshoot(int Shoot) +void botsshoot(int *Shoot) { - switch(Shoot) + switch(*Shoot) { case 0: BotManager.SetBotsShoot(false); @@ -1027,11 +1027,11 @@ void botsshoot(int Shoot) } } -COMMAND(botsshoot, ARG_1INT); +COMMAND(botsshoot, "i"); -void idlebots(int Idle) +void idlebots(int *Idle) { - switch(Idle) + switch(*Idle) { case 0: BotManager.SetIdleBots(false); @@ -1046,7 +1046,7 @@ void idlebots(int Idle) } } -COMMAND(idlebots, ARG_1INT); +COMMAND(idlebots, "i"); void drawbeamtobots() { @@ -1058,7 +1058,7 @@ void drawbeamtobots() } } -COMMAND(drawbeamtobots, ARG_NONE); +COMMAND(drawbeamtobots, ""); void kickbot(const char *szName) { @@ -1088,7 +1088,7 @@ void kickbot(const char *szName) } } -COMMAND(kickbot, ARG_1STR); +COMMAND(kickbot, "s"); void kickallbots(void) { @@ -1107,7 +1107,7 @@ void kickallbots(void) bots.setsize(0); } -COMMAND(kickallbots, ARG_NONE); +COMMAND(kickallbots, ""); void togglegrap() { @@ -1123,7 +1123,7 @@ void togglegrap() } } -COMMAND(togglegrap, ARG_NONE); +COMMAND(togglegrap, ""); void togglebotview(char *bot) { @@ -1150,7 +1150,7 @@ void togglebotview(char *bot) } } -COMMAND(togglebotview, ARG_1STR); +COMMAND(togglebotview, "s"); void botskill(char *bot, char *skill) { @@ -1190,14 +1190,14 @@ void botskill(char *bot, char *skill) BotManager.ChangeBotSkill(SkillNr); } -COMMAND(botskill, ARG_2STR); +COMMAND(botskill, "ss"); void botskillall(char *skill) { botskill(NULL, skill); } -COMMAND(botskillall, ARG_1STR); +COMMAND(botskillall, "s"); #ifndef RELEASE_BUILD @@ -1213,7 +1213,7 @@ void drawbeamtocarrots() } } -COMMAND(drawbeamtocarrots, ARG_NONE); +COMMAND(drawbeamtocarrots, ""); void drawbeamtoteleporters() { @@ -1226,7 +1226,7 @@ void drawbeamtoteleporters() } } -COMMAND(drawbeamtoteleporters, ARG_NONE); +COMMAND(drawbeamtoteleporters, ""); #endif void telebot(void) @@ -1254,7 +1254,7 @@ void telebot(void) } } -COMMAND(telebot, ARG_NONE); +COMMAND(telebot, ""); void testvisible(int iDir) { @@ -1326,22 +1326,13 @@ void testvisible(int iDir) condebug(sz); } -COMMAND(testvisible, ARG_1INT); +COMMANDF(testvisible, "i", (int *dir) { testvisible(*dir); }); -int mapsize(void) +void mapsize(void) { - switch(ssize) - { - case 128: return 7; break; - case 256: return 8; break; - case 512: return 9; break; - case 1024: return 10; break; - case 2048: return 11; break; - case 4096: return 12; break; - default: return 6; break; - } + intret(ffs(ssize)-1); } -COMMAND(mapsize, ARG_IVAL); +COMMAND(mapsize, ""); #endif diff --git a/source/src/client.cpp b/source/src/client.cpp index 2f950487..3f0ee811 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -61,10 +61,9 @@ void abortconnect() #endif } -void connectserv_(const char *servername, const char *serverport = NULL, const char *password = NULL, int role = CR_DEFAULT) +void connectserv_(const char *servername, int serverport = 0, const char *password = NULL, int role = CR_DEFAULT) { - const char *defaultport = "28763"; - if (!serverport) serverport = defaultport; + if(serverport <= 0) serverport = CUBE_DEFAULT_SERVER_PORT; if(watchingdemo) enddemoplayback(); if(!clfail && cllock && searchlan<2) return; @@ -76,15 +75,12 @@ void connectserv_(const char *servername, const char *serverport = NULL, const c connectrole = role; copystring(clientpassword, password ? password : ""); ENetAddress address; - - int p = 0; - if(serverport && serverport[0]) p = atoi(serverport); - address.port = p > 0 ? p : CUBE_DEFAULT_SERVER_PORT; + address.port = serverport; if(servername) { - addserver(servername, serverport, "0"); - conoutf(_("%c2attempting to %sconnect to %c5%s%c4%s%s%c2"), CC, role==CR_DEFAULT?"":"\f8admin\f2", CC, servername, CC, address.port != CUBE_DEFAULT_SERVER_PORT?":":"", serverport, CC); + addserver(servername, serverport, 0); + conoutf(_("%c2attempting to %sconnect to %c5%s%c4%s%d%c2"), CC, role==CR_DEFAULT?"":"\f8admin\f2", CC, servername, CC, address.port != CUBE_DEFAULT_SERVER_PORT?":":"", serverport, CC); if(!resolverwait(servername, &address)) { conoutf(_("%c2could %c3not resolve%c2 server %c5%s%c2"), CC, CC, CC, CC, servername, CC); @@ -118,17 +114,17 @@ void connectserv_(const char *servername, const char *serverport = NULL, const c } } -void connectserv(char *servername, char *serverport, char *password) +void connectserv(char *servername, int *serverport, char *password) { modprotocol = false; - connectserv_(servername, serverport, password); + connectserv_(servername, *serverport, password); } -void connectadmin(char *servername, char *serverport, char *password) +void connectadmin(char *servername, int *serverport, char *password) { modprotocol = false; if(!password[0]) return; - connectserv_(servername, serverport, password, CR_ADMIN); + connectserv_(servername, *serverport, password, CR_ADMIN); } void lanconnect() @@ -137,17 +133,17 @@ void lanconnect() connectserv_(NULL); } -void modconnectserv(char *servername, char *serverport, char *password) +void modconnectserv(char *servername, int *serverport, char *password) { modprotocol = true; - connectserv_(servername, serverport, password); + connectserv_(servername, *serverport, password); } -void modconnectadmin(char *servername, char *serverport, char *password) +void modconnectadmin(char *servername, int *serverport, char *password) { modprotocol = true; if(!password[0]) return; - connectserv_(servername, serverport, password, CR_ADMIN); + connectserv_(servername, *serverport, password, CR_ADMIN); } void modlanconnect() @@ -161,14 +157,12 @@ void whereami() conoutf("you are at (%.2f,%.2f)", player1->o.x, player1->o.y); } -void go_to(char *x, char *y) +void go_to(float *x, float *y) { if(player1->state != CS_EDITING) return; - float fx = 1.0f * atoi(x); - float fy = 1.0f * atoi(y); - player1->newpos.x = fx; - player1->newpos.y = fy; - conoutf("you are going to (%.2f; %.2f)", fx, fy); + player1->newpos.x = *x; + player1->newpos.y = *y; + conoutf("you are going to (%.2f; %.2f)", *x, *y); } void disconnect(int onlyclean, int async) @@ -329,28 +323,28 @@ void pm(char *text) addmsg(SV_TEXTPRIVATE, "ris", cn, text); conoutf("to %s:\f9 %s", colorname(to), highlight(text)); } -COMMAND(pm, ARG_CONC); +COMMAND(pm, "c"); -COMMAND(echo, ARG_CONC); -COMMAND(hudecho, ARG_CONC); -COMMANDN(say, toserver, ARG_CONC); -COMMANDN(me, toserverme, ARG_CONC); -COMMANDN(connect, connectserv, ARG_3STR); -COMMAND(connectadmin, ARG_3STR); -COMMAND(lanconnect, ARG_NONE); -COMMANDN(modconnect, modconnectserv, ARG_3STR); -COMMAND(modconnectadmin, ARG_3STR); -COMMAND(modlanconnect, ARG_NONE); -COMMANDN(disconnect, trydisconnect, ARG_NONE); -COMMAND(whereami, ARG_NONE); -COMMAND(go_to, ARG_2STR); +COMMAND(echo, "c"); +COMMAND(hudecho, "c"); +COMMANDN(say, toserver, "c"); +COMMANDN(me, toserverme, "c"); +COMMANDN(connect, connectserv, "sis"); +COMMAND(connectadmin, "sis"); +COMMAND(lanconnect, ""); +COMMANDN(modconnect, modconnectserv, "sis"); +COMMAND(modconnectadmin, "sis"); +COMMAND(modlanconnect, ""); +COMMANDN(disconnect, trydisconnect, ""); +COMMAND(whereami, ""); +COMMAND(go_to, "ff"); void current_version(char *text) { int version = atoi(text); if (version && AC_VERSIONignored = true; } @@ -122,15 +122,14 @@ void listignored() else conoutf(_("no players were ignored.")); } -void clearignored(char *ccn) +void clearignored(int *cn) { - int cn = ccn && *ccn ? atoi(ccn) : -1; - loopv(players) if(players[i] && (cn < 0 || cn == i)) players[i]->ignored = false; + loopv(players) if(players[i] && (*cn < 0 || *cn == i)) players[i]->ignored = false; } -void muteplayer(int cn) +void muteplayer(int *cn) { - playerent *d = getclient(cn); + playerent *d = getclient(*cn); if(d && d != player1) d->muted = true; } @@ -143,18 +142,17 @@ void listmuted() else conoutf(_("no players were muted.")); } -void clearmuted(char *ccn) +void clearmuted(char *cn) { - int cn = ccn && *ccn ? atoi(ccn) : -1; - loopv(players) if(players[i] && (cn < 0 || cn == i)) players[i]->muted = false; + loopv(players) if(players[i] && (*cn < 0 || *cn == i)) players[i]->muted = false; } -COMMAND(ignore, ARG_1INT); -COMMAND(listignored, ARG_NONE); -COMMAND(clearignored, ARG_1STR); -COMMAND(muteplayer, ARG_1INT); -COMMAND(listmuted, ARG_NONE); -COMMAND(clearmuted, ARG_1STR); +COMMAND(ignore, "i"); +COMMAND(listignored, ""); +COMMAND(clearignored, "i"); +COMMAND(muteplayer, "i"); +COMMAND(listmuted, ""); +COMMAND(clearmuted, "i"); void newname(const char *name) { @@ -209,40 +207,35 @@ void benchme() addmsg(SV_SWITCHTEAM, "ri", team_tospec(player1->team)); } -int _setskin(char *s, int t) +int _setskin(int s, int t) { - if(s && *s) - { - setskin(player1, atoi(s), t); - addmsg(SV_SWITCHSKIN, "rii", player1->skin(0), player1->skin(1)); - } + setskin(player1, s, t); + addmsg(SV_SWITCHSKIN, "rii", player1->skin(0), player1->skin(1)); return player1->skin(t); } -ICOMMANDF(skin_cla, ARG_1EST, (char *s) { return _setskin(s, TEAM_CLA); }); -ICOMMANDF(skin_rvsf, ARG_1EST, (char *s) { return _setskin(s, TEAM_RVSF); }); -ICOMMANDF(skin, ARG_1EST, (char *s) { return _setskin(s, player1->team); }); +COMMANDF(skin_cla, "i", (int *s) { intret(_setskin(*s, TEAM_CLA)); }); +COMMANDF(skin_rvsf, "i", (int *s) { intret(_setskin(*s, TEAM_RVSF)); }); +COMMANDF(skin, "i", (int *s) { intret(_setskin(*s, player1->team)); }); -int curmodeattr(char *attr) +void curmodeattr(char *attr) { - if(!strcmp(attr, "team")) return m_teammode; - else if(!strcmp(attr, "arena")) return m_arena; - else if(!strcmp(attr, "flag")) return m_flags; - else if(!strcmp(attr, "bot")) return m_botmode; - return 0; + if(!strcmp(attr, "team")) { intret(m_teammode); return; } + else if(!strcmp(attr, "arena")) { intret(m_arena); return; } + else if(!strcmp(attr, "flag")) { intret(m_flags); return; } + else if(!strcmp(attr, "bot")) { intret(m_botmode); return; } + intret(0); } -COMMANDN(team, newteam, ARG_1STR); -COMMANDN(name, newname, ARG_1STR); -COMMAND(benchme, ARG_NONE); -ICOMMANDF(isclient, ARG_1EXP, (int cn) { return getclient(cn) != NULL ? 1 : 0; } ); -//ICOMMANDF(isSpect, ARG_IVAL, (void) { return (player1->team==TEAM_SPECT || player1->spectatemode==SM_FLY); }); // Moved to /config/compatibility.cfg -//ICOMMANDF(currole, ARG_IVAL, (void) { return player1->clientrole; }); // Moved to /config/compatibility.cfg -ICOMMANDF(curmastermode, ARG_IVAL, (void) { return servstate.mastermode; }); -ICOMMANDF(curautoteam, ARG_IVAL, (void) { return servstate.autoteam; }); -COMMAND(curmodeattr, ARG_1EST); -COMMANDF(curmap, ARG_1INT, (int cleaned) { result(cleaned ? behindpath(getclientmap()) : getclientmap()); }); -ICOMMANDF(curplayers, ARG_IVAL, (void) { return players.length() + 1; }); +COMMANDN(team, newteam, "s"); +COMMANDN(name, newname, "s"); +COMMAND(benchme, ""); +COMMANDF(isclient, "i", (int *cn) { intret(getclient(*cn) != NULL ? 1 : 0); } ); +COMMANDF(curmastermode, "", (void) { intret(servstate.mastermode); }); +COMMANDF(curautoteam, "", (void) { intret(servstate.autoteam); }); +COMMAND(curmodeattr, ""); +COMMANDF(curmap, "i", (int *cleaned) { result(*cleaned ? behindpath(getclientmap()) : getclientmap()); }); +COMMANDF(curplayers, "", (void) { intret(players.length() + 1); }); VARP(showscoresondeath, 0, 1, 1); VARP(autoscreenshot, 0, 0, 1); @@ -251,18 +244,18 @@ void stopdemo() if(watchingdemo) enddemoplayback(); else conoutf(_("not playing a demo")); } -COMMAND(stopdemo, ARG_NONE); +COMMAND(stopdemo, ""); // macros for playerinfo() & teaminfo(). Use this to replace pstats_xxx ? #define ATTR_INT(name, attribute) if(!strcmp(attr, #name)) { intret(attribute); return; } #define ATTR_FLOAT(name, attribute) if(!strcmp(attr, #name)) { floatret(attribute); return; } #define ATTR_STR(name, attribute) if(!strcmp(attr, #name)) { result(attribute); return; } -void playerinfo(const char *cn, const char *attr) +void playerinfo(int *cn, const char *attr) { - if(!*cn || !cn || !*attr || !attr) return; + if(!*attr || !attr) return; - int clientnum = atoi(cn); // get player clientnum + int clientnum = *cn; // get player clientnum playerent *p = clientnum < 0 ? player1 : getclient(clientnum); if(!p) { @@ -320,16 +313,17 @@ void playerinfo(const char *cn, const char *attr) void playerinfolocal(const char *attr) { - playerinfo("-1", attr); + int cn = -1; + playerinfo(&cn, attr); } -COMMANDN(player, playerinfo, ARG_3STR); -COMMANDN(player1, playerinfolocal, ARG_2STR); +COMMANDN(player, playerinfo, "is"); +COMMANDN(player1, playerinfolocal, "s"); void teaminfo(const char *team, const char *attr) { if(!team || !attr || !m_teammode) return; - int t = atoi(team); // get player clientnum + int t = teamatoi(team); // get player clientnum if(!team_isactive(t)) { conoutf("invalid team: %s", team); @@ -379,7 +373,7 @@ void teaminfo(const char *team, const char *attr) conoutf("invalid attribute: %s", attr); } -COMMAND(teaminfo, ARG_2STR); +COMMAND(teaminfo, "ss"); void deathstate(playerent *pl) { @@ -593,9 +587,9 @@ void addsleep(int msec, const char *cmd, bool persist) s.persist = persist; } -void addsleep_(char *msec, char *cmd, char *persist) +void addsleep_(int *msec, char *cmd, int *persist) { - addsleep(atoi(msec), cmd, atoi(persist) != 0); + addsleep(*msec, cmd, *persist != 0); } void resetsleep(bool force) @@ -612,8 +606,8 @@ void resetsleep_() resetsleep(true); } -COMMANDN(sleep, addsleep_, ARG_3STR); -COMMANDN(resetsleeps, resetsleep_, ARG_NONE); +COMMANDN(sleep, addsleep_, "isi"); +COMMANDN(resetsleeps, resetsleep_, ""); void updateworld(int curtime, int lastmillis) // main game update loop { @@ -835,8 +829,8 @@ void setkillmessage(int gun, bool gib, const char *message) copystring(killmessages[gib?1:0][gun], message, sizeof(killmessages[gib?1:0][gun])); } -COMMANDF(fragmessage, ARG_2STR, (const char *gun, const char *message) { setkillmessage(atoi(gun), false, message); }); -COMMANDF(gibmessage, ARG_2STR, (const char *gun, const char *message) { setkillmessage(atoi(gun), true, message); }); +COMMANDF(fragmessage, "is", (int *gun, const char *message) { setkillmessage(*gun, false, message); }); +COMMANDF(gibmessage, "is", (int *gun, const char *message) { setkillmessage(*gun, true, message); }); void writekillmsgcfg() { @@ -853,12 +847,9 @@ void writekillmsgcfg() f->printf("\n"); } -void burstshots(char *gun_str, char *shots_str) +void burstshots(int gun, int shots) { // args are passed as strings to differentiate 2 cases : shots_str == "0" or shots_str is empty (not specified from cubescript). - int gun = gun_str ? atoi(gun_str) : -1; - int shots = shots_str && *shots_str != '\0' ? atoi(shots_str) : -1; - if(gun >= 0 && gun < NUMGUNS && guns[gun].isauto) { if(shots >= 0) burstshotssettings[gun] = min(shots, (guns[gun].magsize-1)); @@ -867,7 +858,7 @@ void burstshots(char *gun_str, char *shots_str) else conoutf(_("invalid gun specified")); } -COMMAND(burstshots, ARG_2STR); +COMMANDF(burstshots, "ii", (int *g, int *s) { burstshots(*g, *s); }); // damage arriving from the network, monsters, yourself, all ends up here. @@ -959,44 +950,16 @@ void dokill(playerent *pl, playerent *act, bool gib, int gun) pl->deaths++; audiomgr.playsound(S_DIE1+rnd(2), pl); } -/* Removed in favor of the new (player) && (player1) commands ??? - See /config/compatibility.cfg -void pstat_score(int cn) -{ - //if(intermission) - //{ - string scorestring; - int p_flags = 0; - int p_frags = 0; - int p_deaths = 0; - int p_points = 0; - int p_tks = 0; - playerent *pl = cn==player1->clientnum?player1:getclient(cn); - if(pl) - { - p_flags = pl->flagscore; - p_frags = pl->frags; - p_deaths = pl->deaths; - p_points = pl->points; - p_tks = pl->tks; - } - formatstring(scorestring)("%d %d %d %d %d %d %s", p_flags, p_frags, p_deaths, p_points, pl ? pl->team : -1, p_tks, pl ? pl->name : "\"\""); - result(scorestring); - //} - //else result("0 0 0 0 -1 \"\""); -} -COMMAND(pstat_score, ARG_1INT); -*/ -void pstat_weap(int cn) +void pstat_weap(int *cn) { string weapstring = ""; - playerent *pl = getclient(cn); + playerent *pl = getclient(*cn); if(pl) loopi(NUMGUNS) concatformatstring(weapstring, "%s%d %d", strlen(weapstring) ? " " : "", pl->pstatshots[i], pl->pstatdamage[i]); result(weapstring); } -COMMAND(pstat_weap, ARG_1INT); +COMMAND(pstat_weap, "i"); VAR(minutesremaining, 1, 0, 0); VAR(gametimecurrent, 1, 0, 0); @@ -1119,15 +1082,15 @@ void preparectf(bool cleanonly=false) struct gmdesc { int mode; char *desc; }; vector gmdescs; -void gamemodedesc(char *modenr, char *desc) +void gamemodedesc(int *modenr, char *desc) { - if(!modenr || !desc) return; + if(!desc) return; struct gmdesc &gd = gmdescs.add(); - gd.mode = atoi(modenr); + gd.mode = *modenr; gd.desc = newstring(desc); } -COMMAND(gamemodedesc, ARG_2STR); +COMMAND(gamemodedesc, "is"); void resetmap(bool mrproper) { @@ -1166,7 +1129,7 @@ void showmapstats() if (m_flags && F2F < 1000) conoutf(" Flag-to-flag distance is: %d", (int)fSqrt(F2F)); if (item_fail) conoutf(" There are one or more items too close to each other in this map"); } -COMMAND(showmapstats, ARG_NONE); +COMMAND(showmapstats, ""); VARP(showmodedescriptions, 0, 1, 1); @@ -1244,7 +1207,7 @@ void suicide() } } -COMMAND(suicide, ARG_NONE); +COMMAND(suicide, ""); // console and audio feedback @@ -1337,7 +1300,7 @@ void flagmsg(int flag, int message, int actor, int flagtime) } void dropflag() { tryflagdrop(true); } -COMMAND(dropflag, ARG_NONE); +COMMAND(dropflag, ""); char *votestring(int type, const char *arg1, const char *arg2, const char *arg3) { @@ -1464,11 +1427,11 @@ void callvote(int type, const char *arg1, const char *arg2, const char *arg3) else conoutf(_("%c3invalid vote"), CC); } -void scallvote(char *type, const char *arg1, const char *arg2) +void scallvote(int *type, const char *arg1, const char *arg2) { if(type && inmainloop) { - int t = atoi(type); + int t = *type; switch (t) { case SA_MAP: // FIXME @@ -1488,6 +1451,12 @@ void scallvote(char *type, const char *arg1, const char *arg2) break; } } + case SA_FORCETEAM: + { + int team = atoi(arg2); + if(team < 0) arg2 = (team == 0) ? "RVSF" : "CLA"; + // fall through + } default: callvote(t, arg1, arg2); } @@ -1558,44 +1527,40 @@ const char *modestrings[] = "osok", "tosok", "bosok", "htf", "tktf", "ktf", "tpf", "tlss", "bpf", "blss", "btsurv", "btosok" }; -void setnext(char *arg1, char *arg2) +void setnext(int *mode, char *arg2) { - for (int i = 0; i < GMODE_NUM; i++) + if(*mode < 0 || *mode >= GMODE_NUM) return; + + switch(*mode) { - switch(i) - { - case GMODE_COOPEDIT: - case GMODE_BOTTEAMDEATHMATCH: - case GMODE_BOTDEATHMATCH: - case GMODE_BOTONESHOTONEKILL: - continue; - } - if ( !strcmp(arg1,modestrings[i]) ) - { - nextmode=i+GMODE_NUM; - callvote(SA_MAP, arg2, "-1"); + case GMODE_COOPEDIT: + case GMODE_BOTTEAMDEATHMATCH: + case GMODE_BOTDEATHMATCH: + case GMODE_BOTONESHOTONEKILL: return; - } } + nextmode = *mode+GMODE_NUM; + callvote(SA_MAP, arg2, "-1"); + return; } -COMMAND(setnext, ARG_2STR); +COMMAND(setnext, "is"); -void gonext(char *arg1) +void gonext(int *arg1) { if(calledvote || !multiplayer(false)) return; packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); putint(p, SV_CALLVOTE); putint(p, SA_MAP); sendstring("+1", p); - putint(p, atoi(arg1)); + putint(p, *arg1); putint(p, -1); sendpackettoserv(1, p.finalize()); } -COMMAND(gonext, ARG_1STR); +COMMAND(gonext, "i"); -COMMANDN(callvote, scallvote, ARG_3STR); //fixme,ah -COMMAND(vote, ARG_1EXP); +COMMANDN(callvote, scallvote, "iss"); //fixme,ah +COMMANDF(vote, "i", (int *v) { vote(*v); }); void cleanplayervotes(playerent *p) { @@ -1603,9 +1568,9 @@ void cleanplayervotes(playerent *p) if(curvote && curvote->owner==p) curvote->owner = NULL; } -void whois(int cn) +void whois(int *cn) { - playerent *p = getclient(cn); + playerent *p = getclient(*cn); if(!p) { conoutf(_("invalid player name")); @@ -1616,10 +1581,10 @@ void whois(int cn) if(m_teammode) conoutf(_("%c0INFO: %c5%s has %d teamkills."), CC, CC, p->name, p->tks); if(ip[3] != 0 || player1->clientrole==CR_ADMIN) - conoutf("WHOIS client %d:\n\f5name\t%s\n\f5IP\t%d.%d.%d.%d", cn, colorname(p), ip[0], ip[1], ip[2], ip[3]); // full IP - else conoutf("WHOIS client %d:\n\f5name\t%s\n\f5IP\t%d.%d.%d.x", cn, colorname(p), ip[0], ip[1], ip[2]); // censored IP + conoutf("WHOIS client %d:\n\f5name\t%s\n\f5IP\t%d.%d.%d.%d", *cn, colorname(p), ip[0], ip[1], ip[2], ip[3]); // full IP + else conoutf("WHOIS client %d:\n\f5name\t%s\n\f5IP\t%d.%d.%d.x", *cn, colorname(p), ip[0], ip[1], ip[2]); // censored IP } -COMMAND(whois, ARG_1INT); +COMMAND(whois, "i"); void findcn(char *name) { @@ -1631,27 +1596,22 @@ void findcn(char *name) if(!strcmp(name, player1->name)) { intret(player1->clientnum); return; } intret(-1); } -COMMAND(findcn, ARG_1STR); +COMMAND(findcn, "s"); int sessionid = 0; -void setadmin(char *claim, char *password) +void setadmin(int *claim, char *password) { - if(!claim && !password) return; - else + if(!*claim && (player1->clientrole)) { - int y = atoi(claim); - if(!y && (player1->clientrole)) - { - conoutf(_("you released admin status")); - addmsg(SV_SETADMIN, "ri", 0); - } - else if(y != 0) - addmsg(SV_SETADMIN, "ris", y, genpwdhash(player1->name, password, sessionid)); + conoutf(_("you released admin status")); + addmsg(SV_SETADMIN, "ri", 0); } + else if(*claim != 0 && password) + addmsg(SV_SETADMIN, "ris", *claim, genpwdhash(player1->name, password, sessionid)); } -COMMAND(setadmin, ARG_2STR); +COMMAND(setadmin, "is"); struct mline { string name, cmd; }; static vector mlines; @@ -1784,14 +1744,11 @@ void changefollowplayer(int shift) updatefollowplayer(shift); } -COMMAND(spectate, ARG_NONE); -COMMAND(spectatemode, ARG_1INT); -COMMAND(togglespect, ARG_NONE); -COMMAND(changefollowplayer, ARG_1INT); -COMMAND(setfollowplayer, ARG_1INT); - -//int isalive() { return player1->state==CS_ALIVE ? 1 : 0; } -//COMMANDN(alive, isalive, ARG_IVAL); // Moved to /config/compatibility.cfg +COMMAND(spectate, ""); +COMMANDF(spectatemode, "i", (int *mode) { spectatemode(*mode); }); +COMMAND(togglespect, ""); +COMMANDF(changefollowplayer, "i", (int *dir) { changefollowplayer(*dir); }); +COMMANDF(setfollowplayer, "i", (int *cn) { setfollowplayer(*cn); }); void serverextension(char *ext, char *args) { @@ -1801,4 +1758,4 @@ void serverextension(char *ext, char *args) else addmsg(SV_EXTENSION, "rsi", ext, n); } -COMMAND(serverextension, ARG_2STR); +COMMAND(serverextension, "ss"); diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index a02bba18..9ff97bcd 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -1375,7 +1375,7 @@ void setDemoFilenameFormat(char *fmt) copystring(demofilenameformat, fmt); } else copystring(demofilenameformat, DEFDEMOFILEFMT); // reset to default if passed empty string - or should we output the current value in this case? } -COMMANDN(demonameformat, setDemoFilenameFormat, ARG_1STR); +COMMANDN(demonameformat, setDemoFilenameFormat, "s"); void setDemoTimestampFormat(char *fmt) { extern string demotimestampformat; @@ -1384,16 +1384,16 @@ void setDemoTimestampFormat(char *fmt) copystring(demotimestampformat, fmt); } else copystring(demotimestampformat, DEFDEMOTIMEFMT); // reset to default if passed empty string - or should we output the current value in this case? } -COMMANDN(demotimeformat, setDemoTimestampFormat, ARG_1STR); -void setDemoTimeLocal(int truth) +COMMANDN(demotimeformat, setDemoTimestampFormat, "s"); +void setDemoTimeLocal(int *truth) { extern int demotimelocal; - demotimelocal = truth == 0 ? 0 : 1; + demotimelocal = *truth == 0 ? 0 : 1; } -COMMANDN(demotimelocal, setDemoTimeLocal, ARG_1INT); -void getdemonameformat() { extern string demofilenameformat; result(demofilenameformat); } COMMAND(getdemonameformat, ARG_NONE); -void getdemotimeformat() { extern string demotimestampformat; result(demotimestampformat); } COMMAND(getdemotimeformat, ARG_NONE); -int getdemotimelocal() { extern int demotimelocal; return demotimelocal; } COMMAND(getdemotimelocal, ARG_1EXP); +COMMANDN(demotimelocal, setDemoTimeLocal, "i"); +void getdemonameformat() { extern string demofilenameformat; result(demofilenameformat); } COMMAND(getdemonameformat, ""); +void getdemotimeformat() { extern string demotimestampformat; result(demotimestampformat); } COMMAND(getdemotimeformat, ""); +void getdemotimelocal() { extern int demotimelocal; intret(demotimelocal); } COMMAND(getdemotimelocal, ""); const char *parseDemoFilename(char *srvfinfo) diff --git a/source/src/command.cpp b/source/src/command.cpp index 31e002da..d1ba629c 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -18,8 +18,8 @@ int loop_level = 0; // avoid bad calls of b hashtable *idents = NULL; // contains ALL vars/commands/aliases bool persistidents = true, neverpersist = false; -COMMANDF(persistidents, ARG_1INT, (int on) { - persistidents = neverpersist ? false : on; +COMMANDF(persistidents, "i", (int *on) { + persistidents = neverpersist ? false : *on; }); void clearstack(ident &id) @@ -99,8 +99,8 @@ void pop(const char *name) popident(*id); } -COMMAND(push, ARG_2STR); -COMMAND(pop, ARG_1STR); +COMMAND(push, "ss"); +COMMAND(pop, "s"); void delalias(const char *name) { ident *id = idents->access(name); @@ -113,7 +113,7 @@ void delalias(const char *name) } idents->remove(name); } -COMMAND(delalias, ARG_1STR); +COMMAND(delalias, "s"); void alias(const char *name, const char *action) { @@ -187,11 +187,11 @@ void constant(const char *name, const char *action) } } -COMMAND(alias, ARG_2STR); -COMMANDN(const, constant, ARG_2STR); +COMMAND(alias, "ss"); +COMMANDN(const, constant, "ss"); -COMMANDF(checkalias, ARG_1STR, (const char *name) { intret(getalias(name) ? 1 : 0); }); -COMMANDF(isconst, ARG_1STR, (const char *name) { ident *id = idents->access(name); intret(id && id->isconst ? 1 : 0); }); +COMMANDF(checkalias, "s", (const char *name) { intret(getalias(name) ? 1 : 0); }); +COMMANDF(isconst, "s", (const char *name) { ident *id = idents->access(name); intret(id && id->isconst ? 1 : 0); }); // variable's and commands are registered through globals, see cube.h @@ -242,7 +242,7 @@ void setsvar(const char *name, const char *str, bool dofunc) if(dofunc && id->fun) ((void (__cdecl *)())id->fun)(); // call trigger function if available } -void modifyvar(const char *name, const char *arg, char op) +void modifyvar(const char *name, int arg, char op) { ident *id = idents->access(name); if(!id) return; @@ -260,13 +260,12 @@ void modifyvar(const char *name, const char *arg, char op) case ID_SVAR: val = ATOI(*id->storage.s); break; case ID_ALIAS: val = ATOI(id->action); break; } - int argval = ATOI(arg); switch(op) { - case '+': val += argval; break; - case '-': val -= argval; break; - case '*': val *= argval; break; - case '/': val = argval ? val/argval : 0; break; + case '+': val += arg; break; + case '-': val -= arg; break; + case '*': val *= arg; break; + case '/': val = arg ? val/arg : 0; break; } switch(id->type) { @@ -279,7 +278,7 @@ void modifyvar(const char *name, const char *arg, char op) if(id->fun) ((void (__cdecl *)())id->fun)(); } -void modifyfvar(const char *name, const char *arg, char op) +void modifyfvar(const char *name, float arg, char op) { ident *id = idents->access(name); if(!id) return; @@ -297,13 +296,12 @@ void modifyfvar(const char *name, const char *arg, char op) case ID_SVAR: val = atof(*id->storage.s); break; case ID_ALIAS: val = atof(id->action); break; } - float argval = atof(arg); switch(op) { - case '+': val += argval; break; - case '-': val -= argval; break; - case '*': val *= argval; break; - case '/': val = (argval == 0.0f) ? 0 : val/argval; break; + case '+': val += arg; break; + case '-': val -= arg; break; + case '*': val *= arg; break; + case '/': val = (arg == 0.0f) ? 0 : val/arg; break; } switch(id->type) { @@ -316,23 +314,23 @@ void modifyfvar(const char *name, const char *arg, char op) if(id->fun) ((void (__cdecl *)())id->fun)(); } -void addeq(char *name, char *arg) { modifyvar(name, arg, '+'); } -void subeq(char *name, char *arg) { modifyvar(name, arg, '-'); } -void muleq(char *name, char *arg) { modifyvar(name, arg, '*'); } -void diveq(char *name, char *arg) { modifyvar(name, arg, '/'); } -void addeqf(char *name, char *arg) { modifyfvar(name, arg, '+'); } -void subeqf(char *name, char *arg) { modifyfvar(name, arg, '-'); } -void muleqf(char *name, char *arg) { modifyfvar(name, arg, '*'); } -void diveqf(char *name, char *arg) { modifyfvar(name, arg, '/'); } +void addeq(char *name, int *arg) { modifyvar(name, *arg, '+'); } +void subeq(char *name, int *arg) { modifyvar(name, *arg, '-'); } +void muleq(char *name, int *arg) { modifyvar(name, *arg, '*'); } +void diveq(char *name, int *arg) { modifyvar(name, *arg, '/'); } +void addeqf(char *name, float *arg) { modifyfvar(name, *arg, '+'); } +void subeqf(char *name, float *arg) { modifyfvar(name, *arg, '-'); } +void muleqf(char *name, float *arg) { modifyfvar(name, *arg, '*'); } +void diveqf(char *name, float *arg) { modifyfvar(name, *arg, '/'); } -COMMANDN(+=, addeq, ARG_2STR); -COMMANDN(-=, subeq, ARG_2STR); -COMMANDN(*=, muleq, ARG_2STR); -COMMANDN(div=, diveq, ARG_2STR); -COMMANDN(+=f, addeqf, ARG_2STR); -COMMANDN(-=f, subeqf, ARG_2STR); -COMMANDN(*=f, muleqf, ARG_2STR); -COMMANDN(div=f, diveqf, ARG_2STR); +COMMANDN(+=, addeq, "si"); +COMMANDN(-=, subeq, "si"); +COMMANDN(*=, muleq, "si"); +COMMANDN(div=, diveq, "si"); +COMMANDN(+=f, addeqf, "sf"); +COMMANDN(-=f, subeqf, "sf"); +COMMANDN(*=f, muleqf, "sf"); +COMMANDN(div=f, diveqf, "sf"); int getvar(const char *name) { @@ -375,39 +373,14 @@ void _getalias(char *name) } } } -COMMANDN(getalias, _getalias, ARG_1STR); +COMMANDN(getalias, _getalias, "s"); -// (getalias) now handles client variables as well -/*void _getvar(char *name) -{ - string resstr; - resstr[0] = '\0'; - ident *id = idents->access(name); - if(id) - { - switch(id->type) - { - case ID_VAR: - formatstring(resstr)("%d", *id->storage.i); - break; - case ID_FVAR: - formatstring(resstr)("%.3f", *id->storage.f); - break; - case ID_SVAR: - formatstring(resstr)("%s", *id->storage.s); - break; - default: break; - } - } - result(resstr); -} -COMMANDN(getvar, _getvar, ARG_1STR);*/ -COMMANDN(isIdent, identexists, ARG_1EST); +COMMANDF(isIdent, "s", (char *name) { intret(identexists(name) ? 1 : 0); }); -bool addcommand(const char *name, void (*fun)(), int narg) +bool addcommand(const char *name, void (*fun)(), const char *sig) { if(!idents) idents = new hashtable; - ident c(ID_COMMAND, name, fun, narg, IEXC_CORE); + ident c(ID_COMMAND, name, fun, sig, IEXC_CORE); idents->access(name, c); return false; } @@ -634,46 +607,42 @@ char *executeret(const char *p) // all evaluation hap switch(id->type) { case ID_COMMAND: // game defined commands - switch(id->narg) // use very ad-hoc function signature, and just call it + { + + if(strstr(id->sig, "v")) ((void (__cdecl *)(char **, int))id->fun)(&w[1], numargs-1); + else if(strstr(id->sig, "c") || strstr(id->sig, "w")) { - case ARG_1INT: ((void (__cdecl *)(int))id->fun)(ATOI(w[1])); break; - case ARG_2INT: ((void (__cdecl *)(int, int))id->fun)(ATOI(w[1]), ATOI(w[2])); break; - case ARG_3INT: ((void (__cdecl *)(int, int, int))id->fun)(ATOI(w[1]), ATOI(w[2]), ATOI(w[3])); break; - case ARG_4INT: ((void (__cdecl *)(int, int, int, int))id->fun)(ATOI(w[1]), ATOI(w[2]), ATOI(w[3]), ATOI(w[4])); break; - case ARG_NONE: ((void (__cdecl *)())id->fun)(); break; - case ARG_1STR: ((void (__cdecl *)(char *))id->fun)(w[1]); break; - case ARG_2STR: ((void (__cdecl *)(char *, char *))id->fun)(w[1], w[2]); break; - case ARG_3STR: ((void (__cdecl *)(char *, char *, char*))id->fun)(w[1], w[2], w[3]); break; - case ARG_4STR: ((void (__cdecl *)(char *, char *, char*, char*))id->fun)(w[1], w[2], w[3], w[4]); break; - case ARG_5STR: ((void (__cdecl *)(char *, char *, char*, char*, char*))id->fun)(w[1], w[2], w[3], w[4], w[5]); break; - case ARG_6STR: ((void (__cdecl *)(char *, char *, char*, char*, char*, char*))id->fun)(w[1], w[2], w[3], w[4], w[5], w[6]); break; - case ARG_7STR: ((void (__cdecl *)(char *, char *, char*, char*, char*, char*, char*))id->fun)(w[1], w[2], w[3], w[4], w[5], w[6], w[7]); break; - case ARG_8STR: ((void (__cdecl *)(char *, char *, char*, char*, char*, char*, char*, char*))id->fun)(w[1], w[2], w[3], w[4], w[5], w[6], w[7], w[8]); break; -#ifndef STANDALONE - case ARG_DOWN: ((void (__cdecl *)(bool))id->fun)(addreleaseaction(id->name)!=NULL); break; -#endif - case ARG_1EXP: intret(((int (__cdecl *)(int))id->fun)(ATOI(w[1]))); break; - case ARG_2EXP: intret(((int (__cdecl *)(int, int))id->fun)(ATOI(w[1]), ATOI(w[2]))); break; - case ARG_1EXPF: floatret(((float (__cdecl *)(float))id->fun)(atof(w[1]))); break; - case ARG_2EXPF: floatret(((float (__cdecl *)(float, float))id->fun)(atof(w[1]), atof(w[2]))); break; - case ARG_1EST: intret(((int (__cdecl *)(char *))id->fun)(w[1])); break; - case ARG_2EST: intret(((int (__cdecl *)(char *, char *))id->fun)(w[1], w[2])); break; - case ARG_IVAL: intret(((int (__cdecl *)())id->fun)()); break; - case ARG_FVAL: floatret(((float (__cdecl *)())id->fun)()); break; - case ARG_SVAL: result(((const char * (__cdecl *)())id->fun)()); break; - case ARG_VARI: ((void (__cdecl *)(char **, int))id->fun)(&w[1], numargs-1); break; - case ARG_CONC: - case ARG_CONCW: - { - char *r = conc(w+1, numargs-1, id->narg==ARG_CONC); - ((void (__cdecl *)(char *))id->fun)(r); - delete[] r; - break; - } + char *r = conc(w+1, numargs-1, strstr(id->sig, "c")); + ((void (__cdecl *)(char *))id->fun)(r); + delete[] r; } + else if(strstr(id->sig, "d")) ((void (__cdecl *)(bool))id->fun)(addreleaseaction(id->name)!=NULL); + else + { + int ib1, ib2, ib3, ib4, ib5, ib6, ib7, ib8; + float fb1, fb2, fb3, fb4, fb5, fb6, fb7, fb8; + #define ARG(i) (id->sig[i-1] == 'i' ? ((void *)&(ib##i=strtol(w[i], NULL, 0))) : (id->sig[i-1] == 'f' ? ((void *)&(fb##i=atof(w[i]))) : (void *)w[i])) + + switch(strlen(id->sig)) // use very ad-hoc function signature, and just call it + { + case 0: ((void (__cdecl *)())id->fun)(); break; + case 1: ((void (__cdecl *)(void*))id->fun)(ARG(1)); break; + case 2: ((void (__cdecl *)(void*, void*))id->fun)(ARG(1), ARG(2)); break; + case 3: ((void (__cdecl *)(void*, void*, void*))id->fun)(ARG(1), ARG(2), ARG(3)); break; + case 4: ((void (__cdecl *)(void*, void*, void*, void*))id->fun)(ARG(1), ARG(2), ARG(3), ARG(4)); break; + case 5: ((void (__cdecl *)(void*, void*, void*, void*, void*))id->fun)(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5)); break; + case 6: ((void (__cdecl *)(void*, void*, void*, void*, void*, void*))id->fun)(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5), ARG(6)); break; + case 7: ((void (__cdecl *)(void*, void*, void*, void*, void*, void*, void*))id->fun)(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7)); break; + case 8: ((void (__cdecl *)(void*, void*, void*, void*, void*, void*, void*, void*))id->fun)(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8)); break; + default: fatal("command %s has too many arguments (signature: %s)", id->name, id->sig); break; + } + #undef ARG + } + setretval(commandret); commandret = NULL; break; + } case ID_VAR: // game defined variables if(!w[1][0]) conoutf("%s = %d", c, *id->storage.i); // var with no value just prints its current value @@ -883,9 +852,9 @@ void addnickcomplete(char *command) addcomplete(command, COMPLETE_NICK, NULL, NULL); } -COMMANDN(complete, addfilecomplete, ARG_3STR); -COMMANDN(listcomplete, addlistcomplete, ARG_2STR); -COMMANDN(nickcomplete, addnickcomplete, ARG_1STR); +COMMANDN(complete, addfilecomplete, "sss"); +COMMANDN(listcomplete, addlistcomplete, "ss"); +COMMANDN(nickcomplete, addnickcomplete, "s"); void commandcomplete(char *s) { @@ -1020,14 +989,15 @@ void execdir(const char *dir) } } } -COMMAND(execdir,ARG_1STR); +COMMAND(execdir, "s"); + // below the commands that implement a small imperative language. thanks to the semantics of // () and [] expressions, any control construct can be defined trivially. void ifthen(char *cond, char *thenp, char *elsep) { commandret = executeret(cond[0]!='0' ? thenp : elsep); } -void loopa(char *var, char *times, char *body) +void loopa(char *var, int *times, char *body) { - int t = ATOI(times); + int t = *times; if(t<=0) return; ident *id = newident(var, execcontext); if(id->type!=ID_ALIAS) return; @@ -1184,9 +1154,9 @@ int listlen(char *s) return n; } -void at(char *s, char *pos) +void at(char *s, int *pos) { - commandret = indexlist(s, ATOI(pos)); + commandret = indexlist(s, *pos); } int find(const char *s, const char *key) @@ -1215,37 +1185,33 @@ void findlist(char *s, char *key) } void colora(char *s) { - if(s[0] && s[1]=='\0') { - defformatstring(x)("\f%c",s[0]); - commandret = newstring(x); + if(s[0] && s[1]=='\0') + { + defformatstring(x)("\f%c",s[0]); + commandret = newstring(x); } } // Easily inject a string into various CubeScript punctuations -void addpunct(char *s, char *type = "0") +void addpunct(char *s, int *type) { - int t = atoi(type); - if(t > -1 && t < 6) + switch(*type) { - switch(t) - { - case 1: defformatstring(o1)("[%s]", s); result(o1); break; - case 2: defformatstring(o2)("(%s)", s); result(o2); break; - case 3: defformatstring(o3)("$%s", s); result(o3); break; - case 4: result("\""); break; - case 5: result("%"); break; - default: defformatstring(o4)("\"%s\"", s); result(o4); break; - } + case 1: defformatstring(o1)("[%s]", s); result(o1); break; + case 2: defformatstring(o2)("(%s)", s); result(o2); break; + case 3: defformatstring(o3)("$%s", s); result(o3); break; + case 4: result("\""); break; + case 5: result("%"); break; + default: defformatstring(o4)("\"%s\"", s); result(o4); break; } } void toLower(char *s) { result(strcaps(s, false)); } void toUpper(char *s) { result(strcaps(s, true)); } -void testchar(char *s, char *type) +void testchar(char *s, int *type) { - int t = atoi(type); - switch(t) { + switch(*type) { case 1: if(isalpha(s[0]) != 0) { intret(1); return; } break; @@ -1302,54 +1268,54 @@ void strreplace (const char *source, const char *search, const char *replace) } } -COMMANDN(c, colora, ARG_1STR); -COMMANDN(loop, loopa, ARG_3STR); -COMMAND(looplist, ARG_3STR); -COMMANDN(while, whilea, ARG_2STR); -COMMANDN(break, breaka, ARG_NONE); -COMMANDN(continue, continuea, ARG_NONE); -COMMANDN(if, ifthen, ARG_3STR); -COMMAND(exec, ARG_1STR); -COMMAND(concat, ARG_CONC); -COMMAND(concatword, ARG_CONCW); -COMMAND(format, ARG_VARI); -COMMAND(result, ARG_1STR); -COMMAND(execute, ARG_1STR); -COMMAND(at, ARG_2STR); -COMMAND(listlen, ARG_1EST); -COMMAND(findlist, ARG_2STR); -COMMAND(addpunct, ARG_2STR); -COMMANDN(tolower, toLower, ARG_1STR); -COMMANDN(toupper, toUpper, ARG_1STR); -COMMAND(testchar, ARG_2STR); -COMMAND(strreplace, ARG_3STR); +COMMANDN(c, colora, "s"); +COMMANDN(loop, loopa, "sis"); +COMMAND(looplist, "sss"); +COMMANDN(while, whilea, "ss"); +COMMANDN(break, breaka, ""); +COMMANDN(continue, continuea, ""); +COMMANDN(if, ifthen, "sss"); +COMMAND(exec, "s"); +COMMAND(concat, "c"); +COMMAND(concatword, "w"); +COMMAND(format, "v"); +COMMAND(result, "s"); +COMMAND(execute, "s"); +COMMAND(at, "si"); +COMMANDF(listlen, "s", (char *l) { intret(listlen(l)); }); +COMMAND(findlist, "ss"); +COMMAND(addpunct, "si"); +COMMANDN(tolower, toLower, "s"); +COMMANDN(toupper, toUpper, "s"); +COMMAND(testchar, "si"); +COMMAND(strreplace, "sss"); -int add(int a, int b) { return a+b; } COMMANDN(+, add, ARG_2EXP); -int mul(int a, int b) { return a*b; } COMMANDN(*, mul, ARG_2EXP); -int sub(int a, int b) { return a-b; } COMMANDN(-, sub, ARG_2EXP); -int div_(int a, int b) { return b ? a/b : 0; } COMMANDN(div, div_, ARG_2EXP); -int mod_(int a, int b) { return b ? a%b : 0; } COMMANDN(mod, mod_, ARG_2EXP); -float addf(float a, float b) { return a+b; } COMMANDN(+f, addf, ARG_2EXPF); -float mulf(float a, float b) { return a*b; } COMMANDN(*f, mulf, ARG_2EXPF); -float subf(float a, float b) { return a-b; } COMMANDN(-f, subf, ARG_2EXPF); -float divf_(float a, float b) { return b ? a/b : 0; } COMMANDN(divf, divf_, ARG_2EXPF); -float modf_(float a, float b) { return b ? fmod(a, b) : 0; } COMMANDN(modf, modf_, ARG_2EXPF); -float powf_(float a, float b) { return powf(a, b); } COMMANDN(powf, powf_, ARG_2EXPF); -int not_(int a) { return (int)(!a); } COMMANDN(!, not_, ARG_1EXP); -int equal(int a, int b) { return (int)(a==b); } COMMANDN(=, equal, ARG_2EXP); -int notequal(int a, int b) { return (int)(a!=b); } COMMANDN(!=, notequal, ARG_2EXP); -int lt(int a, int b) { return (int)(ab); } COMMANDN(>, gt, ARG_2EXP); -int lte(int a, int b) { return (int)(a<=b); } COMMANDN(<=, lte, ARG_2EXP); -int gte(int a, int b) { return (int)(a>=b); } COMMANDN(>=, gte, ARG_2EXP); +void add(int *a, int *b) { intret(*a + *b); } COMMANDN(+, add, "ii"); +void mul(int *a, int *b) { intret(*a * *b); } COMMANDN(*, mul, "ii"); +void sub(int *a, int *b) { intret(*a - *b); } COMMANDN(-, sub, "ii"); +void div_(int *a, int *b) { intret(*b ? (*a)/(*b) : 0); } COMMANDN(div, div_, "ii"); +void mod_(int *a, int *b) { intret(*b ? (*a)%(*b) : 0); } COMMANDN(mod, mod_, "ii"); +void addf(float *a, float *b) { floatret(*a + *b); } COMMANDN(+f, addf, "ff"); +void mulf(float *a, float *b) { floatret(*a * *b); } COMMANDN(*f, mulf, "ff"); +void subf(float *a, float *b) { floatret(*a - *b); } COMMANDN(-f, subf, "ff"); +void divf_(float *a, float *b) { floatret(*b ? (*a)/(*b) : 0); } COMMANDN(divf, divf_, "ff"); +void modf_(float *a, float *b) { floatret(*b ? fmod(*a, *b) : 0); } COMMANDN(modf, modf_, "ff"); +void powf_(float *a, float *b) { floatret(powf(*a, *b)); } COMMANDN(powf, powf_, "ff"); +void not_(int *a) { intret((int)(!(*a))); } COMMANDN(!, not_, "i"); +void equal(int *a, int *b) { intret((int)(*a == *b)); } COMMANDN(=, equal, "ii"); +void notequal(int *a, int *b) { intret((int)(*a != *b)); } COMMANDN(!=, notequal, "ii"); +void lt(int *a, int *b) { intret((int)(*a < *b)); } COMMANDN(<, lt, "ii"); +void gt(int *a, int *b) { intret((int)(*a > *b)); } COMMANDN(>, gt, "ii"); +void lte(int *a, int *b) { intret((int)(*a <= *b)); } COMMANDN(<=, lte, "ii"); +void gte(int *a, int *b) { intret((int)(*a >= *b)); } COMMANDN(>=, gte, "ii"); -COMMANDF(round, ARG_1STR, (char *a) { intret((int)round(atof(a))); }); -COMMANDF(ceil, ARG_1STR, (char *a) { intret((int)ceil(atof(a))); }); -COMMANDF(floor, ARG_1STR, (char *a) { intret(atoi(a)); }); +COMMANDF(round, "f", (float *a) { intret((int)round(*a)); }); +COMMANDF(ceil, "f", (float *a) { intret((int)ceil(*a)); }); +COMMANDF(floor, "f", (float *a) { intret((int)floor(*a)); }); #define COMPAREF(opname, func, op) \ - void func(char *a, char *b) { intret((int)(atof(a) op atof(b))); } \ - COMMANDN(opname, func, ARG_2STR) + void func(float *a, float *b) { intret((int)((*a) op (*b))); } \ + COMMANDN(opname, func, "ff") COMPAREF(=f, equalf, ==); COMPAREF(!=f, notequalf, !=); COMPAREF(=f, gtef, >=); void anda (char *a, char *b) { intret(execute(a)!=0 && execute(b)!=0); } void ora (char *a, char *b) { intret(execute(a)!=0 || execute(b)!=0); } -COMMANDN(&&, anda, ARG_2STR); -COMMANDN(||, ora, ARG_2STR); +COMMANDN(&&, anda, "ss"); +COMMANDN(||, ora, "ss"); -int strcmpa(char *a, char *b) { return strcmp(a,b)==0; } COMMANDN(strcmp, strcmpa, ARG_2EST); +COMMANDF(strcmp, "ss", (char *a, char *b) { intret((strcmp(a, b) == 0) ? 1 : 0); }); -int rndn(int a) { return a>0 ? rnd(a) : 0; } COMMANDN(rnd, rndn, ARG_1EXP); +COMMANDF(rnd, "i", (int *a) { intret(*a>0 ? rnd(*a) : 0); }); #ifndef STANDALONE void writecfg() @@ -1416,7 +1382,7 @@ void writecfg() delete f; } -COMMAND(writecfg, ARG_NONE); +COMMAND(writecfg, ""); void deletecfg() { @@ -1473,18 +1439,18 @@ int popscontext() return execcontext; } -void scriptcontext(char *context, char *idname) +void scriptcontext(int *context, char *idname) { if(contextsealed) return; ident *id = idents->access(idname); if(!id) return; - int c = atoi(context); + int c = *context; if(c >= 0 && c < IEXC_NUM) id->context = c; } -void isolatecontext(int context) +void isolatecontext(int *context) { - if(context >= 0 && context < IEXC_NUM && !contextsealed) contextisolated[context] = true; + if(*context >= 0 && *context < IEXC_NUM && !contextsealed) contextisolated[*context] = true; } void sealcontexts() { contextsealed = true; } @@ -1497,16 +1463,12 @@ bool allowidentaccess(ident *id) // check if ident is allowed in current context return execcontext <= id->context; } -COMMAND(scriptcontext, ARG_2STR); -COMMAND(isolatecontext, ARG_1INT); -COMMAND(sealcontexts, ARG_NONE); +COMMAND(scriptcontext, "is"); +COMMAND(isolatecontext, "i"); +COMMAND(sealcontexts, ""); #ifndef STANDALONE -void _watchingdemo() -{ - intret(watchingdemo); -} -COMMANDN(watchingdemo, _watchingdemo, ARG_NONE); +COMMANDF(watchingdemo, "", () { intret(watchingdemo); }); void systime() { @@ -1530,12 +1492,12 @@ void timestring_() } extern int millis_() { extern int totalmillis; return totalmillis; } -void strlen_(char *s) { string r; formatstring(r)("%d", strlen(s)); result(r); } +void strlen_(char *s) { intret(strlen(s)); } -void substr_(char *fs, char *pa, char *len) +void substr_(char *fs, int *pa, int *len) { - int ia = atoi(pa); - int ilen = atoi(len); + int ia = *pa; + int ilen = *len; int fslen = (int)strlen(fs); if(ia<0) ia += fslen; if(ia>fslen || ia < 0 || ilen < 0) return; @@ -1545,13 +1507,13 @@ void substr_(char *fs, char *pa, char *len) result(fs+ia); } -void strpos_(char *haystack, char *needle, char *occurence) +void strpos_(char *haystack, char *needle, int *occurence) { int position = -1; char *ptr = haystack; if(haystack && needle) - for(int iocc = atoi(occurence); iocc >= 0; iocc--) + for(int iocc = *occurence; iocc >= 0; iocc--) { ptr = strstr(ptr, needle); if (ptr) @@ -1568,9 +1530,7 @@ void strpos_(char *haystack, char *needle, char *occurence) intret(position); } -void l0(int p, int v) { string f; string r; formatstring(f)("%%0%dd", p); formatstring(r)(f, v); result(r); } - -void getmode_(int acr) { result(modestr(gamemode, acr ? true : false)); } +void l0(int *p, int *v) { string f; string r; formatstring(f)("%%0%dd", *p); formatstring(r)(f, *v); result(r); } void getscrext() { @@ -1583,17 +1543,17 @@ void getscrext() } } -COMMANDN(millis, millis_, ARG_IVAL); -COMMANDN(strlen, strlen_, ARG_1STR); -COMMANDN(substr, substr_, ARG_3STR); -COMMANDN(strpos, strpos_, ARG_3STR); -COMMAND(l0, ARG_2INT); -COMMAND(systime, ARG_NONE); -COMMANDN(timestamp, timestamp_, ARG_NONE); -COMMAND(datestring, ARG_NONE); -COMMANDN(timestring, timestring_, ARG_NONE); -COMMANDN(getmode, getmode_, ARG_1INT); -COMMAND(getscrext, ARG_NONE); +COMMANDF(millis, "", () { intret(millis_()); }); +COMMANDN(strlen, strlen_, "s"); +COMMANDN(substr, substr_, "sii"); +COMMANDN(strpos, strpos_, "ssi"); +COMMAND(l0, "ii"); +COMMAND(systime, ""); +COMMANDN(timestamp, timestamp_, ""); +COMMAND(datestring, ""); +COMMANDN(timestring, timestring_, ""); +COMMANDF(getmode, "i", (int *acr) { result(modestr(gamemode, *acr)); }); +COMMAND(getscrext, ""); const char *currentserver(int i) // [client version] { @@ -1663,7 +1623,7 @@ const char *currentserver(int i) // [client version] return curSRVinfo; } -COMMANDF(curserver, ARG_1INT, (int i) { result(currentserver(i)); }); +COMMANDF(curserver, "i", (int *i) { result(currentserver(*i)); }); #endif void debugargs(char **args, int numargs) @@ -1677,4 +1637,4 @@ void debugargs(char **args, int numargs) printf("\n"); } -COMMAND(debugargs, ARG_VARI); +COMMAND(debugargs, "v"); diff --git a/source/src/command.h b/source/src/command.h index 767a9fc7..a3ca68a9 100644 --- a/source/src/command.h +++ b/source/src/command.h @@ -33,7 +33,7 @@ struct ident void (*fun)(); // ID_VAR, ID_COMMAND identstack *stack; // ID_ALIAS }; - int narg; // ID_VAR, ID_COMMAND + const char *sig; // command signature char *action, *executing; // ID_ALIAS bool persist; @@ -45,55 +45,40 @@ struct ident // ID_VAR ident(int type, const char *name, int minval, int maxval, int *i, void (*fun)(), bool persist, int context) : type(type), name(name), isconst(false), minval(minval), maxval(maxval), fun(fun), - narg(0), action(NULL), executing(NULL), persist(persist), context(context) + sig(NULL), action(NULL), executing(NULL), persist(persist), context(context) { storage.i = i; } // ID_FVAR ident(int type, const char *name, float minval, float maxval, float *f, void (*fun)(), bool persist, int context) : type(type), name(name), isconst(false), minvalf(minval), maxvalf(maxval), fun(fun), - narg(0), action(NULL), executing(NULL), persist(persist), context(context) + sig(NULL), action(NULL), executing(NULL), persist(persist), context(context) { storage.f = f; } // ID_SVAR ident(int type, const char *name, char **s, void (*fun)(), bool persist, int context) : type(type), name(name), isconst(false), minval(0), maxval(0), fun(fun), - narg(0), action(NULL), executing(NULL), persist(persist), context(context) + sig(NULL), action(NULL), executing(NULL), persist(persist), context(context) { storage.s = s; } // ID_ALIAS ident(int type, const char *name, char *action, bool persist, int context) : type(type), name(name), isconst(false), minval(0), maxval(0), stack(0), - narg(0), action(action), executing(NULL), persist(persist), context(context) + sig(NULL), action(action), executing(NULL), persist(persist), context(context) { storage.i = NULL; } // ID_COMMAND - ident(int type, const char *name, void (*fun)(), int narg, int context) + ident(int type, const char *name, void (*fun)(), const char *sig, int context) : type(type), name(name), isconst(false), minval(0), maxval(0), fun(fun), - narg(narg), action(NULL), executing(NULL), persist(false), context(context) + sig(sig), action(NULL), executing(NULL), persist(false), context(context) { storage.i = NULL; } }; -enum // function signatures for script functions, see command.cpp -{ - ARG_1INT, ARG_2INT, ARG_3INT, ARG_4INT, - ARG_NONE, - ARG_1STR, ARG_2STR, ARG_3STR, ARG_4STR, ARG_5STR, ARG_6STR, ARG_7STR, ARG_8STR, - ARG_DOWN, - ARG_1EXP, ARG_2EXP, - ARG_1EXPF, ARG_2EXPF, - ARG_1EST, ARG_2EST, - ARG_IVAL, ARG_FVAL, ARG_SVAL, - ARG_CONC, ARG_CONCW, - ARG_VARI -}; - enum { IEXC_CORE = 0, IEXC_CFG, IEXC_PROMPT, IEXC_MAPCFG, IEXC_MDLCFG, IEXC_NUM }; // script execution context // nasty macros for registering script functions, abuses globals to avoid excessive infrastructure -#define COMMANDN(name, fun, nargs) static bool __dummy_##fun = addcommand(#name, (void (*)())fun, nargs) -#define COMMAND(name, nargs) COMMANDN(name, name, nargs) -#define COMMANDF(name, nargs, inlinefunc) static void __dummy_##name inlinefunc ; COMMANDN(name, __dummy_##name, nargs) -#define ICOMMANDF(name, nargs, inlinefunc) static int __dummy_##name inlinefunc ; COMMANDN(name, __dummy_##name, nargs) +#define COMMANDN(name, fun, sig) static bool __dummy_##fun = addcommand(#name, (void (*)())fun, sig) +#define COMMAND(name, sig) COMMANDN(name, name, sig) +#define COMMANDF(name, sig, inlinefunc) static void __dummy_##name inlinefunc ; COMMANDN(name, __dummy_##name, sig) #define VARP(name, min, cur, max) int name = variable(#name, min, cur, max, &name, NULL, true) #define VAR(name, min, cur, max) int name = variable(#name, min, cur, max, &name, NULL, false) diff --git a/source/src/console.cpp b/source/src/console.cpp index 625bbf3d..71578902 100644 --- a/source/src/console.cpp +++ b/source/src/console.cpp @@ -84,11 +84,11 @@ bool saycommandon = false; VARFP(maxcon, 10, 200, 1000, con.setmaxlines(maxcon)); -void setconskip(int n) { con.setconskip(n); } -COMMANDN(conskip, setconskip, ARG_1INT); +void setconskip(int *n) { con.setconskip(*n); } +COMMANDN(conskip, setconskip, "i"); void toggleconsole() { con.toggleconsole(); } -COMMANDN(toggleconsole, toggleconsole, ARG_NONE); +COMMANDN(toggleconsole, toggleconsole, ""); void renderconsole() { con.render(); } @@ -115,11 +115,9 @@ void conoutf(const char *s, ...) con.addline(sf); delete[] conline; conline=newstring(sf); } -void strstra(const char *a,const char *b) { - intret(strstr(a,b)?1:0); - return; -} -COMMANDN(strstr,strstra,ARG_2STR); + +COMMANDF(strstr, "ss", (char *a, char *b) { intret(strstr(a, b) ? 1 : 0); }); + /** This is the 1.0.4 function It will substituted by rendercommand_wip I am putting this temporarily here because it is very difficult to chat in game with the current cursor behavior, @@ -180,14 +178,14 @@ vector keyms; const char *keycmds[keym::NUMACTIONS] = { "bind", "specbind", "editbind" }; inline const char *keycmd(int type) { return type >= 0 && type < keym::NUMACTIONS ? keycmds[type] : ""; } -void keymap(char *code, char *key) +void keymap(int *code, char *key) { keym &km = keyms.add(); - km.code = atoi(code); + km.code = *code; km.name = newstring(key); } -COMMAND(keymap, ARG_2STR); +COMMAND(keymap, "is"); keym *findbind(const char *key) { @@ -258,17 +256,17 @@ void searchbinds(const char *action, int type) result(names.getbuf()); } -COMMANDF(keybind, ARG_1STR, (const char *key) { keybind(key, keym::ACTION_DEFAULT); } ); -COMMANDF(keyspecbind, ARG_1STR, (const char *key) { keybind(key, keym::ACTION_SPECTATOR); } ); -COMMANDF(keyeditbind, ARG_1STR, (const char *key) { keybind(key, keym::ACTION_EDITING); } ); +COMMANDF(keybind, "s", (const char *key) { keybind(key, keym::ACTION_DEFAULT); } ); +COMMANDF(keyspecbind, "s", (const char *key) { keybind(key, keym::ACTION_SPECTATOR); } ); +COMMANDF(keyeditbind, "s", (const char *key) { keybind(key, keym::ACTION_EDITING); } ); -COMMANDF(bind, ARG_2STR, (const char *key, const char *action) { bindk(key, action, keym::ACTION_DEFAULT); } ); -COMMANDF(specbind, ARG_2STR, (const char *key, const char *action) { bindk(key, action, keym::ACTION_SPECTATOR); } ); -COMMANDF(editbind, ARG_2STR, (const char *key, const char *action) { bindk(key, action, keym::ACTION_EDITING); } ); +COMMANDF(bind, "ss", (const char *key, const char *action) { bindk(key, action, keym::ACTION_DEFAULT); } ); +COMMANDF(specbind, "ss", (const char *key, const char *action) { bindk(key, action, keym::ACTION_SPECTATOR); } ); +COMMANDF(editbind, "ss", (const char *key, const char *action) { bindk(key, action, keym::ACTION_EDITING); } ); -COMMANDF(searchbinds, ARG_1STR, (const char *action) { searchbinds(action, keym::ACTION_DEFAULT); }); -COMMANDF(searchspecbinds, ARG_1STR, (const char *action) { searchbinds(action, keym::ACTION_SPECTATOR); }); -COMMANDF(searcheditbinds, ARG_1STR, (const char *action) { searchbinds(action, keym::ACTION_EDITING); }); +COMMANDF(searchbinds, "s", (const char *action) { searchbinds(action, keym::ACTION_DEFAULT); }); +COMMANDF(searchspecbinds, "s", (const char *action) { searchbinds(action, keym::ACTION_SPECTATOR); }); +COMMANDF(searcheditbinds, "s", (const char *action) { searchbinds(action, keym::ACTION_EDITING); }); struct releaseaction { @@ -291,7 +289,7 @@ void onrelease(char *s) addreleaseaction(s); } -COMMAND(onrelease, ARG_1STR); +COMMAND(onrelease, "s"); void saycommand(char *init) // turns input to the command line on or off { @@ -327,10 +325,10 @@ void getmapmsg(void) result(text); } -COMMAND(saycommand, ARG_CONC); -COMMAND(inputcommand, ARG_3STR); -COMMAND(mapmsg, ARG_1STR); -COMMAND(getmapmsg, ARG_NONE); +COMMAND(saycommand, "c"); +COMMAND(inputcommand, "sss"); +COMMAND(mapmsg, "s"); +COMMAND(getmapmsg, ""); #if !defined(WIN32) && !defined(__APPLE__) #include @@ -430,18 +428,18 @@ int histpos = 0; VARP(maxhistory, 0, 1000, 10000); -void history_(int n) +void history_(int *n) { static bool inhistory = false; - if(!inhistory && history.inrange(n)) + if(!inhistory && history.inrange(*n)) { inhistory = true; - history[history.length()-n-1]->run(); + history[history.length() - *n - 1]->run(); inhistory = false; } } -COMMANDN(history, history_, ARG_1INT); +COMMANDN(history, history_, "i"); void execbind(keym &k, bool isdown) { diff --git a/source/src/docs.cpp b/source/src/docs.cpp index 7c15586a..4d4b4735 100644 --- a/source/src/docs.cpp +++ b/source/src/docs.cpp @@ -157,13 +157,13 @@ void adddockey(char *alias, char *name, char *desc) k.desc = desc && strlen(desc) ? newstring(desc) : NULL; } -COMMANDN(docsection, adddocsection, ARG_1STR); -COMMANDN(docident, adddocident, ARG_2STR); -COMMANDN(docargument, adddocargument, ARG_4STR); -COMMANDN(docremark, adddocremark, ARG_1STR); -COMMANDN(docref, adddocref, ARG_4STR); -COMMANDN(docexample, adddocexample, ARG_2STR); -COMMANDN(dockey, adddockey, ARG_3STR); +COMMANDN(docsection, adddocsection, "s"); +COMMANDN(docident, adddocident, "ss"); +COMMANDN(docargument, adddocargument, "ssss"); +COMMANDN(docremark, adddocremark, "s"); +COMMANDN(docref, adddocref, "ssss"); +COMMANDN(docexample, adddocexample, "ss"); +COMMANDN(dockey, adddockey, "sss"); int stringsort(const char **a, const char **b) { return strcmp(*a, *b); } @@ -211,10 +211,10 @@ void listundoneidents(vector &inames, int allidents) inames.sort(stringsort); } -void docundone(int allidents) +void docundone(int *allidents) { vector inames; - listundoneidents(inames, allidents); + listundoneidents(inames, *allidents); inames.sort(stringsort); loopv(inames) conoutf("%s", inames[i]); } @@ -283,7 +283,7 @@ char *xmlstringenc(char *d, const char *s, size_t len) void docwriteref(int allidents, const char *ref, const char *schemalocation, const char *transformation) { - stream *f = openfile(path(allidents < 0 ? "docs/autogenerated_base_reference.xml" : "docs/autogenerated_todo_reference.xml", true), "w"); + /*stream *f = openfile(path(allidents < 0 ? "docs/autogenerated_base_reference.xml" : "docs/autogenerated_todo_reference.xml", true), "w"); if(!f) return; char desc[] = "TODO: Description"; @@ -304,7 +304,7 @@ void docwriteref(int allidents, const char *ref, const char *schemalocation, con f->printf("\t\t\t\n"); } - static const int bases[] = { ARG_1INT, ARG_1STR, ARG_1EXP, ARG_1EXPF, ARG_1EST }; + static const int bases[] = { "i", "s", "i", "i"F, ARG_1EST }; string name; loopv(inames) { @@ -312,10 +312,10 @@ void docwriteref(int allidents, const char *ref, const char *schemalocation, con if(!id || id->type != ID_COMMAND) continue; f->printf("\t\t\t\t\n", xmlstringenc(name, id->name, MAXSTRLEN)); f->printf("\t\t\t\t\t%s\n", desc); - if(id->narg != ARG_NONE && id->narg != ARG_DOWN && id->narg != ARG_IVAL && id->narg != ARG_FVAL && id->narg != ARG_SVAL) + if(id->narg != "" && id->narg != "d" && id->narg != ARG_IVAL && id->narg != ARG_FVAL && id->narg != ARG_SVAL) { f->printf("\t\t\t\t\t\n"); - if(id->narg == ARG_CONC || id->narg == ARG_CONCW || id->narg == ARG_VARI) f->printf("\t\t\t\t\t\t\n"); + if(id->narg == "c" || id->narg == "c"W || id->narg == ARG_VARI) f->printf("\t\t\t\t\t\t\n"); else { int base = -1; @@ -358,7 +358,7 @@ void docwriteref(int allidents, const char *ref, const char *schemalocation, con } if(allidents < 0) f->printf("\t\t\t\n\t\t\n\t\n\n"); - delete f; + delete f;*/ } void docwritebaseref(char *ref, char *schemalocation, char *transformation) @@ -366,16 +366,16 @@ void docwritebaseref(char *ref, char *schemalocation, char *transformation) docwriteref(-1, ref, schemalocation, transformation); } -void docwritetodoref(int allidents) +void docwritetodoref(int *allidents) { - docwriteref(allidents ? 1 : 0, "", "", ""); + docwriteref(*allidents ? 1 : 0, "", "", ""); } -COMMAND(docundone, ARG_1INT); -COMMAND(docinvalid, ARG_NONE); -COMMAND(docfind, ARG_1STR); -COMMAND(docwritebaseref, ARG_3STR); -COMMAND(docwritetodoref, ARG_1INT); +COMMAND(docundone, "i"); +COMMAND(docinvalid, ""); +COMMAND(docfind, "s"); +COMMAND(docwritebaseref, "sss"); +COMMAND(docwritetodoref, "i"); VAR(docvisible, 0, 1, 1); VAR(docskip, 0, 0, 1000); diff --git a/source/src/editing.cpp b/source/src/editing.cpp index 1d67b2dc..d7c5782e 100644 --- a/source/src/editing.cpp +++ b/source/src/editing.cpp @@ -50,7 +50,7 @@ void toggleedit(bool force) void edittoggle() { toggleedit(false); } -COMMAND(edittoggle, ARG_NONE); +COMMAND(edittoggle, ""); bool correctsel(block &s) // ensures above invariant { @@ -138,10 +138,10 @@ void makesel(bool isnew) } #define SEL_ATTR(attr) { string buf = ""; loopv(sels) { concatformatstring(buf, "%d ", sels[i].attr); } result(buf); } -COMMANDF(selx, ARG_NONE, (void) { SEL_ATTR(x); }); -COMMANDF(sely, ARG_NONE, (void) { SEL_ATTR(y); }); -COMMANDF(selxs, ARG_NONE, (void) { SEL_ATTR(xs); }); -COMMANDF(selys, ARG_NONE, (void) { SEL_ATTR(ys); }); +COMMANDF(selx, "", (void) { SEL_ATTR(x); }); +COMMANDF(sely, "", (void) { SEL_ATTR(y); }); +COMMANDF(selxs, "", (void) { SEL_ATTR(xs); }); +COMMANDF(selys, "", (void) { SEL_ATTR(ys); }); #undef SEL_ATTR VAR(flrceil,0,0,2); @@ -310,17 +310,17 @@ void paste() } // Count the walls of type "type" contained in the current selection -int countwalls(int type) +void countwalls(int *type) { int counter = 0; - EDITSELMP 0; - if(type < 0 || type >= MAXTYPE) + EDITSELMP; + if(*type < 0 || *type >= MAXTYPE) { conoutf("invalid type"); - return 0; + intret(0); } - loopselsxy(if(s->type==type) counter++) - return counter; + loopselsxy(if(s->type==*type) counter++) + intret(counter); } void tofronttex() // maintain most recently used of the texture lists when applying texture @@ -374,18 +374,18 @@ void editheightxy(bool isfloor, int amount, block &sel) }); } -void editheight(int flr, int amount) +void editheight(int *flr, int *amount) { EDITSEL; - bool isfloor = flr==0; + bool isfloor = *flr==0; loopv(sels) { - editheightxy(isfloor, amount, sels[i]); - addmsg(SV_EDITH, "ri6", sels[i].x, sels[i].y, sels[i].xs, sels[i].ys, isfloor, amount); + editheightxy(isfloor, *amount, sels[i]); + addmsg(SV_EDITH, "ri6", sels[i].x, sels[i].y, sels[i].xs, sels[i].ys, isfloor, *amount); } } -COMMAND(editheight, ARG_2INT); +COMMAND(editheight, "ii"); // texture type : 0 floor, 1 wall, 2 ceil, 3 upper wall @@ -477,13 +477,13 @@ void edittype(int type) } } -void heightfield(int t) { edittype(t==0 ? FHF : CHF); } -void solid(int t) { edittype(t==0 ? SPACE : SOLID); } +void heightfield(int *t) { edittype(*t==0 ? FHF : CHF); } +void solid(int *t) { edittype(*t==0 ? SPACE : SOLID); } void corner() { edittype(CORNER); } -COMMAND(heightfield, ARG_1INT); -COMMAND(solid, ARG_1INT); -COMMAND(corner, ARG_NONE); +COMMAND(heightfield, "i"); +COMMAND(solid, "i"); +COMMAND(corner, ""); void editequalisexy(bool isfloor, block &sel) { @@ -500,9 +500,9 @@ void editequalisexy(bool isfloor, block &sel) }); } -void equalize(int flr) +void equalize(int *flr) { - bool isfloor = flr==0; + bool isfloor = *flr==0; EDITSEL; loopv(sels) { @@ -512,7 +512,7 @@ void equalize(int flr) } } -COMMAND(equalize, ARG_1INT); +COMMAND(equalize, "i"); void setvdeltaxy(int delta, block &sel) { @@ -534,18 +534,18 @@ const int MAXARCHVERT = 50; int archverts[MAXARCHVERT][MAXARCHVERT]; bool archvinit = false; -void archvertex(int span, int vert, int delta) +void archvertex(int *span, int *vert, int *delta) { if(!archvinit) { archvinit = true; loop(s,MAXARCHVERT) loop(v,MAXARCHVERT) archverts[s][v] = 0; } - if(span>=MAXARCHVERT || vert>=MAXARCHVERT || span<0 || vert<0) return; - archverts[span][vert] = delta; + if(*span>=MAXARCHVERT || *vert>=MAXARCHVERT || *span<0 || *vert<0) return; + archverts[*span][*vert] = *delta; } -void arch(int sidedelta, int _a) +void arch(int *sidedelta) { EDITSELMP; loopv(sels) @@ -557,8 +557,8 @@ void arch(int sidedelta, int _a) if(sel.ys>MAXARCHVERT) sel.ys = MAXARCHVERT; loopselxy(sel, s->vdelta = sel.xs>sel.ys - ? (archverts[sel.xs-1][x] + (y==0 || y==sel.ys-1 ? sidedelta : 0)) - : (archverts[sel.ys-1][y] + (x==0 || x==sel.xs-1 ? sidedelta : 0))); + ? (archverts[sel.xs-1][x] + (y==0 || y==sel.ys-1 ? *sidedelta : 0)) + : (archverts[sel.ys-1][y] + (x==0 || x==sel.xs-1 ? *sidedelta : 0))); remipmore(sel); } } @@ -608,16 +608,16 @@ VARF(fullbright, 0, 0, 1, else calclight(); ); -void edittag(int tag) +void edittag(int *tag) { EDITSELMP; - loopselsxy(s->tag = tag); + loopselsxy(s->tag = *tag); } -void newent(char *what, char *a1, char *a2, char *a3, char *a4) +void newent(char *what, int *a1, int *a2, int *a3, int *a4) { EDITSEL; - loopv(sels) newentity(-1, sels[i].x, sels[i].y, (int)camera1->o.z, what, ATOI(a1), ATOI(a2), ATOI(a3), ATOI(a4)); + loopv(sels) newentity(-1, sels[i].x, sels[i].y, (int)camera1->o.z, what, *a1, *a2, *a3, *a4); } void movemap(int xo, int yo, int zo) // move whole map @@ -710,23 +710,23 @@ void selectionflip(char *axis) loopv(sels) selfliprotate(sels[i], c == 'X' ? 11 : 12); } -COMMANDF(select, ARG_4INT, (int x, int y, int xs, int ys) { resetselections(); addselection(x, y, xs, ys, 0); }); -COMMANDF(addselection, ARG_4INT, (int x, int y, int xs, int ys) { addselection(x, y, xs, ys, 0); }); -COMMAND(resetselections, ARG_NONE); -COMMAND(edittag, ARG_1INT); -COMMAND(replace, ARG_NONE); -COMMAND(archvertex, ARG_3INT); -COMMAND(arch, ARG_2INT); -COMMAND(slope, ARG_2INT); -COMMANDN(vdelta, setvdelta, ARG_1INT); -COMMANDN(undo, editundo, ARG_NONE); -COMMAND(copy, ARG_NONE); -COMMAND(paste, ARG_NONE); -COMMAND(edittex, ARG_2INT); -COMMAND(newent, ARG_5STR); -COMMAND(perlin, ARG_3INT); -COMMAND(movemap, ARG_3INT); -COMMAND(selectionrotate, ARG_1INT); -COMMAND(selectionflip, ARG_1STR); -COMMAND(countwalls, ARG_1EXP); -COMMAND(settex, ARG_2INT); +COMMANDF(select, "iiii", (int *x, int *y, int *xs, int *ys) { resetselections(); addselection(*x, *y, *xs, *ys, 0); }); +COMMANDF(addselection, "iiii", (int *x, int *y, int *xs, int *ys) { addselection(*x, *y, *xs, *ys, 0); }); +COMMAND(resetselections, ""); +COMMAND(edittag, "i"); +COMMAND(replace, ""); +COMMAND(archvertex, "iii"); +COMMAND(arch, "i"); +COMMANDF(slope, "ii", (int *xd, int *yd) { slope(*xd, *yd); }); +COMMANDF(vdelta, "i", (int *d) { setvdelta(*d); }); +COMMANDN(undo, editundo, ""); +COMMAND(copy, ""); +COMMAND(paste, ""); +COMMANDF(edittex, "ii", (int *type, int *dir) { edittex(*type, *dir); }); +COMMAND(newent, "siiii"); +COMMANDF(perlin, "iii", (int *sc, int *se, int *ps) { perlin(*sc, *se, *ps); }); +COMMANDF(movemap, "iii", (int *x, int *y, int *z) { movemap(*x, *y, *z); }); +COMMANDF(selectionrotate, "i", (int *d) { selectionrotate(*d); }); +COMMAND(selectionflip, "s"); +COMMAND(countwalls, "i"); +COMMANDF(settex, "ii", (int *texture, int *type) { edittex(*texture, *type); }); diff --git a/source/src/entities.cpp b/source/src/entities.cpp index d2a0a08b..000a0057 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -75,7 +75,7 @@ void showedithide() else { conoutf("#%02d: %d : -n/a-", i, eh_ents[i]); } } } -COMMAND(showedithide, ARG_NONE); +COMMAND(showedithide, ""); void setedithide(char *text) // FIXME: human indexing inside { @@ -97,7 +97,7 @@ void setedithide(char *text) // FIXME: human indexing inside while(s); } } -COMMAND(setedithide, ARG_CONC); +COMMAND(setedithide, "c"); void seteditshow(char *just) { @@ -116,7 +116,7 @@ void seteditshow(char *just) } } } -COMMAND(seteditshow, ARG_1STR); +COMMAND(seteditshow, "s"); void renderentarrow(const entity &e, const vec &dir, float radius) { @@ -648,7 +648,7 @@ void entstats(void) conoutf("total entities: %d", ents.length()); } -COMMAND(entstats, ARG_NONE); +COMMAND(entstats, ""); vector changedents; int lastentsync = 0; diff --git a/source/src/i18n.cpp b/source/src/i18n.cpp index b496d045..64362482 100644 --- a/source/src/i18n.cpp +++ b/source/src/i18n.cpp @@ -23,4 +23,4 @@ void script_gettext(char *msgid) result(translated); } -COMMANDN(gettext, script_gettext, ARG_1STR); +COMMANDN(gettext, script_gettext, "s"); diff --git a/source/src/main.cpp b/source/src/main.cpp index 7277bfa4..e5be87d1 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -482,9 +482,9 @@ void makeautoscreenshot() screenshot(NULL); } -COMMAND(screenshot, ARG_1STR); -COMMAND(mapshot, ARG_NONE); -COMMAND(quit, ARG_NONE); +COMMAND(screenshot, "s"); +COMMAND(mapshot, ""); +COMMAND(quit, ""); void screenres(int w, int h) { @@ -516,7 +516,7 @@ void setresdata(char *s, enet_uint32 c) } #endif -COMMAND(screenres, ARG_2INT); +COMMANDF(screenres, "ii", (int *w, int *h) { screenres(*w, *h); }); static int curgamma = 100; VARFP(gamma, 30, 100, 300, @@ -677,7 +677,7 @@ void resetgl() c2skeepalive(); } -COMMAND(resetgl, ARG_NONE); +COMMAND(resetgl, ""); VARFP(maxfps, 0, 200, 1000, if(maxfps && maxfps < 25) maxfps = 25); @@ -705,14 +705,14 @@ void limitfps(int &millis, int curmillis) int lowfps = 30, highfps = 40; -void fpsrange(int low, int high) +void fpsrange(int *low, int *high) { - if(low>high || low<1) return; - lowfps = low; - highfps = high; + if(*low>*high || *low<1) return; + lowfps = *low; + highfps = *high; } -COMMAND(fpsrange, ARG_2INT); +COMMAND(fpsrange, "ii"); void keyrepeat(bool on) { @@ -895,14 +895,16 @@ const char *rndmapname() return mapnames[n]; } -extern void connectserv(char *, char *, char *); +extern void connectserv(char *, int *, char *); -void connectprotocol(char *protocolstring, string &servername, string &serverport, string &password, bool &direct_connect) +void connectprotocol(char *protocolstring, string &servername, int &serverport, string &password, bool &direct_connect) { const char *c = &protocolstring[14], *p = c; int len = 0; direct_connect = false; - servername[0] = serverport[0] = password[0] = '\0'; + string sp; + servername[0] = password[0] = '\0'; + serverport = 0; while(*c && *c!='/' && *c!='?' && *c!=':') { len++; c++; } if(!len) { conoutf("\f3bad commandline syntax", protocolstring); return; } copystring(servername, p, min(len+1, MAXSTRLEN)); @@ -911,7 +913,11 @@ void connectprotocol(char *protocolstring, string &servername, string &serverpor { c++; p = c; len = 0; while(*c && *c!='/' && *c!='?') { len++; c++; } - if(len) copystring(serverport, p, min(len+1, MAXSTRLEN)); + if(len) + { + copystring(sp, p, min(len+1, MAXSTRLEN)); + serverport = atoi(sp); + } } if(*c && *c=='/') c++; if(!*c || *c!='?') return; @@ -922,7 +928,11 @@ void connectprotocol(char *protocolstring, string &servername, string &serverpor { c += 5; p = c; len = 0; while(*c && *c!='&' && *c!='/') { len++; c++; } - if(len) copystring(serverport, p, min(len+1, MAXSTRLEN)); + if(len) + { + copystring(sp, p, min(len+1, MAXSTRLEN)); + serverport = atoi(sp); + } } else if(!strncmp(c, "password=", 9)) { @@ -987,7 +997,8 @@ int main(int argc, char **argv) char *initscript = NULL; char *initdemo = NULL; bool direct_connect = false; // to connect via assaultcube:// browser switch - string servername, serverport, password; + string servername, password; + int serverport; const char *initmap = rndmapname(); @@ -1276,7 +1287,7 @@ int main(int argc, char **argv) if (direct_connect) { direct_connect = false; - connectserv(servername, serverport, password); + connectserv(servername, &serverport, password); } } diff --git a/source/src/master.cpp b/source/src/master.cpp index c11ea6ea..ad0cc490 100644 --- a/source/src/master.cpp +++ b/source/src/master.cpp @@ -32,14 +32,14 @@ void adduser(char *name, char *pubkey) u.name = name; u.pubkey = parsepubkey(pubkey); } -COMMAND(adduser, ARG_2STR); +COMMAND(adduser, "ss"); void clearusers() { enumerate(users, userinfo, u, { delete[] u.name; freepubkey(u.pubkey); }); users.clear(); } -COMMAND(clearusers, ARG_NONE); +COMMAND(clearusers, ""); // :for AUTH struct baninfo @@ -54,7 +54,7 @@ void clearbans() servbans.shrink(0); gbans.shrink(0); } -COMMAND(clearbans, ARG_NONE); +COMMAND(clearbans, ""); void addban(vector &bans, const char *name) { @@ -74,9 +74,9 @@ void addban(vector &bans, const char *name) ban.ip = ip.i; ban.mask = mask.i; } -COMMANDF(ban, ARG_1STR, (char *name) { addban(bans, name); }); -COMMANDF(servban, ARG_1STR, (char *name) { addban(servbans, name); }); -COMMANDF(gban, ARG_1STR, (char *name) { addban(gbans, name); }); +COMMANDF(ban, "s", (char *name) { addban(bans, name); }); +COMMANDF(servban, "s", (char *name) { addban(servbans, name); }); +COMMANDF(gban, "s", (char *name) { addban(gbans, name); }); char *printban(const baninfo &ban, char *buf) { diff --git a/source/src/md2.h b/source/src/md2.h index bcb4117e..935c30a7 100644 --- a/source/src/md2.h +++ b/source/src/md2.h @@ -27,7 +27,7 @@ struct md2 : vertmodel float translate[3]; char name[16]; }; - + md2(const char *name) : vertmodel(name) {} int type() { return MDL_MD2; } @@ -60,11 +60,11 @@ struct md2 : vertmodel tc.u = u.f; tc.v = v.f; vindexes.add((ushort)vindex); - } + } idxs.add(*idx); } - loopi(numvertex-2) - { + loopi(numvertex-2) + { tri &t = tris.add(); if(isfan) { @@ -76,7 +76,7 @@ struct md2 : vertmodel } } } - + bool load(char *path) { if(filename) return true; @@ -88,12 +88,12 @@ struct md2 : vertmodel file->read(&header, sizeof(md2_header)); lilswap((int *)&header, sizeof(md2_header)/sizeof(int)); - if(header.magic!=844121161 || header.version!=8) + if(header.magic!=844121161 || header.version!=8) { delete file; return false; } - + numframes = header.numframes; mesh &m = *new mesh; @@ -144,14 +144,14 @@ struct md2 : vertmodel delete[] tmpverts; delete file; - + filename = newstring(path); return true; } void getdefaultanim(animstate &as, int anim, int varseed) { - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 21 23 24 + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 21 23 24 // I R A P P P J L F S T W P CI CW CA CP CD D D D LD LD LD F static int frame[] = { 0, 40, 46, 54, 58, 62, 66, 69, 72, 84, 95, 112,123,135,154,160,169,173,178,184,190,183,189,197, 0 }; static int range[] = { 40, 6, 8, 4, 4, 4, 3, 3, 12, 11, 17, 11, 12, 19, 6, 9, 4, 5, 6, 6, 8, 1, 1, 1, 7 }; @@ -239,7 +239,7 @@ struct md2 : vertmodel } bool load() - { + { if(loaded) return true; md2part &mdl = *new md2part; parts.add(&mdl); @@ -276,12 +276,12 @@ struct md2 : vertmodel } }; -void md2anim(char *anim, char *frame, char *range, char *speed) +void md2anim(char *anim, int *frame, int *range, float *speed) { if(!loadingmd2 || loadingmd2->parts.empty()) { conoutf("not loading an md2"); return; } int num = findanim(anim); if(num<0) { conoutf("could not find animation %s", anim); return; } - loadingmd2->parts.last()->setanim(num, atoi(frame), atoi(range), atof(speed)); + loadingmd2->parts.last()->setanim(num, *frame, *range, *speed); } void md2tag(char *name, char *vert1, char *vert2, char *vert3, char *vert4) @@ -323,14 +323,14 @@ void md2tag(char *name, char *vert1, char *vert2, char *vert3, char *vert4) if(!mdl.gentag(name, indexes, numverts)) { conoutf("could not generate tag %s", name); return; } } -void md2emit(char *tag, char *type, char *arg1, char *arg2) +void md2emit(char *tag, int *type, int *arg1, int *arg2) { if(!loadingmd2 || loadingmd2->parts.empty()) { conoutf("not loading an md2"); return; }; md2::part &mdl = *loadingmd2->parts.last(); - if(!mdl.addemitter(tag, ATOI(type), ATOI(arg1), ATOI(arg2))) { conoutf("could not find tag %s", tag); return; } + if(!mdl.addemitter(tag, *type, *arg1, *arg2)) { conoutf("could not find tag %s", tag); return; } } -COMMAND(md2anim, ARG_4STR); -COMMAND(md2tag, ARG_5STR); -COMMAND(md2emit, ARG_4STR); +COMMAND(md2anim, "siif"); +COMMAND(md2tag, "sssss"); +COMMAND(md2emit, "siii"); diff --git a/source/src/md3.h b/source/src/md3.h index a941abf5..021fca6d 100644 --- a/source/src/md3.h +++ b/source/src/md3.h @@ -60,21 +60,21 @@ struct md3 : vertmodel lilswap(&header.version, 1); lilswap(&header.flags, 9); if(strncmp(header.id, "IDP3", 4) != 0 || header.version != 15) // header check - { + { delete f; - conoutf("md3: corrupted header"); - return false; + conoutf("md3: corrupted header"); + return false; } numframes = header.numframes; - numtags = header.numtags; + numtags = header.numtags; if(numtags) { tags = new tag[numframes*numtags]; f->seek(header.ofs_tags, SEEK_SET); md3tag tag; - - loopi(header.numframes*header.numtags) + + loopi(header.numframes*header.numtags) { f->read(&tag, sizeof(md3tag)); lilswap((float *)&tag.pos, 12); @@ -102,12 +102,12 @@ struct md3 : vertmodel mesh_offset += mheader.meshsize; continue; } - + mesh &m = *meshes.add(new mesh); m.owner = this; m.name = newstring(mheader.name); - - m.numtris = mheader.numtriangles; + + m.numtris = mheader.numtriangles; m.tris = new tri[m.numtris]; f->seek(mesh_offset + mheader.ofs_triangles, SEEK_SET); loopj(mheader.numtriangles) @@ -120,12 +120,12 @@ struct md3 : vertmodel m.numverts = mheader.numvertices; m.tcverts = new tcvert[m.numverts]; - f->seek(mesh_offset + mheader.ofs_uv , SEEK_SET); + f->seek(mesh_offset + mheader.ofs_uv , SEEK_SET); f->read(m.tcverts, 2*sizeof(float)*m.numverts); // read the UV data lilswap(&m.tcverts[0].u, 2*m.numverts); - + m.verts = new vec[numframes*m.numverts + 1]; - f->seek(mesh_offset + mheader.ofs_vertices, SEEK_SET); + f->seek(mesh_offset + mheader.ofs_vertices, SEEK_SET); loopj(numframes*mheader.numvertices) { md3vertex v; @@ -141,7 +141,7 @@ struct md3 : vertmodel } delete f; - filename = newstring(path); + filename = newstring(path); return true; } @@ -152,7 +152,7 @@ struct md3 : vertmodel matrixstack[0].rotate_around_z(180*RAD); } }; - + void render(int anim, int varseed, float speed, int basetime, const vec &o, float yaw, float pitch, dynent *d, modelattach *a, float scale) { if(!loaded) return; @@ -232,7 +232,7 @@ struct md3 : vertmodel md3part &mdl = *new md3part; parts.add(&mdl); mdl.model = this; - mdl.index = 0; + mdl.index = 0; defformatstring(name1)("packages/models/%s/tris.md3", loadname); if(!mdl.load(path(name1))) { @@ -253,7 +253,7 @@ struct md3 : vertmodel }; void md3load(char *model) -{ +{ if(!loadingmd3) { conoutf("not loading an md3"); return; }; defformatstring(filename)("%s/%s", md3dir, model); md3::md3part &mdl = *new md3::md3part; @@ -261,15 +261,15 @@ void md3load(char *model) mdl.model = loadingmd3; mdl.index = loadingmd3->parts.length()-1; if(!mdl.load(path(filename))) conoutf("could not load %s", filename); // ignore failure -} - +} + void md3skin(char *objname, char *skin) -{ +{ if(!objname || !skin) return; if(!loadingmd3 || loadingmd3->parts.empty()) { conoutf("not loading an md3"); return; }; md3::part &mdl = *loadingmd3->parts.last(); loopv(mdl.meshes) - { + { md3::mesh &m = *mdl.meshes[i]; if(!strcmp(objname, "*") || !strcmp(m.name, objname)) { @@ -279,32 +279,31 @@ void md3skin(char *objname, char *skin) } } -void md3anim(char *anim, char *startframe, char *range, char *speed) +void md3anim(char *anim, int *startframe, int *range, float *speed) { if(!loadingmd3 || loadingmd3->parts.empty()) { conoutf("not loading an md3"); return; }; int num = findanim(anim); if(num<0) { conoutf("could not find animation %s", anim); return; }; - loadingmd3->parts.last()->setanim(num, atoi(startframe), atoi(range), atof(speed)); + loadingmd3->parts.last()->setanim(num, *startframe, *range, *speed); } -void md3link(char *parentno, char *childno, char *tagname) +void md3link(int *parent, int *child, char *tagname) { if(!loadingmd3) { conoutf("not loading an md3"); return; }; - int parent = ATOI(parentno), child = ATOI(childno); - if(!loadingmd3->parts.inrange(parent) || !loadingmd3->parts.inrange(child)) { conoutf("no models loaded to link"); return; } - if(!loadingmd3->parts[parent]->link(loadingmd3->parts[child], tagname)) conoutf("could not link model %s", loadingmd3->loadname); + if(!loadingmd3->parts.inrange(*parent) || !loadingmd3->parts.inrange(*child)) { conoutf("no models loaded to link"); return; } + if(!loadingmd3->parts[*parent]->link(loadingmd3->parts[*child], tagname)) conoutf("could not link model %s", loadingmd3->loadname); } -void md3emit(char *tag, char *type, char *arg1, char *arg2) +void md3emit(char *tag, int *type, int *arg1, int *arg2) { if(!loadingmd3 || loadingmd3->parts.empty()) { conoutf("not loading an md3"); return; }; md3::part &mdl = *loadingmd3->parts.last(); - if(!mdl.addemitter(tag, ATOI(type), ATOI(arg1), ATOI(arg2))) { conoutf("could not find tag %s", tag); return; } + if(!mdl.addemitter(tag, *type, *arg1, *arg2)) { conoutf("could not find tag %s", tag); return; } } - -COMMAND(md3load, ARG_1STR); -COMMAND(md3skin, ARG_2STR); -COMMAND(md3anim, ARG_4STR); -COMMAND(md3link, ARG_3STR); -COMMAND(md3emit, ARG_4STR); - + +COMMAND(md3load, "s"); +COMMAND(md3skin, "ss"); +COMMAND(md3anim, "siif"); +COMMAND(md3link, "iis"); +COMMAND(md3emit, "siii"); + diff --git a/source/src/menus.cpp b/source/src/menus.cpp index 69e19171..463609c4 100644 --- a/source/src/menus.cpp +++ b/source/src/menus.cpp @@ -799,9 +799,9 @@ void *addmenu(const char *name, const char *title, bool allowinput, void (__cdec return &menu; } -void newmenu(char *name, char *hotkeys, char *forwardkeys) +void newmenu(char *name, int *hotkeys, int *forwardkeys) { - addmenu(name, NULL, true, NULL, NULL, atoi(hotkeys) > 0, atoi(forwardkeys) > 0); + addmenu(name, NULL, true, NULL, NULL, *hotkeys > 0, *forwardkeys > 0); } void menureset(void *menu) @@ -818,7 +818,7 @@ void delmenu(const char *name) else menureset(m); } -COMMAND(delmenu, ARG_1STR); +COMMAND(delmenu, "s"); void menumanual(void *menu, char *text, char *action, color *bgcolor, const char *desc) { @@ -852,7 +852,7 @@ void lastmenu_header(char *header, char *footer) } else conoutf("no last menu to apply to"); } -COMMANDN(menuheader, lastmenu_header, ARG_2STR); +COMMANDN(menuheader, lastmenu_header, "ss"); void menufont(void *menu, const char *usefont) { @@ -870,11 +870,11 @@ void setmenufont(char *usefont) menufont(lastmenu, usefont); } -void setmenublink(int truth) +void setmenublink(int *truth) { if(!lastmenu) return; gmenu &m = *(gmenu *)lastmenu; - m.allowblink = truth != 0; + m.allowblink = *truth != 0; } void menuinit(char *initaction) @@ -883,17 +883,17 @@ void menuinit(char *initaction) lastmenu->initaction = newstring(initaction); } -void menuinitselection(int line) +void menuinitselection(int *line) { if(!lastmenu) return; - if(lastmenu->items.inrange(line)) lastmenu->menusel = line; + if(lastmenu->items.inrange(*line)) lastmenu->menusel = *line; } -void menuselection(char *menu, char *line) +void menuselection(char *menu, int *line) { - if(!menu || !line || !menus.access(menu)) return; + if(!menu || !menus.access(menu)) return; gmenu &m = menus[menu]; - menuselect(&m, atoi(line)); + menuselect(&m, *line); } void menuitem(char *text, char *action, char *hoveraction) @@ -928,16 +928,16 @@ void menuitemmapload(char *name, char *text) lastmenu->items.add(new mitemmapload(lastmenu, newstring(name), newstring(name), newstring(caction), NULL, NULL, NULL)); } -void menuitemtextinput(char *text, char *value, char *action, char *hoveraction, char *maxchars) +void menuitemtextinput(char *text, char *value, char *action, char *hoveraction, int *maxchars) { if(!lastmenu || !text || !value) return; - lastmenu->items.add(new mitemtextinput(lastmenu, newstring(text), newstring(value), action[0] ? newstring(action) : NULL, hoveraction[0] ? newstring(hoveraction) : NULL, NULL, atoi(maxchars))); + lastmenu->items.add(new mitemtextinput(lastmenu, newstring(text), newstring(value), action[0] ? newstring(action) : NULL, hoveraction[0] ? newstring(hoveraction) : NULL, NULL, *maxchars)); } -void menuitemslider(char *text, char *min_, char *max_, char *value, char *step, char *display, char *action) +void menuitemslider(char *text, int *min_, int *max_, char *value, int *step, char *display, char *action) { if(!lastmenu) return; - lastmenu->items.add(new mitemslider(lastmenu, newstring(text), atoi(min_), atoi(max_), atoi(step), newstring(value), display[0] ? newstring(display) : NULL, action[0] ? newstring(action) : NULL, NULL)); + lastmenu->items.add(new mitemslider(lastmenu, newstring(text), *min_, *max_, *step, newstring(value), display[0] ? newstring(display) : NULL, action[0] ? newstring(action) : NULL, NULL)); } void menuitemkeyinput(char *text, char *bindcmd) @@ -952,17 +952,17 @@ void menuitemcheckbox(char *text, char *value, char *action) lastmenu->items.add(new mitemcheckbox(lastmenu, newstring(text), newstring(value), action[0] ? newstring(action) : NULL, NULL)); } -void menumdl(char *mdl, char *anim, char *rotspeed, char *scale) +void menumdl(char *mdl, char *anim, int *rotspeed, int *scale) { if(!lastmenu || !mdl || !anim) return; gmenu &menu = *lastmenu; menu.mdl = newstring(mdl); menu.anim = findanim(anim)|ANIM_LOOP; - menu.rotspeed = max(0, min(atoi(rotspeed), 100)); - menu.scale = max(0, min(atoi(scale), 100)); + menu.rotspeed = clamp(*rotspeed, 0, 100); + menu.scale = clamp(*scale, 0, 100); } -void menudirlist(char *dir, char *ext, char *action, char *image) +void menudirlist(char *dir, char *ext, char *action, int *image) { if(!lastmenu) return; if(!action || !action[0]) return; @@ -972,10 +972,10 @@ void menudirlist(char *dir, char *ext, char *action, char *image) d->dir = newstring(dir); d->ext = ext[0] ? newstring(ext): NULL; d->action = action[0] ? newstring(action) : NULL; - d->image = atoi(image)!=0; + d->image = *image!=0; } -void chmenumdl(char *menu, char *mdl, char *anim, char *rotspeed, char *scale) +void chmenumdl(char *menu, char *mdl, char *anim, int *rotspeed, int *scale) { if(!menu || !menus.access(menu)) return; gmenu &m = menus[menu]; @@ -983,8 +983,8 @@ void chmenumdl(char *menu, char *mdl, char *anim, char *rotspeed, char *scale) if(!mdl ||!*mdl) return; m.mdl = newstring(mdl); m.anim = findanim(anim)|ANIM_LOOP; - m.rotspeed = max(0, min(atoi(rotspeed), 100)); - m.scale = max(0, min(atoi(scale), 100)); + m.rotspeed = clamp(*rotspeed, 0, 100); + m.scale = clamp(*scale, 0, 100); } bool parsecolor(color *col, const char *r, const char *g, const char *b, const char *a) @@ -1006,26 +1006,26 @@ void menuselectionbgcolor(char *r, char *g, char *b, char *a) parsecolor(menuselbgcolor, r, g, b, a); } -COMMAND(newmenu, ARG_3STR); -COMMAND(menumdl, ARG_5STR); -COMMAND(menudirlist, ARG_4STR); -COMMAND(chmenumdl, ARG_6STR); -COMMANDN(showmenu, showmenu_, ARG_1STR); -COMMAND(closemenu, ARG_1STR); -COMMANDN(menufont, setmenufont, ARG_1STR); -COMMANDN(menucanblink, setmenublink, ARG_1INT); -COMMAND(menuinit, ARG_1STR); -COMMAND(menuinitselection, ARG_1INT); -COMMAND(menuselection, ARG_2STR); -COMMAND(menuitem, ARG_3STR); -COMMAND(menuitemvar, ARG_3STR); -COMMAND(menuitemimage, ARG_4STR); -COMMAND(menuitemmapload, ARG_2STR); -COMMAND(menuitemtextinput, ARG_5STR); -COMMAND(menuitemslider, ARG_7STR); -COMMAND(menuitemkeyinput, ARG_2STR); -COMMAND(menuitemcheckbox, ARG_3STR); -COMMAND(menuselectionbgcolor, ARG_4STR); +COMMAND(newmenu, "sii"); +COMMAND(menumdl, "ssii"); +COMMAND(menudirlist, "sssi"); +COMMAND(chmenumdl, "sssii"); +COMMANDN(showmenu, showmenu_, "s"); +COMMAND(closemenu, "s"); +COMMANDN(menufont, setmenufont, "s"); +COMMANDN(menucanblink, setmenublink, "i"); +COMMAND(menuinit, "s"); +COMMAND(menuinitselection, "i"); +COMMAND(menuselection, "si"); +COMMAND(menuitem, "sss"); +COMMAND(menuitemvar, "sss"); +COMMAND(menuitemimage, "ssss"); +COMMAND(menuitemmapload, "ss"); +COMMAND(menuitemtextinput, "ssssi"); +COMMAND(menuitemslider, "siisiss"); +COMMAND(menuitemkeyinput, "ss"); +COMMAND(menuitemcheckbox, "sss"); +COMMAND(menuselectionbgcolor, "ssss"); bool menukey(int code, bool isdown, int unicode, SDLMod mod) { @@ -1251,7 +1251,7 @@ void gmenu::render() { extern bool ignoreblinkingbit; if(usefont) pushfont(usefont); - if(!allowblink) ignoreblinkingbit = true; + if(!allowblink) ignoreblinkingbit = true; const char *t = title; if(!t) { diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 39fbfdcc..c93590db 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -523,7 +523,7 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) pl->vel.mul(0.7f); continue; } - pl->o == oo; + pl->o = oo; } if(pl->type==ENT_CAMERA || (pl->type==ENT_PLAYER && pl->state==CS_DEAD && ((playerent *)pl)->spectatemode != SM_FLY)) { @@ -766,20 +766,20 @@ void crouch(bool on) player1->trycrouch = on; } -int inWater(int type = 0) +int inWater(int *type) { - if(hdr.waterlevel > (type ? player1->o.z : (player1->o.z - player1->eyeheight))) return 1; + if(hdr.waterlevel > (*type ? player1->o.z : (player1->o.z - player1->eyeheight))) return 1; else return 0; } -COMMAND(backward, ARG_DOWN); -COMMAND(forward, ARG_DOWN); -COMMAND(left, ARG_DOWN); -COMMAND(right, ARG_DOWN); -COMMANDN(jump, jumpn, ARG_DOWN); -COMMAND(attack, ARG_DOWN); -COMMAND(crouch, ARG_DOWN); -COMMAND(inWater, ARG_1EXP); +COMMAND(backward, "d"); +COMMAND(forward, "d"); +COMMAND(left, "d"); +COMMAND(right, "d"); +COMMANDN(jump, jumpn, "d"); +COMMAND(attack, "d"); +COMMAND(crouch, "d"); +COMMAND(inWater, "i"); void fixcamerarange(physent *cam) { @@ -917,7 +917,7 @@ void findsens() return; } } -COMMAND(findsens,ARG_NONE); +COMMAND(findsens, ""); inline bool zooming(playerent *plx) { return (plx->weaponsel->type == GUN_SNIPER && ((sniperrifle *)plx->weaponsel)->scoped); } diff --git a/source/src/protos.h b/source/src/protos.h index 358f3ac2..683928d3 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -179,7 +179,7 @@ struct gmenu }; // serverbrowser -extern void addserver(const char *servername, const char *serverport, const char *weight); +extern void addserver(const char *servername, int serverport, int weight); extern char *getservername(int n); extern bool resolverwait(const char *name, ENetAddress *address); extern int connectwithtimeout(ENetSocket sock, const char *hostname, ENetAddress &remoteaddress); @@ -360,7 +360,7 @@ extern void newteam(char *name); extern bool securemapcheck(const char *map, bool msg = true); extern int getbuildtype(); extern void sendintro(); -extern void getdemo(char *idx, char *dsp); +extern void getdemo(int *idx, char *dsp); extern void listdemos(); extern bool tryauth(const char *desc); extern authkey *findauthkey(const char *desc); @@ -444,7 +444,7 @@ extern void clearvote(); // scoreboard struct discscore { int team, flags, frags, deaths, points; char name[MAXNAMELEN + 1]; }; extern vector discscores; -extern void showscores(int on); +extern void showscores(bool on); extern void renderscores(void *menu, bool init); extern const char *asciiscores(bool destjpg = false); extern void consolescores(); @@ -778,7 +778,7 @@ extern void setfvar(const char *name, float f, bool dofunc = false); extern void setsvar(const char *name, const char *str, bool dofunc = false); extern int getvar(const char *name); extern bool identexists(const char *name); -extern bool addcommand(const char *name, void (*fun)(), int narg); +extern bool addcommand(const char *name, void (*fun)(), const char *sig); extern int execute(const char *p); extern char *executeret(const char *p); extern char *conc(char **w, int n, bool space); diff --git a/source/src/rendercubes.cpp b/source/src/rendercubes.cpp index 9bffb40d..d640113c 100644 --- a/source/src/rendercubes.cpp +++ b/source/src/rendercubes.cpp @@ -138,7 +138,7 @@ bool showm = false; void showmip() { showm = !showm; } void mipstats(int a, int b, int c) { if(showm) conoutf("1x1/2x2/4x4: %d / %d / %d", a, b, c); } -COMMAND(showmip, ARG_NONE); +COMMAND(showmip, ""); VAR(mergestrips, 0, 1, 1); diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index da232808..5543ea60 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -40,12 +40,12 @@ bool hasext(const char *exts, const char *ext) return false; } -int glext(char *ext) +void glext(char *ext) { const char *exts = (const char *)glGetString(GL_EXTENSIONS); - return hasext(exts, ext) ? 1 : 0; + intret(hasext(exts, ext) ? 1 : 0); } -COMMAND(glext, ARG_1EST); +COMMAND(glext, "s"); VAR(ati_mda_bug, 0, 0, 1); @@ -453,13 +453,13 @@ void scopefunc() } // map old fov values to new ones -void fovcompat(int oldfov) +void fovcompat(int *oldfov) { extern float aspect; - setfvar("fov", atan(tan(RAD/2.0f*oldfov/aspect)*aspect)*2.0f/RAD, true); + setfvar("fov", atan(tan(RAD/2.0f*(*oldfov)/aspect)*aspect)*2.0f/RAD, true); } -COMMAND(fovcompat, ARG_1INT); +COMMAND(fovcompat, "i"); float dynfov() { @@ -771,7 +771,7 @@ void clearminimap() minimapdirty = true; } -COMMAND(clearminimap, ARG_NONE); +COMMAND(clearminimap, ""); VARFP(minimapres, 7, 9, 10, clearminimap()); void drawminimap(int w, int h) { @@ -875,15 +875,15 @@ void cleanupgl() minimapdirty = true; } -void drawzone(char *x1, char *x2, char *y1, char *y2, char *color) +void drawzone(int *x1, int *x2, int *y1, int *y2, int *color) { - zonex1 = atoi(x1); zoney1 = atoi(y1); - zonex2 = atoi(x2); zoney2 = atoi(y2); - if(color[0]) zonecolor = ATOI(color); + zonex1 = *x1; zoney1 = *y1; + zonex2 = *x2; zoney2 = *y2; + if(*color) zonecolor = *color; else zonecolor = 0x00FF00; clearminimap(); } -COMMAND(drawzone, ARG_5STR); +COMMAND(drawzone, "iiiii"); void resetzone() { diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index f1fb3c40..fa9769e4 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -178,7 +178,7 @@ void loadcrosshair(char *c, char *name) crosshairs[n] = loadcrosshairtexture(c); } -COMMAND(loadcrosshair, ARG_2STR); +COMMAND(loadcrosshair, "ss"); void drawcrosshair(playerent *p, int n, color *c, float size) { @@ -702,7 +702,7 @@ void drawscores() string enginestateinfo = ""; void CSgetEngineState() { result(enginestateinfo); } -COMMANDN(getEngineState, CSgetEngineState, ARG_NONE); +COMMANDN(getEngineState, CSgetEngineState, ""); VARP(clockdisplay,0,0,2); VARP(dbgpos,0,0,1); diff --git a/source/src/rendermodel.cpp b/source/src/rendermodel.cpp index 565bc32d..f6949910 100644 --- a/source/src/rendermodel.cpp +++ b/source/src/rendermodel.cpp @@ -12,81 +12,81 @@ model *loadingmodel = NULL; #define checkmdl if(!loadingmodel) { conoutf("not loading a model"); return; } -void mdlcullface(int cullface) +void mdlcullface(int *cullface) { checkmdl; - loadingmodel->cullface = cullface!=0; + loadingmodel->cullface = *cullface!=0; } -COMMAND(mdlcullface, ARG_1INT); +COMMAND(mdlcullface, "i"); -void mdlvertexlight(int vertexlight) +void mdlvertexlight(int *vertexlight) { checkmdl; - loadingmodel->vertexlight = vertexlight!=0; + loadingmodel->vertexlight = *vertexlight!=0; } -COMMAND(mdlvertexlight, ARG_1INT); +COMMAND(mdlvertexlight, "i"); -void mdltranslucent(int translucency) +void mdltranslucent(int *translucency) { checkmdl; - loadingmodel->translucency = translucency/100.0f; + loadingmodel->translucency = *translucency/100.0f; } -COMMAND(mdltranslucent, ARG_1INT); +COMMAND(mdltranslucent, "i"); -void mdlalphatest(int alphatest) +void mdlalphatest(int *alphatest) { checkmdl; - loadingmodel->alphatest = alphatest/100.0f; + loadingmodel->alphatest = *alphatest/100.0f; } -COMMAND(mdlalphatest, ARG_1INT); +COMMAND(mdlalphatest, "i"); -void mdlscale(int percent) +void mdlscale(int *percent) { checkmdl; float scale = 0.3f; - if(percent>0) scale = percent/100.0f; - else if(percent<0) scale = 0.0f; + if(*percent>0) scale = *percent/100.0f; + else if(*percent<0) scale = 0.0f; loadingmodel->scale = scale; } -COMMAND(mdlscale, ARG_1INT); +COMMAND(mdlscale, "i"); -void mdltrans(char *x, char *y, char *z) +void mdltrans(float *x, float *y, float *z) { checkmdl; - loadingmodel->translate = vec(atof(x), atof(y), atof(z)); + loadingmodel->translate = vec(*x, *y, *z); } -COMMAND(mdltrans, ARG_3STR); +COMMAND(mdltrans, "fff"); -void mdlshadowdist(int dist) +void mdlshadowdist(int *dist) { checkmdl; - loadingmodel->shadowdist = dist; + loadingmodel->shadowdist = *dist; } -COMMAND(mdlshadowdist, ARG_1INT); +COMMAND(mdlshadowdist, "i"); -void mdlcachelimit(int limit) +void mdlcachelimit(int *limit) { checkmdl; - loadingmodel->cachelimit = limit; + loadingmodel->cachelimit = *limit; } -COMMAND(mdlcachelimit, ARG_1INT); +COMMAND(mdlcachelimit, "i"); vector mapmodels; -void mapmodel(char *rad, char *h, char *zoff, char *snap, char *name) +void mapmodel(int *rad, int *h, int *zoff, char *snap, char *name) { mapmodelinfo &mmi = mapmodels.add(); - mmi.rad = atoi(rad); - mmi.h = atoi(h); - mmi.zoff = atoi(zoff); + mmi.rad = *rad; + mmi.h = *h; + mmi.zoff = *zoff; formatstring(mmi.name)("mapmodels/%s", name); } @@ -97,8 +97,8 @@ void mapmodelreset() mapmodelinfo &getmminfo(int i) { return mapmodels.inrange(i) ? mapmodels[i] : *(mapmodelinfo *)0; } -COMMAND(mapmodel, ARG_5STR); -COMMAND(mapmodelreset, ARG_NONE); +COMMAND(mapmodel, "iiiss"); +COMMAND(mapmodelreset, ""); hashtable mdllookup; diff --git a/source/src/rendertext.cpp b/source/src/rendertext.cpp index 38563d2c..8046f994 100644 --- a/source/src/rendertext.cpp +++ b/source/src/rendertext.cpp @@ -11,7 +11,7 @@ font *curfont = NULL; VARP(allowblinkingtext, 0, 0, 1); // if you're so inclined -void newfont(char *name, char *tex, char *defaultw, char *defaulth, char *offsetx, char *offsety, char *offsetw, char *offseth) +void newfont(char *name, char *tex, int *defaultw, int *defaulth, int *offsetx, int *offsety, int *offsetw, int *offseth) { font *f = fonts.access(name); if(!f) @@ -23,12 +23,12 @@ void newfont(char *name, char *tex, char *defaultw, char *defaulth, char *offset f->tex = textureload(tex); f->chars.shrink(0); - f->defaultw = ATOI(defaultw); - f->defaulth = ATOI(defaulth); - f->offsetx = ATOI(offsetx); - f->offsety = ATOI(offsety); - f->offsetw = ATOI(offsetw); - f->offseth = ATOI(offseth); + f->defaultw = *defaultw; + f->defaulth = *defaulth; + f->offsetx = *offsetx; + f->offsety = *offsety; + f->offsetw = *offsetw; + f->offseth = *offseth; f->skip = 33; fontdef = f; @@ -36,27 +36,27 @@ void newfont(char *name, char *tex, char *defaultw, char *defaulth, char *offset extern GLenum texformat(int bpp); -void fontchar(int x, int y, int w, int h) +void fontchar(int *x, int *y, int *w, int *h) { if(!fontdef) return; font::charinfo &c = fontdef->chars.add(); - c.x = x; - c.y = y; - c.w = w ? w : fontdef->defaultw; - c.h = h ? h : fontdef->defaulth; + c.x = *x; + c.y = *y; + c.w = *w ? *w : fontdef->defaultw; + c.h = *h ? *h : fontdef->defaulth; } -void fontskip(int n) +void fontskip(int *n) { if(!fontdef) return; - fontdef->skip = n; + fontdef->skip = *n; } -COMMANDN(font, newfont, ARG_8STR); -COMMAND(fontchar, ARG_4INT); -COMMAND(fontskip, ARG_1INT); +COMMANDN(font, newfont, "ssiiiiii"); +COMMAND(fontchar, "iiii"); +COMMAND(fontskip, "i"); string myfont = "default"; void newsetfont(const char *name) @@ -71,7 +71,7 @@ bool setfont(const char *name) curfont = f; return true; } -COMMANDN(setfont, newsetfont, ARG_1STR); +COMMANDN(setfont, newsetfont, "s"); font *getfont(const char *name) { diff --git a/source/src/scoreboard.cpp b/source/src/scoreboard.cpp index dce86a4f..75fffc54 100644 --- a/source/src/scoreboard.cpp +++ b/source/src/scoreboard.cpp @@ -5,13 +5,13 @@ void *scoremenu = NULL; -void showscores(int on) +void showscores(bool on) { if(on) showmenu("score", false); else closemenu("score"); } -COMMAND(showscores, ARG_1INT); +COMMANDF(showscores, "i", (int *on) { showscores(*on != 0); }); struct sline { @@ -543,4 +543,4 @@ void winners() result(winners); } -COMMAND(winners, ARG_NONE); +COMMAND(winners, ""); diff --git a/source/src/server.cpp b/source/src/server.cpp index a5244b5f..479dce4a 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -3469,10 +3469,8 @@ void process(ENetPacket *packet, int sender, int chan) } vi->owner = sender; vi->callmillis = servmillis; - logline(ACLOG_INFO, "pre packet"); MSG_PACKET(msg); if(!scallvote(vi, msg)) delete vi; - logline(ACLOG_INFO, "post scallvote"); break; } diff --git a/source/src/serverbrowser.cpp b/source/src/serverbrowser.cpp index 1789e72d..eafd6e99 100644 --- a/source/src/serverbrowser.cpp +++ b/source/src/serverbrowser.cpp @@ -321,14 +321,13 @@ static serverinfo *newserver(const char *name, uint ip = ENET_HOST_ANY, int port return si; } -void addserver(const char *servername, const char *serverport, const char *weight) +void addserver(const char *servername, int serverport, int weight) { - int port = atoi(serverport); - if(port == 0) port = CUBE_DEFAULT_SERVER_PORT; + if(serverport <= 0) serverport = CUBE_DEFAULT_SERVER_PORT; - loopv(servers) if(strcmp(servers[i]->name, servername)==0 && servers[i]->port == port) return; + loopv(servers) if(strcmp(servers[i]->name, servername)==0 && servers[i]->port == serverport) return; - newserver(servername, ENET_HOST_ANY, port, weight ? atoi(weight) : 0); + newserver(servername, ENET_HOST_ANY, serverport, weight); } VARP(servpingrate, 1000, 5000, 60000); @@ -738,7 +737,7 @@ void searchnickname(const char *name) strtoupper(cursearchuc); showmenu("search"); } -COMMAND(searchnickname, ARG_1STR); +COMMAND(searchnickname, "s"); VAR(showallservers, 0, 1, 1); @@ -924,8 +923,8 @@ bool assignserverfavourites() return res; } -COMMAND(addfavcategory, ARG_1STR); -COMMAND(listfavcats, ARG_NONE); +COMMAND(addfavcategory, "s"); +COMMAND(listfavcats, ""); static serverinfo *lastselectedserver = NULL; static bool pinglastselected = false; @@ -1352,28 +1351,23 @@ void updatefrommaster(int force) { // preserve currently connected server from deletion serverinfo *curserver = getconnectedserverinfo(); - string curname, curport, curweight; - if(curserver) - { - copystring(curname, curserver->name); - formatstring(curport)("%d", curserver->port); - formatstring(curweight)("%d", curserver->msweight); - } + string curname; + if(curserver) copystring(curname, curserver->name); clearservers(); - if ( !strncmp(data.getbuf(), "addserver", 9) ) cllock = false; // the ms could reply other thing... but currently, this is useless - if ( !cllock ) + if(!strncmp(data.getbuf(), "addserver", 9)) cllock = false; // the ms could reply other thing... but currently, this is useless + if(!cllock ) { execute(data.getbuf()); - if(curserver) addserver(curname, curport, curweight); + if(curserver) addserver(curname, curserver->port, curserver->msweight); } lastupdate = totalmillis; } } -COMMAND(addserver, ARG_3STR); -COMMAND(clearservers, ARG_NONE); -COMMAND(updatefrommaster, ARG_1INT); +COMMANDF(addserver, "sii", (char *n, int *p, int *w) { addserver(n, *p, *w); }); +COMMAND(clearservers, ""); +COMMANDF(updatefrommaster, "i", (int *f) { updatefrommaster(*f); }); void writeservercfg() { diff --git a/source/src/sound.h b/source/src/sound.h index 4f374854..347ddfd9 100644 --- a/source/src/sound.h +++ b/source/src/sound.h @@ -408,7 +408,7 @@ public: void stopsound(); // music handling - void music(char *name, char *millis, char *cmd); + void music(char *name, int millis, char *cmd); void musicpreload(int id); void musicsuggest(int id, int millis, bool rndofs); void musicfadeout(int id); diff --git a/source/src/texture.cpp b/source/src/texture.cpp index 16a1441e..225ddf9f 100644 --- a/source/src/texture.cpp +++ b/source/src/texture.cpp @@ -489,14 +489,13 @@ void texture(char *scale, char *name) Slot &s = slots.add(); copystring(s.name, name); path(s.name); - float sc = atof(scale); s.tex = NULL; s.loaded = false; - s.scale = (sc > 0 && sc <= 2.0f) ? sc : 1.0f; + s.scale = (*scale > 0 && *scale <= 2.0f) ? *scale : 1.0f; } -COMMAND(texturereset, ARG_NONE); -COMMAND(texture, ARG_2STR); +COMMAND(texturereset, ""); +COMMAND(texture, "fs"); Texture *lookuptexture(int tex, Texture *failtex) { @@ -559,7 +558,7 @@ void loadsky(char *basename) } } -COMMAND(loadsky, ARG_1STR); +COMMAND(loadsky, "s"); void loadnotexture(char *c) { @@ -571,7 +570,7 @@ void loadnotexture(char *c) if(noworldtexture==notexture) conoutf("could not load alternative texture '%s'.", p); } } -COMMAND(loadnotexture, ARG_1STR); +COMMAND(loadnotexture, "s"); void draw_envbox_face(float s0, float t0, float x0, float y0, float z0, float s1, float t1, float x1, float y1, float z1, diff --git a/source/src/water.cpp b/source/src/water.cpp index 0d6385f1..7e59a85c 100644 --- a/source/src/water.cpp +++ b/source/src/water.cpp @@ -24,7 +24,7 @@ void setwatercolor(const char *r, const char *g, const char *b, const char *a) } } -COMMANDN(watercolour, setwatercolor, ARG_4STR); +COMMANDN(watercolour, setwatercolor, "ssss"); FVAR(waveheight, 0, 0.3f, 1.0f); // renders water for bounding rect area that contains water... simple but very inefficient diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index e3fb290f..723cfec6 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -57,16 +57,16 @@ void selectweapon(weapon *w) } } -void requestweapon(int w) +void requestweapon(int *w) { - if(keypressed && player1->state == CS_ALIVE && w >= 0 && w < NUMGUNS ) + if(keypressed && player1->state == CS_ALIVE && *w >= 0 && *w < NUMGUNS ) { - if (player1->akimbo && w==GUN_PISTOL) w = GUN_AKIMBO; - selectweapon(player1->weapons[w]); + if (player1->akimbo && *w==GUN_PISTOL) *w = GUN_AKIMBO; + selectweapon(player1->weapons[*w]); } } -void shiftweapon(int s) +void shiftweapon(int *s) { if(keypressed && player1->state == CS_ALIVE) { @@ -100,7 +100,7 @@ void shiftweapon(int s) int num = availweapons.length(); int curidx = availweapons.find(curweapon); if(!num || curidx<0) return; - int idx = (curidx+s) % num; + int idx = (curidx + *s) % num; if(idx<0) idx += num; weapon *next = availweapons[idx]; if(next->type!=player1->weaponsel->type) // different weapon @@ -108,7 +108,7 @@ void shiftweapon(int s) selectweapon(next); } } - else if(player1->isspectating()) updatefollowplayer(s); + else if(player1->isspectating()) updatefollowplayer(*s); } bool quicknade = false, nadeattack = false; @@ -132,21 +132,21 @@ void quicknadethrow(bool on) } } -int currentprimary() { return player1->primweap->type; } -int prevweapon() { return player1->prevweaponsel->type; } -int curweapon() { return player1->weaponsel->type; } +void currentprimary() { intret(player1->primweap->type); } +void prevweapon() { intret(player1->prevweaponsel->type); } +void curweapon() { intret(player1->weaponsel->type); } -int magcontent(int w) { if(w >= 0 && w < NUMGUNS) return player1->weapons[w]->mag; else return -1;} -int magreserve(int w) { if(w >= 0 && w < NUMGUNS) return player1->weapons[w]->ammo; else return -1;} +void magcontent(int *w) { if(*w >= 0 && *w < NUMGUNS) intret(player1->weapons[*w]->mag); else intret(-1); } +void magreserve(int *w) { if(*w >= 0 && *w < NUMGUNS) intret(player1->weapons[*w]->ammo); else intret(-1); } -COMMANDN(weapon, requestweapon, ARG_1INT); -COMMAND(shiftweapon, ARG_1INT); -COMMAND(quicknadethrow, ARG_DOWN); -COMMAND(currentprimary, ARG_IVAL); -COMMAND(prevweapon, ARG_IVAL); -COMMAND(curweapon, ARG_IVAL); -COMMAND(magcontent, ARG_1EXP); -COMMAND(magreserve, ARG_1EXP); +COMMANDN(weapon, requestweapon, "i"); +COMMAND(shiftweapon, "i"); +COMMAND(quicknadethrow, "d"); +COMMAND(currentprimary, ""); +COMMAND(prevweapon, ""); +COMMAND(curweapon, ""); +COMMAND(magcontent, "i"); +COMMAND(magreserve, "i"); void tryreload(playerent *p) { @@ -155,7 +155,7 @@ void tryreload(playerent *p) } void selfreload() { tryreload(player1); } -COMMANDN(reload, selfreload, ARG_NONE); +COMMANDN(reload, selfreload, ""); void createrays(vec &from, vec &to) // create random spread of rays for the shotgun { @@ -727,7 +727,7 @@ void accuracyreset() } conoutf(_("Your accuracy has been reset.")); } -COMMAND(accuracyreset,ARG_NONE); +COMMAND(accuracyreset, ""); // weapon weapon::weapon(class playerent *owner, int type) : type(type), owner(owner), info(guns[type]), @@ -1441,7 +1441,7 @@ void setburst(bool enable) } } -COMMAND(setburst, ARG_DOWN); +COMMAND(setburst, "d"); // pistol @@ -1555,7 +1555,7 @@ void setscope(bool enable) sr->setscope(enable); } -COMMAND(setscope, ARG_1INT); +COMMANDF(setscope, "i", (int *on) { setscope(*on != 0); }); void shoot(playerent *p, vec &targ) diff --git a/source/src/wizard.cpp b/source/src/wizard.cpp index 603e81e8..d96a19a8 100644 --- a/source/src/wizard.cpp +++ b/source/src/wizard.cpp @@ -129,7 +129,7 @@ int wizardmain(int argc, char **argv) printf("Installing the AC Server as windows service ... "); fflush(stdout); vector path; - databuf cwd = path.reserve(MAX_PATH); + databuf cwd = path.reserve(MAX_PATH); if(!_getcwd(cwd.buf, MAX_PATH)) { printf("Failed!\n"); diff --git a/source/src/world.cpp b/source/src/world.cpp index 44731e5a..2aa33879 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -125,8 +125,8 @@ void closestenttype(char *what) clenttype = what[0] ? findtype(what) : NOTUSED; } -COMMAND(nextclosestent, ARG_NONE); -COMMAND(closestenttype, ARG_1STR); +COMMAND(nextclosestent, ""); +COMMAND(closestenttype, "s"); int closestent() // used for delent and edit mode ent display { @@ -200,21 +200,21 @@ void getenttype() result(entnames[type]); } -int getentattr(int attr) +void getentattr(int *attr) { int e = closestent(); - if(e>=0) switch(attr) + if(e>=0) switch(*attr) { - case 0: return ents[e].attr1; - case 1: return ents[e].attr2; - case 2: return ents[e].attr3; - case 3: return ents[e].attr4; + case 0: intret(ents[e].attr1); return; + case 1: intret(ents[e].attr2); return; + case 2: intret(ents[e].attr3); return; + case 3: intret(ents[e].attr4); return; } - return 0; + intret(0); } -COMMAND(getenttype, ARG_NONE); -COMMAND(getentattr, ARG_1EXP); +COMMAND(getenttype, ""); +COMMAND(getentattr, "i"); void delent() { @@ -285,17 +285,17 @@ entity *newentity(int index, int x, int y, int z, char *what, int v1, int v2, in return index<0 ? &ents.last() : &ents[index]; } -void entset(char *what, char *a1, char *a2, char *a3, char *a4) +void entset(char *what, int *a1, int *a2, int *a3, int *a4) { int n = closestent(); if(n>=0) { entity &e = ents[n]; - newentity(n, e.x, e.y, e.z, what, ATOI(a1), ATOI(a2), ATOI(a3), ATOI(a4)); + newentity(n, e.x, e.y, e.z, what, *a1, *a2, *a3, *a4); } } -COMMAND(entset, ARG_5STR); +COMMAND(entset, "siiii"); void clearents(char *name) { @@ -312,7 +312,7 @@ void clearents(char *name) } } -COMMAND(clearents, ARG_1STR); +COMMAND(clearents, "s"); void scalecomp(uchar &c, int intens) { @@ -340,7 +340,7 @@ void scalelights(int f, int intens) calclight(); } -COMMAND(scalelights, ARG_2INT); +COMMANDF(scalelights, "ii", (int *f, int *i) { scalelights(*f, *i); }); int findentity(int type, int index) { @@ -356,12 +356,12 @@ int findentity(int type, int index, uchar attr2) return -1; } -void nextplayerstart(char *type) +void nextplayerstart(int *type) { static int cycle = -1; if(noteditmode("nextplayerstart")) return; - cycle = type[0] ? findentity(PLAYERSTART, cycle + 1, atoi(type)) : findentity(PLAYERSTART, cycle + 1); + cycle = findentity(PLAYERSTART, cycle + 1, *type); if(cycle >= 0) { entity &e = ents[cycle]; @@ -375,7 +375,7 @@ void nextplayerstart(char *type) } } -COMMAND(nextplayerstart, ARG_1STR); +COMMAND(nextplayerstart, "i"); sqr *wmip[LARGEST_FACTOR*2]; @@ -506,21 +506,21 @@ bool empty_world(int factor, bool force) // main empty world creation routine void mapenlarge() { if(empty_world(-1, false)) addmsg(SV_NEWMAP, "ri", -1); } void mapshrink() { if(empty_world(-2, false)) addmsg(SV_NEWMAP, "ri", -2); } -void newmap(int i) +void newmap(int *i) { - if(empty_world(i, false)) + if(empty_world(*i, false)) { - addmsg(SV_NEWMAP, "ri", max(i, 0)); + addmsg(SV_NEWMAP, "ri", max(*i, 0)); if(identexists("onNewMap")) execute("onNewMap"); } defformatstring(startmillis)("%d", millis_()); alias("gametimestart", startmillis); } -COMMAND(mapenlarge, ARG_NONE); -COMMAND(mapshrink, ARG_NONE); -COMMAND(newmap, ARG_1INT); -COMMANDN(recalc, calclight, ARG_NONE); -COMMAND(delent, ARG_NONE); -COMMAND(entproperty, ARG_2INT); +COMMAND(mapenlarge, ""); +COMMAND(mapshrink, ""); +COMMAND(newmap, "i"); +COMMANDN(recalc, calclight, ""); +COMMAND(delent, ""); +COMMANDF(entproperty, "ii", (int *p, int *a) { entproperty(*p, *a); }); diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index 5929e374..e5396927 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -375,9 +375,8 @@ void checkmapdependencies(bool silent = false, bool details = false) // find req enumeratek(mufpaths, const char *, key, mufpaths.remove(key)); // don't report false positives next time round delete[] packn; } -void wrapCMD(int i) { checkmapdependencies(false, i!=0); } -//COMMAND(checkmapdependencies, ARG_NONE); // for some reason this still results in silent==true - WTF? It used to work with the _proper_ default. -COMMANDN(checkmapdependencies, wrapCMD, ARG_1INT); + +COMMANDF(checkmapdependencies, "i", (int *i) { checkmapdependencies(false, *i!=0); }); VARP(mapbackupsonsave, 0, 1, 1); @@ -480,7 +479,7 @@ void showmapdims() conoutf(" max X|Y|Z: %3d : %3d : %3d", mapdims[2], mapdims[3], mapdims[7]); conoutf("delta X|Y|Z: %3d : %3d : %3d", mapdims[4], mapdims[5], mapdims[7]-mapdims[6]); } -COMMAND(showmapdims, ARG_NONE); +COMMAND(showmapdims, ""); extern void preparectf(bool cleanonly = false); int numspawn[3], maploaded = 0, numflagspawn[2]; @@ -720,11 +719,10 @@ bool load_world(char *mname) // still supports all map formats that have return true; } -COMMANDN(savemap, save_world, ARG_1STR); +COMMANDN(savemap, save_world, "s"); // FIXME - remove this before release -void setmaprevision(int rev) { hdr.maprevision = rev; } -COMMAND(setmaprevision, ARG_1INT); +COMMANDF(setmaprevision, "i", (int *rev) { hdr.maprevision = *rev; }); #define MAPDEPFILENAME "mapdependencies.txt" void listmapdependencies(char *mapname) // print map dependencies to file @@ -856,11 +854,11 @@ void listmapdependencies(char *mapname) // print map dependencies to file delete f; } -COMMAND(listmapdependencies, ARG_1STR); +COMMAND(listmapdependencies, "s"); -void listmapdependencies_all(int sure) +void listmapdependencies_all(int *sure) { - if(sure != 42 || multiplayer()) return; + if(*sure != 42 || multiplayer()) return; stream *f = openfile(MAPDEPFILENAME, "w"); delete f; @@ -872,4 +870,4 @@ void listmapdependencies_all(int sure) loopv(files) listmapdependencies(files[i]); listmapdependencies(NULL); } -COMMAND(listmapdependencies_all, ARG_1INT); +COMMAND(listmapdependencies_all, "i"); diff --git a/source/src/worldocull.cpp b/source/src/worldocull.cpp index 04bc0b08..70821559 100644 --- a/source/src/worldocull.cpp +++ b/source/src/worldocull.cpp @@ -10,7 +10,7 @@ float odist = 256; void toggleocull() { ocull = !ocull; } -COMMAND(toggleocull, ARG_NONE); +COMMAND(toggleocull, ""); // constructs occlusion map: cast rays in all directions on the 2d plane and record distance. // done exactly once per frame. diff --git a/source/src/zip.cpp b/source/src/zip.cpp index 1e7ded46..c9ff1769 100644 --- a/source/src/zip.cpp +++ b/source/src/zip.cpp @@ -563,7 +563,7 @@ int listzipfiles(const char *dir, const char *ext, vector &files) } #ifndef STANDALONE -COMMANDF(addzip, ARG_3STR, (const char *name, const char *mount, const char *strip) { addzip(name, mount[0] ? mount : NULL, strip[0] ? strip : NULL); }); -COMMANDF(removezip, ARG_1STR, (const char *name) { removezip(name); }); +COMMANDF(addzip, "sss", (const char *name, const char *mount, const char *strip) { addzip(name, mount[0] ? mount : NULL, strip[0] ? strip : NULL); }); +COMMANDF(removezip, "s", (const char *name) { removezip(name); }); #endif