headers() {
    int i, n;
    string tmp_str, tmp_str2, rest_of_mess;
    string name;

    if (!loaded)
	load_player();
    if (arr_messages == 0) {
	write("No mail.\n");
	return 1;
    }
    for (i=0; i<sizeof(arr_messages); i+=2) {
	name = i/2+1 + " " + arr_messages[i];
	if (strlen(name) < 8)
	    name += "\t";
	write(name + "\t");
        n = sscanf(arr_messages[i+1],"%sRe:   %s\n%s",
		   tmp_str,tmp_str2,rest_of_mess);
        if (n == 3) write(" Re:   " + tmp_str2);
        n = sscanf(arr_messages[i+1],"%sSubj: %s\n%s",
		   tmp_str,tmp_str2,rest_of_mess);
        if (n == 3) write(" Subj: " + tmp_str2);
        n = sscanf(arr_messages[i+1],"%sDate: %s\n%s",
		   tmp_str,tmp_str2, rest_of_mess);
        if (n == 3) write(" Date: " + tmp_str2);
	write("\n");
    }
    return 1;
}
예제 #2
0
파일: main.c 프로젝트: dgalide/2048
int		main(void)
{
	t_player	*map;
	int			i;

	map = load_player(4);
	i = play(map);
	return (0);
}
예제 #3
0
void CubeCreature::load_cube(FILE *file){
	fscanf(file,"%u ",&energy);
	load_address(file);
	carry_res.load(file);
	orders->load_orders(file);
	load_player(file);
	load_colli(file);
	load_creature(file);
	load_constructable(file);
	load_health(file);
}
read() {
    is_reading = 1;
    if (!loaded) {
	load_player();
	if (arr_messages == 0) {
	    write("No mail.\n");
	    return 1;
	}
    }
    loop();
    return 1;
}
예제 #5
0
파일: main_menu.c 프로젝트: chameco/gwir
bool main_menu_mode(entity *player) {
	hide_ui();

	main_menu_background();

	draw_string("                                                     ", (color){22, DEFAULT_BG}, COLS/2-26, 2);
	draw_string("                                                     ", (color){22, DEFAULT_BG}, COLS/2-26, 3);
	draw_string("   .g8^^^bgd `7MMF'     A     `7MF'`7MMF'`7MM^^^Mq.  ", (color){22, DEFAULT_BG}, COLS/2-26, 4);
	draw_string(" .dP'     `M   `MA     ,MA     ,V    MM    MM   `MM. ", (color){22, DEFAULT_BG}, COLS/2-26, 5);
	draw_string(" dM'       `    VM:   ,VVM:   ,V     MM    MM   ,M9  ", (color){22, DEFAULT_BG}, COLS/2-26, 6);
	draw_string(" MM              MM.  M' MM.  M'     MM    MMmmdM9   ", (color){22, DEFAULT_BG}, COLS/2-26, 7);
	draw_string(" MM.    `7MMF'   `MM A'  `MM A'      MM    MM  YM.   ", (color){22, DEFAULT_BG}, COLS/2-26, 8);
	draw_string(" `Mb.     MM      :MM;    :MM;       MM    MM   `Mb. ", (color){22, DEFAULT_BG}, COLS/2-26, 9);
	draw_string("   `^bmmmdPY       VF      VF      .JMML..JMML. .JMM.", (color){22, DEFAULT_BG}, COLS/2-26, 10);
	draw_string("                                                     ", (color){22, DEFAULT_BG}, COLS/2-26, 11);
	draw_string("                                                     ", (color){22, DEFAULT_BG}, COLS/2-26, 12);
	draw_string(" 1 - Continue", DEFAULT_COLOR, 1, 15);
	draw_string(" 2 - New Game", DEFAULT_COLOR, 1, 16);
	draw_string(" Q - Quit", DEFAULT_COLOR, 1, 17);

	update_panels();
	doupdate();

	int input = getch();
	switch (input) {
		case '1':
			load_player();
			if (player->alive) {
				set_mode(MODE_GAMEPLAY);
				erase();
				show_ui();
			} else {
				main_menu_background();

				draw_string("No saved game!", (color){52, DEFAULT_BG}, COLS/2 - 7, LINES/4);

				update_panels();
				doupdate();
				while (getch() == ERR);
			}
			break;
		case '2': set_mode(MODE_CREATE_CHARACTER); break;
		case 'Q': return false;
	}
	
	return true;
}
loop() {
    string tmp;

    if (!loaded)
	load_player();
    if (arr_messages == 0) {
	write("No messages.\n");
	is_reading = 0;
	return;
    }
    if (curr_mess < 1 || curr_mess > sizeof(arr_messages)/2)
	tmp = " (no current) ";
    else
	tmp = " (current: " + curr_mess + ") ";
    write("[1 - " + (sizeof(arr_messages)/2) + " h d r x ?]" + tmp);
    input_to("get_cmd");
}
예제 #7
0
player_t* rawr_t::load_player( sim_t* sim,
                               const std::string& character_file )
{
  FILE* f = fopen( character_file.c_str(), "r" );
  if ( ! f )
  {
    sim -> errorf( "Unable to open Rawr Character Save file '%s'\n", character_file.c_str() );
    return false;
  }

  std::string buffer;
  char c;
  while ( ( c = fgetc( f ) ) != EOF ) buffer += c;
  fclose( f );

  player_t* p = load_player( sim, character_file, buffer );

  return p;
}
예제 #8
0
파일: TheGame.cpp 프로젝트: asxetos/TheGame
int main() {
	SIrrlichtCreationParameters pars;

	pars.DriverType=EDT_OPENGL;
	pars.WindowSize=dimension2d<s32>(800,600);
	pars.Bits=32;

	pars.AntiAlias=true;
	pars.Stencilbuffer=true;
	pars.Doublebuffer = true;

	pars.Fullscreen=false;
	pars.Vsync=false;

	pars.EventReceiver=&receiver;

	device  = createDeviceEx(pars);

	//device = createDevice(EDT_OPENGL, dimension2d<u32>(800, 600), 32, false, false, false, &receiver);
	if (!device)
		return 1;

	driver = device->getVideoDriver();
	driver->setTextureCreationFlag(ETCF_ALWAYS_32_BIT, true);

	smgr = device->getSceneManager();

	smgr->setShadowColor(SColor(127,0,0,0));

	load_map();
	load_player();

	int fps = 0;
	int prev_fps = -1;
	stringw the_title;

	camera = smgr->addCameraSceneNode();//FPS();
	camera->setPosition(vector3df(-50,50,-150));

	device->getCursorControl()->setVisible(false);

	then = device->getTimer()->getTime();
	while(device->run()) {
		now = device->getTimer()->getTime();
		//check_input();
		then = now;

		driver->beginScene(true, true, SColor(255, 255, 255, 255));
		smgr->drawAll();
		driver->endScene();

		fps = driver->getFPS();
		if (fps != prev_fps) {
			the_title = L"The Game | ";
			the_title += driver->getName();
			the_title += " | FPS:";
			the_title += fps;

			device->setWindowCaption(the_title.c_str());
		}
	}

	device->drop();
	return 0;
}
예제 #9
0
파일: saveload.c 프로젝트: abstrakct/gt2
bool load_game(char *filename, int ingame)
{
        FILE *f;
        struct savefile_header header;
        monster_t *m;
        obj_t *o;
        int i;
        char cmd[100];

        printf("\nLoading game from %s\n", filename);
        
        if(filename[strlen(filename)-1] == 'z' && filename[strlen(filename)-2] == 'x') {               // it's pretty likely to be compressed with xz!
                sprintf(cmd, "xz -d %s", filename);
                system(cmd);
                filename[strlen(filename)-3] = '\0';  // strip off .xz
        }

        f = fopen(filename, "r");
        if(!f) {
                printf("Couldn't open file %s", filename);
                return false;
        }

        fread(&header, sizeof(struct savefile_header), 1, f);
        if(header.magic != GT_SAVEFILE_MAGIC) {
                fprintf(stderr, "This doesn't look like a GT savefile to me!");
                return false;
        }
        if(header.version.major != GT_VERSION_MAJ || header.version.minor != GT_VERSION_MIN || header.version.revision != GT_VERSION_REV)
                fprintf(stderr, "Warning: Save file doesn't match current version number. This may or may not work...!");

        fread(&gtconfig, sizeof(gt_config_t), 1, f);
        fread(game, sizeof(game_t), 1, f);
        clear_master_object_list();
        game->num_objects = 0;

        /* player */
        if(!load_player(player, f)) {
                fprintf(stderr, "DEBUG: %s:%d - loading failed in load_player\n", __FILE__, __LINE__);
                return false;
        }

        /* now, loading monsterdefs, linked lists, all that.. might be tricky! */
        for(i=0; i <= game->monsterdefs; i++) {
                if(!ingame)  // only alloc memory if we are loading at startup
                        m = gtmalloc(sizeof(monster_t));
                else
                        m = monsterdefs;
                if(!load_monsterdef(m, f)) {
                        fprintf(stderr, "DEBUG: %s:%d - loading failed in load_monsterdef\n", __FILE__, __LINE__);
                        return false;
                }
                
                m->next = monsterdefs->next;
                m->head = monsterdefs;
                m->prev = monsterdefs;
                if(monsterdefs->next)
                        monsterdefs->next->prev = m;
                monsterdefs->next = m;
}

        /* objdefs */
        for(i=0; i <= game->objdefs; i++) {
                if(!ingame)  // only alloc memory if we are loading at startup
                        o = gtmalloc(sizeof(obj_t));
                else
                        o = objdefs;
                if(!load_objdef(o, f)) {
                        fprintf(stderr, "DEBUG: %s:%d - loading failed in load_objdef %d\n", __FILE__, __LINE__, i);
                        return false;
                }

                o->next = objdefs->next;
                o->head = objdefs;
                /*o->prev = objdefs;
                if(objdefs->next)
                        objdefs->next->prev = o;*/
                objdefs->next = o;
        }

        /* world */
        if(!load_level(world->dng, f)) {
                fprintf(stderr, "DEBUG: %s:%d - loading failed in load_level\n", __FILE__, __LINE__);
                return false;
        }
        for(i=1; i<=game->createddungeons; i++) {
                if(!load_level(&world->dng[i], f)) {
                        fprintf(stderr, "DEBUG: %s:%d - loading failed in load_level (level %d)\n", __FILE__, __LINE__, i);
                        return false;
                }
        }

        /* schedule / events */
        if(!load_eventlist(f)) {
                fprintf(stderr, "DEBUG: %s:%d - Loading failed in load_eventlist!\n", __FILE__, __LINE__);
                return false;
        }

        fclose(f);
        printf("Loading successful!\n");
        return true;
}