Ejemplo n.º 1
0
int main()
{
    int wait;
    // Set up port for start switch
    lcdInit();
    // Set up motors and encoders
    motorInit();
    encodersInit();
    servoInit();
    // Set up IRs
    gp2d12Init(PIN_HEAD_IR);
    digitalSetDirection(PIN_IR,AVRRA_INPUT);
    digitalSetData(PIN_IR,AVRRA_LOW);
    // Set up OP599A - analog already initialized
    digitalSetDirection(PIN_PHOTO,AVRRA_INPUT);
    digitalSetData(PIN_PHOTO,AVRRA_LOW);
    // Set up fan & test
    digitalSetData(PIN_FAN, AVRRA_LOW);
    digitalSetDirection(PIN_FAN, AVRRA_OUTPUT);
    digitalSetData(PIN_FAN, AVRRA_HIGH);
    delayms(25);
    digitalSetData(PIN_FAN, AVRRA_LOW);

    lcdPrint("Wait... ");
    wait = digitalGetData(PIN_START);
    while(wait) {
        // standard delay ..
        delayms(10);
        wait = digitalGetData(PIN_START);
    }

    // Start our map
    mapInit();
    lcdClear();
    PrintHeading(lheading,nStart);
    sei();

    // Run Behaviors
    while(1) {
        // update odometer
        while(rCount > COUNTS_CM(1) ) {
            // odometer is in CM
            odometer = odometer - 1;
            rCount = rCount - COUNTS_CM(1);
        }
        // now run behaviors
        if(arbitrate()>0) {
            // let motors wind down
            delayms(500);
            clearCounters;
            plan();
            clearCounters;
        }
    }
}
Ejemplo n.º 2
0
int init(void *handle) {
	MAIN *m = handle;

	m->var.state = STATE_DUMMY;
	m->var.newstate = STATE_INVENTORY;	/* TODO: Måste fixas när menysystem och allt det där implementeras */
//	m->var.newstate = STATE_OVERWORLD;
	if (cameraInit(m) != 0);
	else if (systemInit(m) != 0);
	else if (mapInit(m) != 0);
	else if (textboxInit(m) != 0);
	else if (npcInit(m) != 0);
	else return 0;

	return -1;
}
Ejemplo n.º 3
0
void engineInit() {
	int err;
	err = SDL_Init(SDL_INIT_VIDEO);
	assert(!err);
	
	err = TTF_Init();
	assert(!err);
	
	engine.window = SDL_CreateWindow("bored", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1024, 768, 0);
	assert(engine.window);
	
	mapInit();
	mapSeed(rand());
	gfxInit();
	guiInit();
}
Ejemplo n.º 4
0
void MapViewInit()
{
	Player* player = getGameState()->getPlayer();
	lastLoses = player->getLoseCount();
	lastWins = player->getWinCount();

	playerTexture = Iw2DCreateImage("textures/map_player.png");
	healthTexture = Iw2DCreateImage("textures/map_health.png");
	healthLostTexture = Iw2DCreateImage("textures/map_health_lost.png");
	xpBarTexture  = Iw2DCreateImage("textures/map_xp_bar.png");
	
	mapTexture = new CIwTexture;
	mapTexture->LoadFromFile ("textures/map_template.png");
	mapTexture->Upload();
	
	mapInit(mapTexture->GetWidth(), mapTexture->GetHeight());

	ghostInit();
}
Ejemplo n.º 5
0
// Initialize peer manager object.
static int peermgtInit(struct s_peermgt *mgt) {
	const char *defaultpw = "default";
	int i;
	int s = mapGetMapSize(&mgt->map);
	struct s_peeraddr empty_addr;
	struct s_nodeid *local_nodeid = &mgt->nodekey->nodeid;
	
	mgt->msgsize = 0;
	mgt->loopback = 0;
	mgt->outmsg.len = 0;
	mgt->outmsgbroadcast = 0;
	mgt->outmsgbroadcastcount = 0;
	mgt->rrmsg.len = 0;
	mgt->rrmsgpeerid = 0;
	mgt->rrmsgusetargetaddr = 0;
	mgt->fragoutpeerid = 0;
	mgt->fragoutcount = 0;
	mgt->fragoutsize = 0;
	mgt->fragoutpos = 0;
	mgt->localflags = 0;
	
	for(i=0; i<s; i++) {
		mgt->data[i].state = peermgt_STATE_INVALID;
	}

	memset(empty_addr.addr, 0, peeraddr_SIZE);
	mapInit(&mgt->map);
	authmgtReset(&mgt->authmgt);
	nodedbInit(&mgt->nodedb);
	nodedbSetMaxAge(&mgt->nodedb, peermgt_NEWCONNECT_MAX_AGE);

	if(peermgtNew(mgt, local_nodeid, &empty_addr) == 0) { // ID 0 should always represent local NodeID
		if(peermgtGetID(mgt, local_nodeid) == 0) {
			if(peermgtSetNetID(mgt, defaultpw, 7) && peermgtSetPassword(mgt, defaultpw, 7)) {
				mgt->data[0].state = peermgt_STATE_COMPLETE;
				return 1;
			}
		}
	}
	
	return 0;
}
Ejemplo n.º 6
0
int
SCOTCH_graphMapInit (
const SCOTCH_Graph * const  grafptr,              /*+ Graph to map                    +*/
SCOTCH_Mapping * const      mappptr,              /*+ Mapping structure to initialize +*/
const SCOTCH_Arch * const   archptr,              /*+ Target architecture used to map +*/
SCOTCH_Num * const          parttab)              /*+ Mapping array                   +*/
{
  LibMapping * restrict srcmappptr;

#ifdef SCOTCH_DEBUG_LIBRARY1
  if (sizeof (SCOTCH_Mapping) < sizeof (LibMapping)) {
    errorPrint ("SCOTCH_graphMapInit: internal error");
    return     (1);
  }
#endif /* SCOTCH_DEBUG_LIBRARY1 */

  srcmappptr = (LibMapping *) mappptr;
  srcmappptr->parttax = (parttab != NULL) ? (parttab - ((Graph *) grafptr)->baseval) : parttab;

  return (mapInit (&srcmappptr->m, ((Graph *) grafptr)->baseval, ((Graph *) grafptr)->vertnbr, (Arch *) archptr));
}
Ejemplo n.º 7
0
bool stageThreeInitialise(void)
{
	STRUCTURE *psStr;
	UDWORD i;
	DROID		*psDroid;

	debug(LOG_WZ, "== stageThreeInitalise ==");
	bTrackingTransporter = false;

	loopMissionState = LMS_NORMAL;

	if(!InitRadar()) 	// After resLoad cause it needs the game palette initialised.
	{
		return false;
	}

	// reset the clock to normal speed
	gameTimeResetMod();

	if (!init3DView())	// Initialise 3d view stuff. After resLoad cause it needs the game palette initialised.
	{
		return false;
	}

	effectResetUpdates();
	initLighting(0, 0, mapWidth, mapHeight);

	if(bMultiPlayer)
	{
		// FIXME Is this really needed?
		debug( LOG_WZ, "multiGameInit()\n" );
		multiGameInit();
		cmdDroidMultiExpBoost(true);
	}

	preProcessVisibility();

	// Load any stored templates; these need to be available ASAP
	initTemplates();

	if (!fpathInitialise())
	{
		return false;
	}

	mapInit();
	clustInitialise();
	gridReset();

	//if mission screen is up, close it.
	if(MissionResUp)
	{
		intRemoveMissionResultNoAnim();
	}

	// Re-inititialise some static variables.

	driveInitVars(false);
	resizeRadar();

	setAllPauseStates(false);

	/* decide if we have to create teams, ONLY in multiplayer mode!*/
	if (bMultiPlayer && game.alliance == ALLIANCES_TEAMS)
	{
		createTeamAlliances();

		/* Update ally vision for pre-placed structures and droids */
		for(i=0;i<MAX_PLAYERS;i++)
		{
			if(i != selectedPlayer)
			{
				/* Structures */
				for(psStr=apsStructLists[i]; psStr; psStr=psStr->psNext)
				{
					if(aiCheckAlliances(psStr->player,selectedPlayer))
					visTilesUpdate((BASE_OBJECT *)psStr);
				}

				/* Droids */
				for(psDroid=apsDroidLists[i]; psDroid; psDroid=psDroid->psNext)
				{
					if(aiCheckAlliances(psDroid->player,selectedPlayer))
					visTilesUpdate((BASE_OBJECT *)psDroid);
				}
			}
		}
	}

	// ffs JS   (and its a global!)
	if (getLevelLoadType() != GTYPE_SAVE_MIDMISSION)
	{
		eventFireCallbackTrigger((TRIGGER_TYPE)CALL_GAMEINIT);
		triggerEvent(TRIGGER_GAME_INIT);
	}

	return true;
}
Ejemplo n.º 8
0
// Initialize NodeDB.
static void nodedbInit(struct s_nodedb *db) {
	mapInit(db->addrdb);
	mapEnableReplaceOld(db->addrdb);
}
Ejemplo n.º 9
0
int main()
{ 
    map *p = NULL;
    size_t cap, tSize;
    int objType,keyType;
	int objTypeSize, keyTypeSize;
    void *data = malloc(sizeof(double)*10);
	void *data2 = malloc(sizeof(double)*10);
    double double_neg_inf = DOUBLE_NEG_INF;
    short short_neg_inf = SHORT_NEG_INF;
	mapit it = NULL, rit=NULL;	

     while(1){
        char cmd[10240] = {0};
        int ret;
         if(p == NULL){
            printf("The map needs to be initialized.\n");
            printf("Init step 1. Key Type: d for double, others for short.\n");
            scanf("%s", cmd);
            keyType = (cmd[0] == 'd')?__DS__DOUBLE__:__DS__SHORT__;
			printf("Init step 2. Value Type: d for double, others for short.\n");
			scanf("%s", cmd);
			objType = (cmd[0] == 'd')?__DS__DOUBLE__:__DS__SHORT__;
			printf("Init step 3. Capacity: \n");
			scanf("%zu", &cap);
            p = mapAlloc();
            if(p == NULL)
                ret = __DS__MAP__OUT_OF_MEM__;
            else{
				objTypeSize = (objType==__DS__DOUBLE__)? sizeof(double): sizeof(short);
                if(keyType == __DS__DOUBLE__)
                    ret = mapInit(p, sizeof(double), objTypeSize, cap, doubleGT);
                else
                    ret = mapInit(p, sizeof(short), objTypeSize, cap, shortGT);
            } 
                
            if(ret != __DS__MAP__NORMAL__){
                printf("Not enough memory.\n");
                if(p != NULL)
                    mapFree(p);
                p = NULL;
             } 
            else{
                printf("Initialization done.\n");
             }
		}else{
            int choice = 0;
            printf("size/capacity: %zu/%zu\n", mapSize(p), mapCap(p));
            printf("Valid operation: 1)insert, 2)delete, 3)get iterator, 4)set\n");
            printf("                 5)update by it, 6)get order, 7)next, 8)pre, 9)get by iterator\n");
			printf("				 10)empty, 11)free,  12)quit\n");
	
            while(choice <= 0 || choice > 12){
                scanf("%s", cmd);
                sscanf(cmd, "%d", &choice);
            }
            if (choice == 1){//insert 
                printf("input a %s-type key:", (keyType == __DS__DOUBLE__)?"double":"short"); 
                getData(keyType, data);
				printf("input a %s-type value:", (objType == __DS__DOUBLE__)?"double":"short");
                getData(objType, data2);
				ret = mapInsert(p, data, data2);
                if(ret==__DS__MAP__FULL__)printf("Map is full!\n");
				else if(ret==__DS__MAP__OBJ_EXIST__)printf("Element already exists!\n");
				else if(ret==__DS__MAP__OUT_OF_MEM__)printf("Run out of memory\n");
				else if(ret==__DS__MAP__NORMAL__)printf("Insert OK\n");
            } 
            else if(choice == 2){//delete  
				printf("input a %s value:", (keyType == __DS__DOUBLE__)?"double":"short");
				getData(keyType, data);
                ret = mapDelete(p, data);
                if(ret==__DS__MAP__OBJ_NOT_EXIST__){
                    printf("Element is not in the set.\n");
                }  
                else
					printf("Delete OK\n");
            }
            else if (choice == 3){//get it
                printf("input a %s value:", (keyType == __DS__DOUBLE__)?"double":"short"); 
                getData(keyType, data);
                ret = mapGetIt(p, data, &it);
                if(ret == __DS__MAP__OBJ_EXIST__){
                    printf("Get iterator OK!");
					printf(".\n");
			 	} 
			 	else{
					printf("The key ");
					printData(keyType, data);
					printf(" is not in the map.\n");
				} 
            }
            else if(choice == 4){//set by it
				printf("input the value to set:");
				getData( objType, data2);
                ret = mapSetByIt(it, data2);
                if(ret == __DS__MAP__NORMAL__){
                    printf("Set OK!\n");
                  } 
                else
                    printf("Invalid It\n");
            }
			else if(choice == 5){//update by it
				printf("input the key to set:");
				getData( objType, data);
				printf("input the value to set:");
				getData( objType, data2);
				ret = mapUpdateByIt(it, data, data2);
				if(ret == __DS__MAP__NORMAL__)
				{
					printf("Update OK!\n");
				}else
				{
					printf("Invalid It\n");
				}
			}
            else if (choice == 6){//get order
				int order;
                printf("input the order:");
				scanf("%zu", &order);
				ret = mapGetOrderIt(p, order, data, data2, &it);
        
                if(ret == __DS__MAP__NORMAL__){
                    printf("The result key is ");
                    printData( keyType, data);
                    printf(".\n");
					printf("The result value is ");
					printData( objType, data2);
					printf(".\n");
                 } 
                else
                    printf("No element found\n");
            }  
			else if(choice == 7){//next
				rit = mapNextIt(it);
				if(rit!=NULL)
					printf("Get Next OK!\n");
				else
					printf("Cannot get next\n");
				mapFreeIt(it);
				it = rit;
			} 
			else if(choice == 8){//pre
				rit = mapPrevIt(it);
				if(rit!=NULL)
					printf("Get Priv OK!\n");
				else
					printf("Cannot get priv\n");
				mapFreeIt(it);
				it = rit;
			}
			else if(choice == 9){//get element by it
				ret = mapGetByIt(it,data,data2);
				if(ret==__DS__MAP__NORMAL__)
				{
					printf("The key of curremt it :");
					printData( keyType, data);
					printf("\nThe value of curremt it :");
					printData( objType, data2);
					printf("\n");
				}else
				{
					printf("Invalid Iterator\n");
				}
			}
            else if(choice == 10){//empty
                if(mapEmpty(p)==__DS__MAP__EMPTY__)
                    printf("The map is empty.\n");
                else
                    printf("The map is not empty.\n");
            }  
            else if(choice == 11){
                mapFree(p);
                p = NULL;
            }  
            else if(choice == 12)
                break;
        } 
    } 
}
Ejemplo n.º 10
0
Versions::Versions() {
    mapInit(map)
            (HTTP1_0, "HTTP/1.0")
            (HTTP1_1, "HTTP/1.1")
            (UNSUPPORTED, "Not Allowed");
}
Ejemplo n.º 11
0
bool stageThreeInitialise()
{
	STRUCTURE *psStr;
	UDWORD i;
	DROID *psDroid;
	bool fromSave = (getSaveGameType() == GTYPE_SAVE_START || getSaveGameType() == GTYPE_SAVE_MIDMISSION);

	debug(LOG_WZ, "== stageThreeInitialise ==");

	loopMissionState = LMS_NORMAL;

	if (!InitRadar()) 	// After resLoad cause it needs the game palette initialised.
	{
		return false;
	}

	// reset the clock to normal speed
	gameTimeResetMod();

	if (!init3DView())	// Initialise 3d view stuff. After resLoad cause it needs the game palette initialised.
	{
		return false;
	}

	effectResetUpdates();
	initLighting(0, 0, mapWidth, mapHeight);
	pie_InitLighting();

	if (fromSave)
	{
		// these two lines are the biggest hack in the world.
		// the reticule seems to get detached from 'reticuleup'
		// this forces it back in sync...
		intRemoveReticule();
		intAddReticule();
	}

	if (bMultiPlayer)
	{
		if (!fromSave)
		{
			multiGameInit();
		}
		initTemplates();
	}

	preProcessVisibility();

	prepareScripts(getLevelLoadType() == GTYPE_SAVE_MIDMISSION || getLevelLoadType() == GTYPE_SAVE_START);

	if (!fpathInitialise())
	{
		return false;
	}

	mapInit();
	gridReset();

	//if mission screen is up, close it.
	if (MissionResUp)
	{
		intRemoveMissionResultNoAnim();
	}

	// Re-inititialise some static variables.

	resizeRadar();

	setAllPauseStates(false);

	/* decide if we have to create teams, ONLY in multiplayer mode!*/
	if (bMultiPlayer && alliancesSharedVision(game.alliance))
	{
		createTeamAlliances();

		/* Update ally vision for pre-placed structures and droids */
		for (i = 0; i < MAX_PLAYERS; i++)
		{
			if (i != selectedPlayer)
			{
				/* Structures */
				for (psStr = apsStructLists[i]; psStr; psStr = psStr->psNext)
				{
					if (aiCheckAlliances(psStr->player, selectedPlayer))
					{
						visTilesUpdate((BASE_OBJECT *)psStr);
					}
				}

				/* Droids */
				for (psDroid = apsDroidLists[i]; psDroid; psDroid = psDroid->psNext)
				{
					if (aiCheckAlliances(psDroid->player, selectedPlayer))
					{
						visTilesUpdate((BASE_OBJECT *)psDroid);
					}
				}
			}
		}
	}

	countUpdate();
	if (getLevelLoadType() != GTYPE_SAVE_MIDMISSION)
	{
		if (getDebugMappingStatus())
		{
			triggerEventCheatMode(true);
		}
		eventFireCallbackTrigger((TRIGGER_TYPE)CALL_GAMEINIT);
		triggerEvent(TRIGGER_GAME_INIT);
	}

	return true;
}