Ejemplo n.º 1
1
/**
 * This command loads up the specified new scene number
 */
bool Debugger::Cmd_Scene(int argc, const char **argv) {
	if (argc < 2) {
		debugPrintf("Usage: %s <scene number> [<x> <y>]\n", argv[0]);
		return true;
	}

	int sceneNumber = strToInt(argv[1]);
	if (sceneNumber >= g_vm->_theBoxes.getLocBoxesCount()) {
		debugPrintf("Invalid scene\n");
		return true;
	}

	RMPoint scenePos;
	if (argc >= 4) {
		scenePos._x = strToInt(argv[2]);
		scenePos._y = strToInt(argv[3]);
	} else {
		// Get the box areas for the scene, and choose one so as to have a default
		// position for Tony that will be in the walkable areas
		RMBoxLoc *box = g_vm->_theBoxes.getBoxes(sceneNumber);
		scenePos.set(box->_boxes[0]._hotspot[0]._hotx, box->_boxes[0]._hotspot[0]._hoty);
	}

	// Set up a process to change the scene
	ChangeSceneDetails details;
	details.sceneNumber = sceneNumber;
	details.x = scenePos._x;
	details.y = scenePos._y;
	CoroScheduler.createProcess(DebugChangeScene, &details, sizeof(ChangeSceneDetails));

	return false;
}
Ejemplo n.º 2
0
/**
 * Handles getting a parameter for an opcode
 */
