Example #1
0
CTown::CTown(int i, int reg, Point pos, eTownType resname)
{
	owner = 0;
	selected = 0;
	objectType = "town";
	id = i;
	position = Rect(pos, Size(30, 30));
	type = resname;
	region = reg;
	name = "Miasto";
	smokeTimer = rand() % 500 / 200.0f;

	setStat("got_image", 1);
	setStat("base_points", rand() % 100 + 10);

	setStat("slider0", 0.25);
	setStat("slider1", 0.25);
	setStat("slider2", 0.25);
	setStat("slider3", 0.25);

	setStat("slider0_aim", 0.25);
	setStat("slider1_aim", 0.25);
	setStat("slider2_aim", 0.25);
	setStat("slider3_aim", 0.25);

}
Example #2
0
void LLViewerStats::updateFrameStats(const F64 time_diff)
{
	if (mPacketsLostPercentStat.getCurrent() > 5.0)
	{
		incStat(LLViewerStats::ST_LOSS_05_SECONDS, time_diff);
	}
	
	if (mSimFPS.getCurrent() < 20.f && mSimFPS.getCurrent() > 0.f)
	{
		incStat(LLViewerStats::ST_SIM_FPS_20_SECONDS, time_diff);
	}
	
	if (mSimPhysicsFPS.getCurrent() < 20.f && mSimPhysicsFPS.getCurrent() > 0.f)
	{
		incStat(LLViewerStats::ST_PHYS_FPS_20_SECONDS, time_diff);
	}
		
	if (time_diff >= 0.5)
	{
		incStat(LLViewerStats::ST_FPS_2_SECONDS, time_diff);
	}
	if (time_diff >= 0.125)
	{
		incStat(LLViewerStats::ST_FPS_8_SECONDS, time_diff);
	}
	if (time_diff >= 0.1)
	{
		incStat(LLViewerStats::ST_FPS_10_SECONDS, time_diff);
	}

	if (gFrameCount && mLastTimeDiff > 0.0)
	{
		// new "stutter" meter
		setStat(LLViewerStats::ST_FPS_DROP_50_RATIO,
				(getStat(LLViewerStats::ST_FPS_DROP_50_RATIO) * (F64)(gFrameCount - 1) + 
				 (time_diff >= 2.0 * mLastTimeDiff ? 1.0 : 0.0)) / gFrameCount);
			

		// old stats that were never really used
		setStat(LLViewerStats::ST_FRAMETIME_JITTER,
				(getStat(LLViewerStats::ST_FRAMETIME_JITTER) * (gFrameCount - 1) + 
				 fabs(mLastTimeDiff - time_diff) / mLastTimeDiff) / gFrameCount);
			
		F32 average_frametime = gRenderStartTime.getElapsedTimeF32() / (F32)gFrameCount;
		setStat(LLViewerStats::ST_FRAMETIME_SLEW,
				(getStat(LLViewerStats::ST_FRAMETIME_SLEW) * (gFrameCount - 1) + 
				 fabs(average_frametime - time_diff) / average_frametime) / gFrameCount);

		F32 max_bandwidth = gViewerThrottle.getMaxBandwidth();
		F32 delta_bandwidth = gViewerThrottle.getCurrentBandwidth() - max_bandwidth;
		setStat(LLViewerStats::ST_DELTA_BANDWIDTH, delta_bandwidth / 1024.f);

		setStat(LLViewerStats::ST_MAX_BANDWIDTH, max_bandwidth / 1024.f);
		
	}
	
	mLastTimeDiff = time_diff;

}
Example #3
0
void CTown::update()
{


	smokeTimer += CTimer::dt * 3;

	for (int a = 0; a<4; a++)
	{
		if (getSliderAim((eTownSlider)a)>getSlider((eTownSlider)a))
			setStat("slider" + IntToStr(a), getSlider((eTownSlider)a) + 0.01*CTimer::dt);

		if (getSliderAim((eTownSlider)a) < getSlider((eTownSlider)a))
			setStat("slider" + IntToStr(a), getSlider((eTownSlider)a) - 0.01*CTimer::dt);

	}

	bool fu = 0, fb = 0;
	for (int a = 0; a < townOrders.size(); a++)
	{
		double prog = getMap()->getDeltaTime();

		if (townOrders[a].unit == -1)
		{
			if (!fb)
				townOrders[a].progress += prog, fb = 1;
		}
		else if (!fu)
		{
			fu = 1;
			townOrders[a].progress += prog*double(getAttrib("trainingTime"));
			townOrders[a].morale += getAttrib("baseMorale")*CUnit::getUnit(getOwner(), townOrders[a].unit).getStat("baseMorale")*prog / townOrders[a].costs[(int)RES_TIME];
		}


		if (townOrders[a].progress > townOrders[a].costs[(int)RES_TIME])
		{
			if (townOrders[a].unit == -1)
				addBuild(townOrders[a].build, 1);
			else
			{
				CUnit unit = CUnit::getUnit(getOwner(), townOrders[a].unit);
				unit.setStat("morale", townOrders[a].morale);
				std::vector<int> armies;
				CArmy::getArmiesInPoint(getCenter(), 20, armies);
				CArmy* a;
				if (armies.size() == 0)
					a = getMap()->addArmy(getCenter(), getOwner());
				else
					a = getMap()->getArmy(armies[0]);
				a->addUnit(&unit);

			}


			townOrders.erase(townOrders.begin() + a); a--;
		}
	}

}
void Opcode80CBHandler::_run()
{
    Logger::debug("SCRIPT") << "[80CB] [+] int set_critter_stat(GameCritterObject* who, int number, int value)" << std::endl;
    int value = _vm->dataStack()->popInteger();
    int number = _vm->dataStack()->popInteger();
    if (number > 6)
    {
        _error("set_critter_stat - number out of range:" + std::to_string(number));
    }
    auto object = _vm->dataStack()->popObject();
    if (!object) 
    {
        _error("set_critter_stat(who, num, value) - who is null");
    }
    auto critter = dynamic_cast<Game::CritterObject*>(object);
    if (!critter)
    {
        _error("set_critter_stat(who, num, value) - who is not a critter");
    }
    critter->setStat((STAT)number, value);
    if (dynamic_cast<Game::DudeObject*>(critter))
    {
        _vm->dataStack()->push(3); // for dude
    }
    else
    {
        _vm->dataStack()->push(-1); // for critter
    }
}
Example #5
0
/**
 * Function: memoryStage
 * This driver function updates the values in writebackStage
 */
