Strange complier error in simple RPG

This is a discussion on Strange complier error in simple RPG within the Game Programming forums, part of the General Programming Boards category; I am doing a simple RPG game, but everytime I compile it it gives me this strange error: RPG fatal ...

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    118

    Strange complier error in simple RPG

    I am doing a simple RPG game, but everytime I compile it it gives me this strange error:
    RPG fatal error LNK1201: error writing to program database 'c:\Carlos Documents and Settings\Carlos Documents\Visual Studio Projects\RPG\Debug\RPG.pdb'; check for insufficient disk space, invalid path, or insufficient privilege

    I have about 1 GB of free space in my hard disk, it is the right path, but I dont know what it means by insufficient privilage...
    Anyways, here is my code:
    Code:
    #include <ctime>
    #include <iostream>
    #include <conio.h>
    using namespace std;
    
    struct ENTITY
    {
    	int HP;
    	int DEF;
    	int ATTCK;
    	int SPEED;
    	int EXP;
    };
    
    int PlayerLVL = 1;
    int MonsterLVL = 1;
    ENTITY Player;
    ENTITY Monster;
    
    void DisplayStats(ENTITY Player, ENTITY Monster, int PlayerLVL, int MonsterLVL); // to check variables are set right
    
    void PlayerR(ENTITY &Player, int PlayerLVL);
    
    void MonsterR(ENTITY &Monster, int MonsterLVL);
    
    int RollDice(int DiceSides);
    
    void Battle(ENTITY &Player, ENTITY &Monster, int PlayerLVL, int MonsterLVL);
    
    int main()
    {
    	float round = 0;
    	char Option = ' ';
    
    	Player.EXP = 0;
    	Monster.EXP = 0;
    
    	while (1)
    	{
    		PlayerR(Player, PlayerLVL);
    		MonsterR(Monster, MonsterLVL);
    
    		Battle(Player, Monster, PlayerLVL, MonsterLVL);
    
    		cout << "Press \"q\" to quit. Any other key to continue." << endl;
    		Option = getch();
    
    		if (Option == 'q' || Option == 'Q')
    			break;
    
    		if (Player.EXP > (20 * round/3))
    		{
    			PlayerLVL++;
    			Player.EXP = 0;
    			cout << "You grew a level! You are now at level " << PlayerLVL << "!" << endl;
    			getch();
    		}
    		round++;
    	}
    
    	return 0;
    }
    
    void DisplayStats(ENTITY Player, ENTITY Monster, int PlayerLVL, int MonsterLVL)
    {
    	cout << "Player: " << PlayerLVL << endl;
    	cout << "HP: " << Player.HP << endl;
    	cout << "DEF: " << Player.DEF << endl;
    	cout << "ATTCK: " << Player.ATTCK << endl;
    	cout << "SPEED: " << Player.SPEED << endl;
    	cout << endl;
    	cout << "Monster: " << MonsterLVL << endl;
    	cout << "HP: " << Monster.HP << endl;
    	cout << "DEF: " << Monster.DEF << endl;
    	cout << "ATTCK: " << Monster.ATTCK << endl;
    	cout << "SPEED: " << Monster.SPEED << endl;
    	cout << endl;
    }
    
    void PlayerR(ENTITY &Player, int PlayerLVL)
    {
    	Player.HP = 20 * PlayerLVL;
    	Player.DEF = 3 * PlayerLVL;
    	Player.ATTCK = 5 * PlayerLVL;
    	Player.SPEED = 5 * PlayerLVL;
    }
    
    void MonsterR(ENTITY &Monster, int MonsterLVL)
    {
    	Monster.HP = 25 * MonsterLVL;
    	Monster.DEF = 1 * MonsterLVL;
    	Monster.ATTCK = 5 * MonsterLVL;
    	Monster.SPEED = 6 * MonsterLVL;
    }
    
    int RollDice(int DiceSides)
    {
    	srand((unsigned) time(NULL));
    	int Roll = rand() % (DiceSides + 1);
    
    	return Roll;
    }
    
    void Battle(ENTITY &Player, ENTITY &Monster, int PlayerLVL, int MonsterLVL)
    {
    	bool PFirst = true;
    	int Roll1 = 0;
    	int Roll2 = 0;
    
    	Roll1 = RollDice(10);
    	Roll2 = RollDice(10);
    
    	if ((Player.SPEED + Roll1) > (Monster.SPEED + Roll2))
    		PFirst = true;
    
    	else
    		PFirst = false;
    
    	do
    	{
    		if (PFirst)
    		{
    			system("cls");
    			DisplayStats(Player, Monster, PlayerLVL, MonsterLVL);
    			
    			cout << "You have attacked the monster!" << endl;
    
    			Monster.HP -= (Player.ATTCK - Monster.DEF);
    			PFirst = false;
    
    			getch();
    		}
    
    		else
    		{
    			system("cls");
    			DisplayStats(Player, Monster, PlayerLVL, MonsterLVL);
    
    			cout << "You have been attacked by the monster!" << endl;
    
    			Player.HP -= (Monster.ATTCK - Player.DEF);
    			PFirst = true;
    
    			getch();
    		}
    	} while (Player.HP > 0 && Monster.HP > 0);
    	
    	if (Player.HP > 0)
    	{
    		cout << "You killed the monster!" << endl;
    		Player.EXP += 10 * MonsterLVL;
    	}
    	else
    		cout << "The battle is over... " << endl;
    }
    Thanks in advance.
    Why drink and drive when you can smoke and fly?

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    What OS are you using? If you're using 2000/XP, try logging in as an admin.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    118
    Thnks a lot, logging in as an admin worked.
    Now I just noticed the function RollDice always returns 9, why is that?

    [EDIT]
    Actually, every time I compile, Roll1 and Roll2 have the same value, I even changed it and they are always the same.
    This is the changed code:
    Code:
    int RollDice(int DiceSides, int &ROLL)
    {
    	if (ROLL == 0)
    	{
    		srand((unsigned) time(NULL));
    		
    		return (rand() % (DiceSides + 1));
    		ROLL++;
    	}
    
    	else
    	{
    		srand((unsigned) GetTickCount());
    
    		return (rand() % (DiceSides + 1));
    		ROLL--;
    	}
    }
    Last edited by Marcos; 03-26-2003 at 04:21 PM.
    Why drink and drive when you can smoke and fly?

  4. #4
    The Pantless Man CheesyMoo's Avatar
    Join Date
    Jan 2003
    Posts
    262
    I don't know what you're doing but if you inclued windows.h you can do this to seed:
    Code:
    // bla bla bla
    
    #include <windows.h>
    
    srand(gettickcount());
    int wang = rand();
    cout << "COOL RANDOM NUMBERS!" << wang << endl;

    Edit-
    What I mean is I don't know what you're doing to seed. If it's always the same I guess it doensn't work, so try that.
    Last edited by CheesyMoo; 03-26-2003 at 08:37 PM.
    If you ever need a hug, just ask.

  5. #5
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Only call srand( ) once, at the start of main. It will lose its randomness if you call it everytime you generate a number.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strange Simple Error
    By jordanguyoflove in forum C Programming
    Replies: 5
    Last Post: 01-20-2009, 05:58 AM
  2. A simple but strange code of malloc()
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 03-31-2008, 04:58 AM
  3. Strange results using dnsapi and windns
    By Niara in forum Networking/Device Communication
    Replies: 3
    Last Post: 08-13-2005, 10:21 AM
  4. simple error or strange compiler?
    By threahdead in forum C Programming
    Replies: 6
    Last Post: 01-20-2003, 02:00 PM
  5. Strange vc++ complier error
    By Unregistered in forum Windows Programming
    Replies: 3
    Last Post: 08-18-2002, 01:35 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21