void get_parameter() {
	int nvalue;

	if (token == NUMBER) {
		literal.value.integer	= strToInt(token_string);
		return;
	}

	if (token != IDENTIFIER)
		return;

	nvalue = symbolFind();
	if (nvalue != -1) {
		// Found symbol, so get it's numeric value and return
		token = NUMBER;
		literal.value.integer	= strToInt(symbolTable[nvalue].value);
		return;
	}

	// Check if the parameter is the name of an already processed subroutine
	strToLower(token_string);
	nvalue = subIndexOf();
	if (nvalue == -1) {
		token = ERROR;
		return;
	}

	// Store the index (not the offset) of the subroutine to call
	token = NUMBER;
	literal.value.integer = nvalue;
}
Ejemplo n.º 3
0
int main(void)
{
  printf ("%i\n", strToInt("245"));
  printf ("%i\n", strToInt("100") + 25);
  printf ("%i\n", strToInt("13x5"));
  return 0;
}
Ejemplo n.º 4
0
void setRTCFromText(char *time) {
	// This function parses the date and or time using any of the following format:
	//  1. #h#m#s
	//  2. #m#d
	//  3. #m#d#h#m#s
	//  where '#' represents any valid positive integer.  
	//  Note that 'm' is used for month and for minute. 'm' will mean month, unless it follows an 'h'.
	//  Note that year is not set because it is used to indicate the time period (see cold_start code)
	
	int month = -1, date = -1, hour = -1, min = -1, sec = -1;
	char *ptr;
	
	if ((ptr = findTimePart(time,'m'))) {
		month = strToInt(ptr);
		if ((ptr = findTimePart(time,'d')))
			date = strToInt(ptr);
		else 
			month = -1;
	}
	if ((ptr = findTimePart(time,'h'))) {
		hour = strToInt(ptr);
		if ((ptr = findTimePart(ptr,'m')))
			min = strToInt(ptr);
		if ((ptr = findTimePart(ptr,'s')))
			sec = strToInt(ptr);
	}
	if (month >= 1 && date >= 1)
		setDate(month,date);
	if (hour >= 0 && min >= 0 && sec >= 0)
		setRTC(hour,min,sec);
}
Ejemplo n.º 5
0
extern void 
importNewSystemData (LPSTR importFile) {
	struct SystemData sd;
	int handle;
	char buffer[READ_LENGTH+1];
	char *name, *value;
	
	memset(&sd,0,sizeof(struct SystemData));
	buffer[READ_LENGTH] = '\0'; //prevents readLine from searching for \n past buffer
	handle = tbOpen(importFile,O_RDONLY);
	while (nextNameValuePair(handle, buffer, ':', &name, &value)) {
		if (!value)
			continue;
		// test there is a new line and that it isn't a comment (starting with "#")
		if(*name == '#')
			continue;
		if (!strcmp(name,(char *)"SRN")) LBstrncpy(sd.serialNumber,trim(value),SRN_MAX_LENGTH);
			else if (!strcmp(name,(char *)"REFLASH")) sd.countReflashes=strToInt(value);
			else if (!strcmp(name,(char *)"IMAGE")) LBstrncpy(sd.imageName,trim(value),IMAGENAME_MAX_LENGTH);
			else if (!strcmp(name,(char *)"UPDATE")) LBstrncpy(sd.updateNumber,trim(value),UPDATENUMBER_MAX_LENGTH);
			else if (!strcmp(name,(char *)"LOCATION")) LBstrncpy(sd.location,trim(value),LOCATION_MAX_LENGTH);
			else if (!strcmp(name,(char *)"YEAR")) sd.yearLastUpdated=strToInt(value);
			else if (!strcmp(name,(char *)"MONTH")) sd.monthLastUpdated=strToInt(value);
			else if (!strcmp(name,(char *)"DATE")) sd.dateLastUpdated=strToInt(value);
	}
	close(handle);
	setSystemData(&sd);	
}
Ejemplo n.º 6
0
bool Debugger::cmd_enterRoom(int argc, const char **argv) {
	Resources &res = Resources::getReference();
	Room &room = Room::getReference();
	uint remoteFlag = 0;

	if (argc > 1) {
		int roomNumber = strToInt(argv[1]);

		// Validate that it's an existing room
		if (res.getRoom(roomNumber) == NULL) {
			DebugPrintf("specified number was not a valid room\n");
			return true;
		}

		if (argc > 2) {
			remoteFlag = strToInt(argv[2]);
		}

		room.leaveRoom();
		room.setRoomNumber(roomNumber);
		if (!remoteFlag)
			res.getActiveHotspot(PLAYER_ID)->setRoomNumber(roomNumber);

		detach();
		return false;
	}

	DebugPrintf("Syntax: room <roomnum> [<remoteview>]\n");
	DebugPrintf("A non-zero value for reomteview will change the room without ");
	DebugPrintf("moving the player.\n");
	return true;
}
Ejemplo n.º 7
0
bool Debugger::cmd_giveItem(int argc, const char **argv) {
	Resources &res = Resources::getReference();
	uint16 itemNum;
	uint16 charNum = PLAYER_ID;
	HotspotData *charHotspot, *itemHotspot;

	if (argc >= 2) {
		itemNum = strToInt(argv[1]);

		if (argc == 3)
			charNum = strToInt(argv[2]);

		itemHotspot = res.getHotspot(itemNum);
		charHotspot = res.getHotspot(charNum);

		if (itemHotspot == NULL) {
			DebugPrintf("The specified item does not exist\n");
		} else if (itemNum < 0x408) {
			DebugPrintf("The specified item number is not an object\n");
		} else if ((charNum < PLAYER_ID) || (charNum >= 0x408) ||
				   (charHotspot == NULL)) {
			DebugPrintf("The specified character does not exist");
		} else {
			// Set the item's room number to be the destination character
			itemHotspot->roomNumber = charNum;
		}
	} else {
		DebugPrintf("Syntax: give <item_id> [<character_id>]\n");
	}

	return true;
}
Ejemplo n.º 8
0
int main (void)
{
    int strToInt (const char str[]);
    printf ("%i\n", strToInt("-245"));
    printf ("%i\n", strToInt("100") + 25);
    printf ("%i\n", strToInt("135"));
    return 0;
}
Ejemplo n.º 9
0
/**
 * This command loads up the specified screen number
 */