void memoryStage(forwardType * forward, statusType * status, bubbleType * bubble) {
    unsigned int valM;
    unsigned int valE;
    bool memError = FALSE;
    valE = memAddr();
    valM = memCond(valE,&memError);
    if(!memRead())
        valM = 0;
    //Forwarding from memoryStage
    (*forward).m_valM = valM;
    (*forward).M_valE = M.valE;

    (*forward).M_dstE = M.dstE;
    (*forward).M_dstM = M.dstM;
    (*forward).M_Cnd = M.Cnd; 
    (*forward).M_icode = M.icode;
    (*forward).M_valA = M.valA;
    unsigned int mStat;
    mStat = setStat(memError);
    //Updating stat in the statusType struct
    //and the bubbleType struct
    (*status).m_stat = mStat;
    (*bubble).M_icode = M.icode;
    if(!(W_stall(*bubble,*status)))
        updateWStage(mStat,M.icode,M.valE,valM,M.dstE,M.dstM);
}
//Creates the text representation of myuiscreen by using ASCII art.
void setup() {                    //print using myui (stat)
  xt_par0(XT_CLEAR_SCREEN);
  setStat();
  xt_par2(XT_SET_ROW_COL_POS, row = 1, col = 1);
  xt_par0(XT_CH_GREEN);
  printf("-------------------------------------------------------LifeTracker------------------------------------------------------");
  xt_par0(XT_CH_WHITE);
  xt_par2(XT_SET_ROW_COL_POS, row = 2, col = 25);
  printf("Number of Records: %s | Authors: %s | Version: %s ", data[3].value, data[2].value, data[1].value);
  xt_par2(XT_SET_ROW_COL_POS,row = 3, col = 24);
  if (maxRecord != 0) printf("First Record  Time: %s | Last Record  Time: %s", data[4].value, data[5].value);
  else printf("             First Record Time: (NULL) | Last Record Time: (NULL)");
  xt_par2(XT_SET_ROW_COL_POS, row = 4, col = 1);
  printf("------------------------------------------------------------------------------------------------------------------------");
  xt_par2(XT_SET_ROW_COL_POS, row = 5, col = 1);
  xt_par0(XT_CH_BLUE);
  if(screen == 0)
    printf("------------UP/Down-Scroll between Subjects/Records/Search Left/Right-Toggle between Subjects/Records/Search------------");
  else if(screen == 1 || screen == 2)
    printf("-------------------------------------UP/Down-Switch rows Left/Right-Switch columns--------------------------------------");
  else
    printf("------------------------------------------------------------------------------------------------------------------------");
  xt_par0(XT_CH_WHITE);
  xt_par2(XT_SET_ROW_COL_POS, row = 7, col = 21); 
}
Example #7
0
bool PlayerCreateState::_statDecrease(unsigned int num)
{
    auto player = Game::getInstance()->player();
    if (player->stat(num) <= 1) return false;

    player->setStat(num, player->stat(num) - 1);
    player->setStatsPoints(player->statsPoints() + 1);
    return true;
}
Example #8
0
void StatManagement::addAllStats()
{
	StatDefPair::iterator iter = Stat::getStatDefinitions()->begin();
	StatDefPair::iterator end = Stat::getStatDefinitions()->end();
	while(iter != end)
	{
		setStat(iter->first, 0);
		iter++;
	}
}
Example #9
0
/*
use: process a list of commands
args: cmdList = root of command tree
return: status of last command executed
*/
int process(CMD *cmdList) {

	pid_t pID;		// process ID
	int status;		// status of process

	// reap zombies
	(void) signal(SIGINT, SIG_IGN);
	while((pID = waitpid(-1, &status, WNOHANG)) > 0) {
		status = (WIFEXITED(status) ? WEXITSTATUS(status) : 
			128+WTERMSIG(status));
		fprintf(stderr, "Completed: %d (%d)\n", pID, status);
	}
	(void) signal(SIGINT, SIG_DFL);

	// process commands
	status = processCMD(cmdList);

	// update status
	return setStat(status);
}
Example #10
0
void File::_initialize()
{
    if (_initialized) return;
    Dat::Item::_initialize();
    Dat::Item::setPosition(0);

    uint32(); // unknown 1

    // primary stats
    for (unsigned i = (unsigned)STAT::STRENGTH; i <= (unsigned)STAT::LUCK; i++)
    {
        setStat((STAT)i, uint32());
    }

    // secondary stats
    _hitPoints = uint32();
    _actionPoints = uint32();
    _armorClass = uint32();

    uint32(); // unknown 2

    _meleeDamage = uint32();
    _carryWeight = uint32();
    _sequence    = uint32();
    _healingRate = uint32();
    _criticalChance      = uint32();
    _criticalHitModifier = uint32();

    for (unsigned i = (unsigned)DAMAGE::NORMAL; i <= (unsigned)DAMAGE::EXPLOSIVE; i++)
    {
        setDamage((DAMAGE)i, uint32());
    }
    for (unsigned i = (unsigned)DAMAGE::NORMAL; i <= (unsigned)DAMAGE::EXPLOSIVE; i++)
    {
        setResistance((DAMAGE)i, uint32());
    }

    _radiationResistance = uint32();
    _poisonResistance    = uint32();
    _age    = uint32();
    _gender = (GENDER)uint32();

    // bonuses to primary stats
    for (unsigned i = (unsigned)STAT::STRENGTH; i <= (unsigned)STAT::LUCK; i++)
    {
        setStatBonus((STAT)i, uint32());
    }

    // bonuses to secondary stats
    _hitPointsBonus    = uint32();
    _actionPointsBonus = uint32();
    _armorClassBonus   = uint32();

    uint32(); // unknown 3

    _meleeDamageBonus = uint32();
    _carryWeightBonus = uint32();
    _sequenceBonus    = uint32();
    _healingRateBonus = uint32();
    _criticalChanceBonus      = uint32();
    _criticalHitModifierBonus = uint32();

    for (unsigned i = (unsigned)DAMAGE::NORMAL; i <= (unsigned)DAMAGE::EXPLOSIVE; i++)
    {
        setDamageBonus((DAMAGE)i, uint32());
    }
    for (unsigned i = (unsigned)DAMAGE::NORMAL; i <= (unsigned)DAMAGE::EXPLOSIVE; i++)
    {
        setResistanceBonus((DAMAGE)i, uint32());
    }

    _radiationResistanceBonus = uint32();
    _poisonResistanceBonus    = uint32();
    _ageBonus    = uint32();
    _genderBonus = uint32();

    //skills
    for (unsigned i = (unsigned)SKILL::SMALL_GUNS; i <= (unsigned)SKILL::OUTDOORSMAN; i++)
    {
        setSkill((SKILL)i, uint32());
    }

    // unknown
    uint32(); // unknown 4
    uint32(); // unknown 5
    uint32(); // unknown 6
    uint32(); // unknown 7

    // name
    char * name = new char[32]();
    this->readBytes(name, 32);
    setName(name);
    delete [] name;

    _firstTaggedSkill  = (SKILL)int32();
    _secondTaggedSkill = (SKILL)int32();
    _thirdTaggedSkill  = (SKILL)int32();
    _fourthTaggedSkill = (SKILL)int32();
    _firstTrait  = (TRAIT)int32();
    _secondTrait = (TRAIT)int32();
    _characterPoints = uint32();
}
Example #11
0
/*
use: process a <pipeline>
args: 
	cmd 	= root of command tree
	fdin 	= input file descriptor
return: status of process
*/
int processPipe(CMD *cmd, int fdin, bool suppress) {

	int status;			// status of process

	// <stage> | <pipeline> case
	if (cmd->type == PIPE) {

		int fd[2];		// file descriptors
		
		// build the pipe
		if (pipe(fd) == -1) {
			status = errno;
			errorExit(status);
		}

		// built-in command
		if (isSpecial(cmd->left)) {
			processSpecial(cmd->left, true);
			status = processPipe(cmd->right, fd[0], true);
			return setStat(status);
		}

		pid_t pID = fork();		// process ID of fork

		// error check
		if (pID < 0) {
			status = errno;
			errorExit(status);
		}
		// child process
		else if (pID == 0) {

			// update input
			if (fdin != 0) {
				dup2(fdin, 0);
				close(fdin);
			}
			
			// update output
			close(fd[0]);
			dup2(fd[1], 1);
			close(fd[1]);

			// left side of pipe
			status = processStage(cmd->left);
		}
		// parent process
		else {
			
			// close file descriptors
			if (fdin != 0) {
				close(fdin);
			}
			close(fd[1]);

			// right side of pipe
			int temp = processPipe(cmd->right, fd[0], true);

			// close last file descriptor
			close(fd[0]);

			// wait for child process to finish
			(void) signal(SIGINT, SIG_IGN);
			waitpid(pID, &status, 0);

			// update status
			if (status == 0) {
				status = temp;
			}
			else {
				status = (WIFEXITED(status) ? WEXITSTATUS(status) : 
					128+WTERMSIG(status));
			}
			(void) signal(SIGINT, SIG_DFL);
		}

	}
	// <stage> case
	else {

		// built-in command
		if (isSpecial(cmd)) {
			if (suppress) {
				status = processSpecial(cmd, true);
			}
			else {
				status = processSpecial(cmd, false);
			}
			return setStat(status);
		}

		pid_t pID = fork();		// process ID of fork

		// error check
		if (pID < 0) {
			status = errno;
			errorExit(status);
		}
		// child process
		else if (pID == 0) {
			
			// update input
			if (fdin != 0) {
				dup2(fdin, 0);
				close(fdin);
			}

			status = processStage(cmd);
		}
		// parent process
		else {

			//close input
			if (fdin != 0) {
				close(fdin);
			}

			// wait for child process to finish
			(void) signal(SIGINT, SIG_IGN);
			waitpid(pID, &status, 0);

			// update status
			status = (WIFEXITED(status) ? WEXITSTATUS(status) : 
				128+WTERMSIG(status));
			(void) signal(SIGINT, SIG_DFL);
		}
	}

	return setStat(status);
}
Example #12
0
/*
use: process a <stage>
args: cmd = root of command tree
return: status of process
*/
int processStage(CMD* cmd) {

	int status 	= 0;	// status of process

	// set local variables
	for (int i = 0; i < cmd->nLocal; i++) {
		setenv(cmd->locVar[i], cmd->locVal[i], 1);
	}

	// process the redirections
	status = processRedir(cmd, true, false);
	if (status != 0) {
		return setStat(status);
	}

	// (<command>) case
	if (cmd->type == SUBCMD) {
		status = process(cmd->left);
		exit(status);
	}

	// current directory
	if (strcmp(cmd->argv[0], "dirs") == 0) {

		// extra args
		if (cmd->argc > 1) {
			status = 1;
			fprintf(stderr, "Too many arguments (%d > 1)\n", cmd->argc);
			//ADDED LINE
			exit(status);
		}

		char *cwd = NULL;		// current directory
		cwd = getcwd(cwd, 0);

		// error checking
		if (cwd == NULL) {
			status = errno;
			errorExit(status);
		}
		// write path
		if (write(1, cwd, strlen(cwd)) == -1) {
			status = errno;
			errorExit(status);
		}
		// write newline
		if (write(1, "\n", 1) == -1) {
			status = errno;
			errorExit(status);
		}
		status = (WIFEXITED(status) ? WEXITSTATUS(status) : 
			128+WTERMSIG(status));
		exit(status);
	}
	// <simple> case
	else if (execvp(cmd->argv[0], cmd->argv) == -1) {
		status = errno;
		errorExit(status);
	}

	return setStat(status);
}
Example #13
0
/*
use: process a built-in command
args: cmd = root of command tree
return: status of process
*/
int processSpecial(CMD *cmd, bool suppress) {

	int status = 0;		// status of process
	pid_t pID;			// process ID

	// check redirections
	status = processRedir(cmd, false, true);
	if (status != 0) {
		return setStat(status);
	}

	char **file = cmd->argv;	// for brevity

	// change directory
	if (strcmp(file[0], "cd") == 0) {

		// extra args
		if (cmd->argc > 2) {
			status = 1;
			fprintf(stderr, "Too many arguments (%d > 2)\n", cmd->argc);
			//ADDED LINE
			return setStat(status);
		}

		char *cwd = NULL;		// current directory
		cwd = getcwd(cwd, 0);

		// cd
		if (cmd->argc == 1) {
			if (chdir(getenv("HOME")) == -1) {
				status = errno;
				perror("Error");
			}
		}
		// cd PATH
		else {
			if (chdir(file[1]) == -1) {
				status = errno;
				perror("Error");
			}
		}

		// switch back directory if in left child
		if (suppress) {
			chdir(cwd);
		}
		//ADDED LINE
		free(cwd);
	}
	// wait for children
	else if (strcmp(file[0], "wait") == 0) {

		// extra args
		if (cmd->argc > 1) {
			status = 1;
			fprintf(stderr, "Too many arguments (%d > 1)\n", cmd->argc);
		}

		// reap zombies
		if (!suppress) {
			(void) signal(SIGINT, SIG_IGN);
			while((pID = waitpid(-1, &status, 0)) > 0) {
				status = (WIFEXITED(status) ? WEXITSTATUS(status) : 
					128+WTERMSIG(status));
				fprintf(stderr, "Completed: %d (%d)\n", pID, status);
			}
			(void) signal(SIGINT, SIG_DFL);
		}
	}

	return setStat(status);
}
Example #14
0
/*
use: process the redirection
args: 
	cmd 	= root of command tree
	fork 	= tells whether this is being called in a fork
	special = tells whether this is related to a built-in
return: status of process
*/
int processRedir(CMD* cmd, bool fork, bool special) {

	int status = 0;									// status of process
	mode_t mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH;	// access privileges

	// redirect in
	if (cmd->fromType == RED_IN) {
		int fdin = open(cmd->fromFile, O_RDONLY);

		// error check
		if (fdin == -1) {
			status = errno;
			if (fork) {
				errorExit(status);
			}
			else {
				perror("Error");
				return setStat(status);
			}
		}
		if (!special) {
			dup2(fdin, 0);
			close(fdin);
		}
	}

	// redirect out
	if (cmd->toType == RED_OUT) {
		int fdout = open(cmd->toFile, O_WRONLY|O_CREAT|O_TRUNC, mode);
		
		// error check
		if (fdout == -1) {
			status = errno;
			if (fork) {
				errorExit(status);
			}
			else {
				perror("Error");
				return setStat(status);
			}
		}
		// update output
		if (!special) {
			dup2(fdout, 1);
			close(fdout);
		}
	}
	// redirect append
	else if (cmd->toType == RED_APP) {
		int fdout = open(cmd->toFile, O_WRONLY|O_CREAT|O_APPEND, mode);
		
		// error check
		if (fdout == -1) {
			status = errno;
			if (fork) {
				errorExit(status);
			}
			else {
				perror("Error");
				return setStat(status);
			}
		}
		// update output
		if (!special) {
			dup2(fdout, 1);
			close(fdout);
		}
	}

	return status;
}
Example #15
0
void StatManagement::setStat(Stat *stat, StatType value)
{
	setStat(stat->getShortName(), value);
}
void GcdFileType::_initialize()
{
    if (_initialized) return;
    DatFileItem::_initialize();
    DatFileItem::setPosition(0);

    unsigned int uint32;
    
    // unknown 1
    *this >> _unknown1;

    // primary stats
    for (unsigned int i = STATS_STRENGTH; i <= STATS_LUCK; i++)
    {
        *this >> uint32;
        setStat(i, uint32);
    }
    
    // secondary stats
    *this >> _hitPoints >> _actionPoints >> _armorClass;

    // unknown 2
    *this >> _unknown2;

    *this >> _meleeDamage >> _carryWeight >> _sequence >> _healingRate >> _criticalChance >> _criticalHitModifier;
    
    for (unsigned int i = DAMAGE_NORMAL; i <= DAMAGE_EXPLOSIVE; i++)
    {
        *this >> uint32;
        setDamage(i, uint32);
    }
    for (unsigned int i = DAMAGE_NORMAL; i <= DAMAGE_EXPLOSIVE; i++)
    {
        *this >> uint32;
        setResistance(i, uint32);
    }
    
    *this >> _radiationResistance >> _poisonResistance >> _age >> _gender;

    // bonuses to primary stats
    for (unsigned int i = STATS_STRENGTH; i <= STATS_LUCK; i++)
    {
        *this >> uint32;
        setStatBonus(i, uint32);
    }

    // bonuses to secondary stats
    *this >> _hitPointsBonus >> _actionPointsBonus >> _armorClassBonus;

    // unknown 3
    *this >> _unknown3;

    *this >> _meleeDamageBonus >> _carryWeightBonus >> _sequenceBonus >> _healingRateBonus
          >> _criticalChanceBonus >> _criticalHitModifierBonus;
    for (unsigned int i = DAMAGE_NORMAL; i <= DAMAGE_EXPLOSIVE; i++)
    {
        *this >> uint32;
        setDamageBonus(i, uint32);
    }
    for (unsigned int i = DAMAGE_NORMAL; i <= DAMAGE_EXPLOSIVE; i++)
    {
        *this >> uint32;
        setResistanceBonus(i, uint32);
    }
    *this >> _radiationResistanceBonus >> _poisonResistanceBonus >> _ageBonus >> _genderBonus;

    //skills
    for (unsigned int i = SKILLS_1; i <= SKILLS_18; i++)
    {
        *this >> uint32;
        setSkill(i, uint32);
    }

    // unknown
    *this >> _unknown4 >> _unknown5 >> _unknown6 >> _unknown7;

    // name
    char * name = new char[32]();
    this->readBytes(name, 32);
    setName(name);
    delete [] name;

    *this >> _firstTaggedSkill
          >> _secondTaggedSkill
          >> _thirdTaggedSkill
          >> _fourthTaggedSkill
          >> _firstTrait
          >> _secondTrait
          >> _characterPoints;
}