int main(int argc, char **argv) { if( argc != 2 || strcmp(argv[1], "-DoIt") != 0 ){ fprintf(stderr, "警告! initbbs只用在「第一次安裝」的時候.\n" "若您的站台已經上線, initbbs將會破壞掉原有資料!\n\n" "將把 BBS 安裝在 " BBSHOME "\n\n" "確定要執行, 請使用 initbbs -DoIt\n"); return 1; } if(chdir(BBSHOME)) { perror(BBSHOME); exit(1); } initDir(); initHome(); initBoardsDIR(); initManDIR(); initPasswds(); initBoards(); initMan(); initSymLink(); initHistory(); return 0; }
void testNavigate(){ int check, nextX, nextY; initDir(); //start by getting the initial direction solution = createStack(); push(solution, current); // add the starting square to the stack while (current->val != 'F'){ // the maze sloving loop printf("current position: (%d, %d)\ncurrent direction: %c\n",current->x, current->y,dir); switch(dir){ case 'n': check = checkUp(); nextX = current->x; nextY = current->y - 1; break; case 's': check = checkDown(); nextX = current->x; nextY = current->y + 1; break; case 'e': check = checkRight(); nextX = current->x + 1; nextY = current->y; break; case 'w': check = checkLeft(); nextX = current->x - 1; nextY = current->y; break; } if (check == 1){ // if you can move, the next space is not a wall printf("the square ahead is not a wall!\n"); if (maze[nextX][nextY]->wasHere == 1){ //we have been there already printf("we have been here before!\n"); if (otherOptions(nextX, nextY) == 1){ // there are other options printf("we have other options, lets turn\n"); changeDir(); printf("new direction: %c\n",dir); } else { // no other options will need to go back to where we have been printf("we have no other options we must go this way\n"); pop(solution); // pop from stack current->deadEnd = 1; current = maze[nextX][nextY]; // move } } else { printf("we have not been here before, lets go!\n"); current = maze[nextX][nextY]; // move current-> wasHere = 1; push(solution, current); // add to stack } } else { printf("the square ahead is a wall, we must change directions\n"); changeDir(); printf("new direction: %c\n",dir); } char c = getchar(); } }
//------------------------------------------------------------------------------ void Console::init() { new Logger(); initCmdHistory(); initArghandler(); initCommand(); initDir(); initConoslePattern(); }
void navigate(){ int check, nextX, nextY; initDir(); //start by getting the initial direction solution = createStack(); push(solution, current); // add the starting square to the stack while (current->val != 'F'){ // the maze sloving loop switch(dir){ case 'n': check = checkUp(); nextX = current->x; nextY = current->y - 1; break; case 's': check = checkDown(); nextX = current->x; nextY = current->y + 1; break; case 'e': check = checkRight(); nextX = current->x + 1; nextY = current->y; break; case 'w': check = checkLeft(); nextX = current->x - 1; nextY = current->y; break; } if (check == 1){ // if you can move, the next space is not a wall if (maze[nextX][nextY]->wasHere == 1){ //we have been there already if (otherOptions(nextX, nextY) == 1){ // there are other options changeDir(); } else { // no other options will need to go back to where we have been pop(solution); // pop from stack current->deadEnd = 1; current = maze[nextX][nextY]; // move } } else { current = maze[nextX][nextY]; // move current-> wasHere = 1; push(solution, current); // add to stack } } else { changeDir(); } } }