bool HugoConsole::Cmd_gotoScreen(int argc, const char **argv) {
	if ((argc != 2) || (strToInt(argv[1]) > _vm->_numScreens)){
		DebugPrintf("Usage: %s <screen number>\n", argv[0]);
		return true;
	}

	_vm->_scheduler->newScreen(strToInt(argv[1]));
	return false;
}
Ejemplo n.º 10
0
int main(void)
{
    int strToInt (const char numericString[]);
    printf ("%i\n", strToInt("245"));
    printf ("%i\n", strToInt("100") + 25);
    printf ("%i\n", strToInt("13x5"));
    printf ("%i\n", strToInt("-405"));

    return 0;
}
Ejemplo n.º 11
0
int main (void)
{
    int strToInt (const char string[]);
    
    printf ("%i\n", strToInt("245"));
    printf ("%i\n", strToInt("-100") + 25);
    printf ("%i\n", strToInt("-13x5"));
    
    return 0;
}
Ejemplo n.º 12
0
void sh_memfree(char* params){
	int i;
	for(i=0;i<strLen(params);i++){
		if(params[i] == ' ') break;
	}
	params[i] = 0;
	void* pointer = (void*) ((int*)strToInt(params));
	int value = strToInt(params+i+1);
	free(pointer, value);
}
int main(void) {

    int strToInt(const char string[]);

    printf("%i \n", strToInt("435"));
    printf("%i \n", strToInt("435") + 25);
    printf("%i \n", strToInt("43*5"));

    return 0;
}
Ejemplo n.º 14
0
void OutputTable (SItemTableCtx &Ctx, const SItemTypeList &ItemList)
	{
	int i, j;

	if (ItemList.GetCount() == 0)
		return;

	//	Output each row

	for (i = 0; i < ItemList.GetCount(); i++)
		{
		CItemType *pType = ItemList[i];

		for (j = 0; j < Ctx.Cols.GetCount(); j++)
			{
			if (j != 0)
				printf("\t");

			const CString &sField = Ctx.Cols[j];

			//	Get the field value

			CString sValue;
			CItem Item(pType, 1);
			CItemCtx ItemCtx(Item);
			CCodeChainCtx CCCtx;

			ICCItem *pResult = Item.GetProperty(&CCCtx, ItemCtx, sField);

			if (pResult->IsNil())
				sValue = NULL_STR;
			else
				sValue = pResult->Print(&g_pUniverse->GetCC(), PRFLAG_NO_QUOTES | PRFLAG_ENCODE_FOR_DISPLAY);

			pResult->Discard(&g_pUniverse->GetCC());

			//	Format the value

			if (strEquals(sField, FIELD_AVERAGE_DAMAGE) || strEquals(sField, FIELD_POWER_PER_SHOT))
				printf("%.2f", strToInt(sValue, 0, NULL) / 1000.0);
			else if (strEquals(sField, FIELD_POWER))
				printf("%.1f", strToInt(sValue, 0, NULL) / 1000.0);
			else if (strEquals(sField, FIELD_TOTAL_COUNT))
				{
				SDesignTypeInfo *pInfo = Ctx.TotalCount.GetAt(pType->GetUNID());
				double rCount = (pInfo ? pInfo->rPerGameMeanCount : 0.0);
				printf("%.2f", rCount);
				}
			else
				printf(sValue.GetASCIIZPointer());
			}

		printf("\n");
		}
	}
Ejemplo n.º 15
0
int p9_ex11(void)
{
	printf("%i\n", strToInt("245"));
	printf("%i\n", strToInt("245") + 25);
	printf("%i\n", strToInt("13x5"));
	printf("%i\n", strToInt("-245"));



	return 0;
}
Ejemplo n.º 16
0
int main(){
    int n;
    scanf("%d",&n);
    char *str1,*str2;
    str1=(char*)malloc(sizeof(char)*8);
    str2=(char*)malloc(sizeof(char)*8);
    while(n--){
        scanf("%s %s",str1,str2);
        intToStr(strToInt(str1)+strToInt(str2));
    }
    return 0;
}
Ejemplo n.º 17
0
/**
 * This command loads up the specified new scene number
 */
bool Debugger::Cmd_Scene(int argc, const char **argv) {
	if (argc < 2) {
		DebugPrintf("Usage: %s <scene number> [prior scene #]\n", argv[0]);
		return true;
	}

	if (argc == 3)
		g_globals->_sceneManager._sceneNumber = strToInt(argv[2]);

	g_globals->_sceneManager.changeScene(strToInt(argv[1]));
	return false;
}
Ejemplo n.º 18
0
bool Debugger::Cmd_PlaySound(int argc, const char **argv) {
	if (argc < 2) {
		debugPrintf("Usage: %s <sound file>\n", argv[0]);
	} else {
		int commandId = strToInt(argv[1]);
		int param = (argc >= 3) ? strToInt(argv[2]) : 0;

		_vm->_sound->command(commandId, param);
	}

	return false;
}
Ejemplo n.º 19
0
bool Debugger::Cmd_SetCamera(int argc, const char **argv) {
	if (argc != 3) {
		debugPrintf("Usage: %s <x> <y>\n", argv[0]);
		return true;
	} else {
		int x = strToInt(argv[1]);
		int y = strToInt(argv[2]);
		_vm->_game->_scene.setCamera(Common::Point(x, y));
		_vm->_game->_scene.resetScene();
		_vm->_game->_scene.drawElements(kTransitionNone, false);
		return false;
	}
}
Ejemplo n.º 20
0
/**
 * This command puts an object in the inventory
 */
bool HugoConsole::Cmd_getObject(int argc, const char **argv) {
	if ((argc != 2) || (strToInt(argv[1]) > _vm->_object->_numObj)) {
		DebugPrintf("Usage: %s <object number>\n", argv[0]);
		return true;
	}

	if (_vm->_object->_objects[strToInt(argv[1])]._genericCmd & TAKE)
		_vm->_parser->takeObject(&_vm->_object->_objects[strToInt(argv[1])]);
	else
		DebugPrintf("Object not available\n");

	return true;
}
Ejemplo n.º 21
0
int main() {
  char *sInput = "874";

  switch( isVaildInt(sInput) ) {
    case 0: //pos number
      printf("%d\n", strToInt(sInput, 1));
      break;
    case 1: //neg number
      printf("%d\n", strToInt(sInput+1, -1));
      break;
    case 2: 
      printf("inVaildNum\n");break;
  }
}
Ejemplo n.º 22
0
int udbBacktrace(int argc, char* argv[]) {
    subArgv[0] = buf;
    subArgv[1] = 0;
    int result = doSysDebug(DEBUG_BACKTRACE, subArgv);
    char** res = split(buf);
    for(int i = 0; res[i]; i += 2) {
        uint32_t ebp = strToInt(res[i]);
        uint32_t eip = strToInt(res[i + 1]);
        struct DebugInfo* deb = findSline(eip);
        cprintf(
            "0x%08x in %s (ebp=%08x, eip=%08x) at %s:%d\n", 
            eip, deb->func->symStr, ebp, eip, deb->soStr, deb->sourceLine);
    }
}
Ejemplo n.º 23
0
static void readSequenceAnnotationContent(xmlNode *node) {
	SequenceAnnotation *ann;
	xmlChar *ann_uri;
	xmlChar *path;
	xmlChar *contents;
	xmlNode *child_node; // structured xml annotation
	int i;

	// create SequenceAnnotation
	ann_uri = getNodeURI(node);
	ann = createSequenceAnnotation(DESTINATION, (char *)ann_uri);
	xmlFree(ann_uri);

	// add bioStart
	path = BAD_CAST "./" NSPREFIX_SBOL ":" NODENAME_BIOSTART;
	if ((contents = getContentsOfNodeMatchingXPath(node, path))) {
		setSequenceAnnotationStart(ann, strToInt((char *)contents));
		xmlFree(contents);
	}

	// add bioEnd
	path = BAD_CAST "./" NSPREFIX_SBOL ":" NODENAME_BIOEND;
        if ((contents = getContentsOfNodeMatchingXPath(node, path))) {
		setSequenceAnnotationEnd(ann, strToInt((char *)contents));
		xmlFree(contents);
	}

	// add strand
	path = BAD_CAST "./" NSPREFIX_SBOL ":" NODENAME_STRAND;
        if ((contents = getContentsOfNodeMatchingXPath(node, path))) {
		setSequenceAnnotationStrand(ann, strToPolarity((char *)contents));
		xmlFree(contents);
	}

	// scan other xml nodes attached to this Annotation for structured xml annotations
	// @TODO factor out this block of code.  This routine is generally used by each of the SBOL core objects
	// but it requires some custom knowledge of the calling object (in this case, Annotation)
	child_node = node->children;
	while (child_node) {
		if (child_node->ns && !isSBOLNamespace(child_node->ns->href)) {
			// copy xml tree and save it in the SBOLDocument object as a structural annotation 
			xmlNode* node_copy = xmlDocCopyNode(child_node, ann->doc->xml_doc, 1);
			node_copy = xmlAddChild(xmlDocGetRootElement(ann->doc->xml_doc), node_copy);
			i = xmlReconciliateNs(ann->doc->xml_doc, xmlDocGetRootElement(ann->doc->xml_doc));
			insertPointerIntoArray(ann->base->xml_annotations, node_copy);
		}
		child_node = child_node->next;
	}
}
int mul (char* arg1, char* arg2, char* arg3,
		 char* arg4, char* arg5, char* arg6) {

	int r = 0xe0000090;

	int Rd = strToInt(arg1, MAX_ARG_SIZE);
	int Rm = strToInt(arg2, MAX_ARG_SIZE);
	int Rs = strToInt(arg3, MAX_ARG_SIZE);

	setBitsAt(&r, 16, &Rd, 0, 4);
	setBitsAt(&r, 0, &Rm, 0, 4);
	setBitsAt(&r, 8, &Rs, 0, 4);

	return r;
}
Ejemplo n.º 25
0
void sh_poke(char* params){
	// poke pointer byte(decimal)
	int i;
	for(i=0;i<strLen(params);i++){
		if(params[i] == ' ') break;
	}
	char substr[i+1];
	memCopy(params,substr,i);
	substr[i] = 0;
	char* pointer = (char*) ((int*)strToInt(substr));
	
	char substr2[strLen(params)-i];
	memCopy(params+i+1,substr2,strLen(params)-i);
	int value = strToInt(substr2);
	*pointer = value;
}
void MenuStateOptionsSound::saveConfig(){
	Config &config= Config::getInstance();
	Lang &lang= Lang::getInstance();
	setActiveInputLable(NULL);

	config.setString("FactorySound", listBoxSoundFactory.getSelectedItem());
	config.setString("SoundVolumeFx", listBoxVolumeFx.getSelectedItem());
	config.setString("SoundVolumeAmbient", listBoxVolumeAmbient.getSelectedItem());
	CoreData::getInstance().getMenuMusic()->setVolume(strToInt(listBoxVolumeMusic.getSelectedItem())/100.f);
	config.setString("SoundVolumeMusic", listBoxVolumeMusic.getSelectedItem());

	config.save();

	if(config.getBool("DisableLuaSandbox","false") == true) {
		LuaScript::setDisableSandbox(true);
	}

    SoundRenderer &soundRenderer= SoundRenderer::getInstance();
    soundRenderer.stopAllSounds();
    program->stopSoundSystem();
    soundRenderer.init(program->getWindow());
    soundRenderer.loadConfig();
    soundRenderer.setMusicVolume(CoreData::getInstance().getMenuMusic());
    program->startSoundSystem();

    if(CoreData::getInstance().hasMainMenuVideoFilename() == false) {
    	soundRenderer.playMusic(CoreData::getInstance().getMenuMusic());
    }

	Renderer::getInstance().loadConfig();
	console.addLine(lang.getString("SettingsSaved"));
}
Ejemplo n.º 27
0
void CGameSettings::SetValue (int iOption, const CString &sValue, bool bSetSettings)

//	SetValue
//
//	Sets the boolean, integer, or string value of the option

	{
	switch (g_OptionData[iOption].iType)
		{
		case optionBoolean:
			m_Options[iOption].bValue = (strEquals(sValue, CONSTLIT("true")) || strEquals(sValue, CONSTLIT("on")) || strEquals(sValue, CONSTLIT("yes")));
			break;

		case optionInteger:
			m_Options[iOption].iValue = strToInt(sValue, 0);
			break;

		case optionString:
			m_Options[iOption].sValue = sValue;
			break;

		default:
			ASSERT(false);
		}

	//	Set the settings value, if appropriate

	if (bSetSettings)
		m_Options[iOption].sSettingsValue = sValue;
	}
Ejemplo n.º 28
0
void Cmd::executeEvent() {
	string heading = cmdline["heading"];

	int port;
	if(!cmdline["port"].empty())
		port = strToInt(cmdline["port"]);
	else
		port=10001;


	int rc;
	string err;
	map<string, string> parameter;

	if(!cmdline["param"].empty()) {
		parameter.insert(std::make_pair(cmdline["param"],cmdline["value"]));
	}

	MMSXMLClientInterface *ipcclient = new MMSXMLClientInterface("127.0.0.1",port);
	if(parameter.empty()) {
	if(!ipcclient->funcSendEvent(heading, NULL, 1, &rc, &err)) {
	    	cons.printError("Could not send event!");
	    	exit(1);
		} else {
	         cons.printText("Event sucessfully sent.");
	         exit(0);
		}
	} else if(!ipcclient->funcSendEvent(heading, &parameter, 1, &rc, &err)) {
    	cons.printError("Could not send event!");
    	exit(1);
	} else {
         cons.printText("Event sucessfully sent.");
         exit(0);
	}
}
Ejemplo n.º 29
0
static void xcmd_flag_not_avaible_status_long (const char* const s, const char* const v, void* data)
{
	xcmdPath *path = data;

	if(!strToInt(v, 0, &path->not_available_status))
		error (FATAL, "Could not parse the value for %s flag: %s", s, v);
}
int main()
{
    char s[MAX_STR_LEN];
    while(gets(s) != NULL)
        printf("%d\n", strToInt(s));
    return 0;
}