Exemple #1
0
void Game::init(bool fullscreen, int screenMode) {
	const char *caption = kGameWindowTitle;
	if (_isDemo) {
		_stub->setIcon(_bermudaDemoBmpData, _bermudaDemoBmpSize);
		caption = kGameWindowTitleDemo;
	} else {
		_stub->setIcon(_bermudaIconBmpData, _bermudaIconBmpSize);
	}
	_stub->init(caption, kGameScreenWidth, kGameScreenHeight, fullscreen, screenMode);
	allocateTables();
	loadCommonSprites();
	restart();
	if (_isDemo) {
		_nextState = kStateGame;
	} else {
		playVideo("DATA/LOGO.AVI");
		_nextState = kStateBitmap;
	}
}
Exemple #2
0
void Game::mainLoop() {
	_stub->init(_gameWindowTitle, kGameScreenWidth, kGameScreenHeight);
	allocateTables();
	loadCommonSprites();
	_mixer->open();
	restart();
	if (_isDemo) {
		playBitmapSequenceDemo();
	} else {
		playVideo("DATA/LOGO.AVI");
		playVideo("DATA/INTRO.AVI");
	}
	_lastFrameTimeStamp = _stub->getTimeStamp();
	while (!_stub->_quit) {
		if (_switchScene) {
			_switchScene = false;
			if (stringEndsWith(_tempTextBuffer, "SCN")) {
				win16_sndPlaySound(6);
				debug(DBG_GAME, "switch to scene '%s'", _tempTextBuffer);
				if (strcmp(_tempTextBuffer, "PIC4.SCN") == 0) {
					debug(DBG_INFO, "End of game");
					break;
				}
				strcpy(_currentSceneScn, _tempTextBuffer);
				parseSCN(_tempTextBuffer);
			} else if (stringEndsWith(_tempTextBuffer, "SAV")) {
				if (_isDemo && strcmp(_tempTextBuffer, "A16.SAV") == 0) {
					debug(DBG_GAME, "End of demo interactive part");
					restart();
					continue;
				}
				warning("Ignoring savestate load '%s'", _tempTextBuffer);
				// should work though, as the original savestates load fine
				// now, but this "feature" is only used in the demo AFAICT,
				// so no need to bother...
			} else {
				debug(DBG_GAME, "load mov '%s'", _tempTextBuffer);
				loadMOV(_tempTextBuffer);
			}
			if (_loadState) {
				_loadState = false;
				loadState(_stateSlot, false);
				playMusic(_musicName);
				memset(_keysPressed, 0, sizeof(_keysPressed));
			}
			assert(_sceneObjectsCount != 0);
			if (_currentBagObject == -1) {
				_currentBagObject = _bagObjectsCount - 1;
				if (_currentBagObject > 0) {
					_currentBagObject = 0;
				}
			}
			if (_loadDataState != 0) {
				setupScreenPalette(_bitmapBuffer0 + kOffsetBitmapPalette);
			}
			_gameOver = false;
			_workaroundRaftFlySceneBug = strncmp(_currentSceneScn, "FLY", 3) == 0;
		}
		updateKeysPressedTable();
		updateMouseButtonsPressed();
		runObjectsScript();
		if (!_switchScene) {
			_stub->updateScreen();
			uint32 end = _lastFrameTimeStamp + kCycleDelay;
			do {
				_stub->sleep(10);
				_stub->processEvents();
			} while (!_stub->_pi.fastMode && _stub->getTimeStamp() < end);
			_lastFrameTimeStamp = _stub->getTimeStamp();
		}
		if (_startDialogue) {
			_startDialogue = false;
			handleDialogue();
		}
	}
	clearSceneData(-1);
	deallocateTables();
	unloadCommonSprites();
	_mixer->close();
	_stub->destroy();
}
Exemple #3
0
static Bool configcit(void)
    {
    Bool oldresizelog = FALSE, oldresizemsg = FALSE;

    CitadelIsConfiguring = TRUE;

    VerifyHeap();

#ifndef WINCIT
    if (OC.PrintFile)
        {
        fclose(OC.PrintFile);
        OC.PrintFile = NULL;
        }

    if (journalfl)
        {
        fclose(journalfl);
        journalfl = NULL;
        }
#endif

    if (TrapFile)
        {
        fclose(TrapFile);
        TrapFile = NULL;
        }

    if (RoomFile)
        {
        fclose(RoomFile);
        RoomFile = NULL;
        }


    // read CONFIG.CIT
    if (!readconfig(NULL, 0))
        {
        return (FALSE);
        }


	Bool grpZap = FALSE, hallZap = FALSE, msgZap = FALSE, logZap = FALSE, log2Zap = FALSE, log3Zap = FALSE,
			log4Zap = FALSE, log5Zap = FALSE, log6Zap = FALSE, roomZap = FALSE, roomposZap = FALSE;

    initfiles(&grpZap, &hallZap, &msgZap, &logZap, &log2Zap, &log3Zap, &log4Zap, &log5Zap, &log6Zap, &roomZap, &roomposZap);

    VerifyHeap();

    // if we are about to make a new system, make default .CIT files.
    if (msgZap && roomZap && logZap && grpZap && hallZap && roomposZap)
        {
        CreateConfigurationFile(C_EXTERNAL_CIT, 0, TRUE);
        CreateConfigurationFile(C_NODES_CIT, 1, TRUE);
        CreateConfigurationFile(C_GRPDATA_CIT, 2, TRUE);
        CreateConfigurationFile(C_CRON_CIT, 3, TRUE);
        CreateConfigurationFile(C_MDMRESLT_CIT, 4, TRUE);
        CreateConfigurationFile(C_PROTOCOL_CIT, 5, TRUE);
        CreateConfigurationFile(C_TERMCAP_CIT, 6, TRUE);
        CreateConfigurationFile(C_COMMANDS_CIT, 7, TRUE);
        }

    VerifyHeap(1);

    // allocate tables here so readconfig() can be called from sysop menu
    allocateTables();

#ifndef WINCIT
    setdefaultTerm(TT_ANSI);
    termCap(TERM_NORMAL);
#endif

    VerifyHeap(1);

#ifdef WINCIT
    if (msgZap || roomZap || logZap || grpZap || hallZap || roomposZap)
        {
        hCreateDlg = CreateDialog(hInstance, "CREATEDATAFILES", NULL, (DLGPROC) EmptyDlgProc);
        }
#endif

    if (msgZap)
        {
        MessageDat.InitializeMessageFile(cfg.MsgDatSizeInK * 1024l);
        }

    if (roomZap)    zapRoomFile();
    if (logZap)     zapLogFile(FALSE, TRUE);
    if (grpZap)     zapGrpFile(NULL, TRUE);
    if (hallZap)    zapHallFile();
    if (roomposZap) zapRoomPosFile(TRUE);

    if (roomZap && !msgZap) roomBuild = TRUE;
    if (hallZap && !msgZap) hallBuild = TRUE;

    if (!logZap)
        {
        if (log2Zap)    zapLog2();
        if (log3Zap)    zapLog3();
        if (log4Zap)    zapLog4();
        if (log5Zap)    zapLog5();
        if (log6Zap)    zapLog6();
        }

#ifdef WINCIT
    if (hCreateDlg)
        {
        DestroyWindow(hCreateDlg);
        hCreateDlg = NULL;
        }

// no go for debug version; td32 go crash crash
    hConfigDlg = CreateDialog(hInstance, "CONFIGURE", NULL, (DLGPROC) EmptyDlgProc);
#endif

    VerifyHeap(1);

    logInit();

    VerifyHeap(1);

	MessageDat.BuildTable();

    VerifyHeap(1);

    RoomTabBld();

    VerifyHeap(1);

#ifdef WINCIT
    if (hConfigDlg)
        {
        DestroyWindow(hConfigDlg);
        hConfigDlg = NULL;
        }
#endif

    if (hallBuild)
        {
        buildhalls();
        VerifyHeap(1);
        }

    if (resizeRoom)
        {
        resizeroomfile();
        VerifyHeap(1);
        }

    if (resizeGrp)
        {
        resizegrpfile();
        VerifyHeap(1);
        }

    if (resizeHall)
        {
        resizehallfile();
        VerifyHeap(1);
        }

    if (resizeLog)
        {
        resizelogfile();
        VerifyHeap(1);
        }

    if (resizeMsg)
        {
        MessageDat.Resize(newmessagek * 1024l);	// bibnewmsg
        VerifyHeap(1);
        }

    if (resizeLog || resizeMsg || resizeRoom || resizeGrp)
        {
        oldresizelog = resizeLog;
        oldresizemsg = resizeMsg;
        resizeLog = FALSE;
        resizeMsg = FALSE;

        MessageDat.CloseMessageFile();

#ifndef MINGW
        fcloseall();
#endif

        cfg.MsgDatSizeInK = newmessagek;
        cfg.MAXLOGTAB = newmaxlogtab;

        initfiles(&grpZap, &hallZap, &msgZap, &logZap, &log2Zap, &log3Zap, &log4Zap, &log5Zap, &log6Zap, &roomZap, &roomposZap);
        }

    VerifyHeap(1);

#ifdef WINCIT
    if (oldresizelog || oldresizemsg)
        {
        hConfigDlg = CreateDialog(hInstance, "CONFIGURE", NULL, (DLGPROC) EmptyDlgProc);
        }
#endif

    if (oldresizelog)
        {
        if (!LogTab.Resize(cfg.MAXLOGTAB))
            {
            crashout(getcfgmsg(116));
            }

        VerifyHeap(1);

        logInit();

        VerifyHeap(1);
        }

	if (oldresizemsg)	// bibnewmsg - required?
        {
        MessageDat.SetTableSize(cfg.nmessages);

        VerifyHeap(1);

        MessageDat.BuildTable();

        VerifyHeap(1);
        }

#ifdef WINCIT
    if (hConfigDlg)
        {
        DestroyWindow(hConfigDlg);
        hConfigDlg = NULL;
        }
#else
    doccr();
    cPrintf(getcfgmsg(135));
    doccr();
    pause(200);
#endif

	MessageDat.CloseMessageFile();

#ifndef WINCIT
    if (OC.PrintFile)
        {
        fclose(OC.PrintFile);
        OC.PrintFile = NULL;
        }

    if (journalfl)
        {
        fclose(journalfl);
        journalfl = NULL;
        }
#endif

    if (TrapFile)
        {
        fclose(TrapFile);
        TrapFile = NULL;
        }

    if (RoomFile)
        {
        fclose(RoomFile);
        RoomFile = NULL;
        }

    VerifyHeap(1);

    CitadelIsConfiguring = FALSE;

    return (TRUE);
    }
Exemple #4
0
static Bool initCitadel(void)
    {
    if (!read_cfg_messages())
        {
#ifdef WINCIT
        char Buffer[128];
        sprintf(Buffer, getmsg(188), getmsg(671));
        MessageBox(NULL, Buffer, NULL, MB_ICONSTOP | MB_OK);
#else
        printf(getmsg(188), getmsg(671));
#endif
        return (FALSE);
        }

    checkfiles();

    initExtDrivers();

    get_os();

	cfg.battr = 0xff;
    setscreen();

    logo(TRUE); // no go for debug version; td32 go crash crash

    init_internal_sound();

	// some mouse initialization technology!!!!
    initMouseHandler();
    hideCounter = 1;

    if (time(NULL) < 700000000L)
        {
#ifdef WINCIT
        MessageBox(NULL, getcfgmsg(119), NULL, MB_ICONSTOP | MB_OK);
#else
        doccr();
        doccr();
        cPrintf(getcfgmsg(119));
        doccr();
#endif
        dump_cfg_messages();
        return (FALSE);
        }


    static char prompt[92];
    static char citadel[92];
    char *envprompt;
    char *citprompt;

    envprompt = getenv(getcfgmsg(120));
    citprompt = getenv(getcfgmsg(121));
    if (citprompt)
        {
        sprintf(prompt, getcfgmsg(122), citprompt);
        }
    else if (envprompt)
        {
        sprintf(prompt, getcfgmsg(123), envprompt);
        }
    else
        {
        strcpy(prompt, getcfgmsg(124));
        }
    putenv(prompt);

    sprintf(citadel, getcfgmsg(125), programName, version);
    putenv(citadel);


#ifndef WINCIT
    OC.whichIO = CONSOLE;
    OC.SetOutFlag(OUTOK);
    OC.Echo = BOTH;
    OC.setio();
#endif

    VerifyHeap(1);

    // If we aren't reconfiguring, load the tables...
    if (!reconfig)
        {
        // Start by reading ETC.TAB
        getcwd(etcpath, 64);

        FILE *fd;
        if ((fd = fopen(etcTab, FO_RB)) != NULL)
            {
            if (filelength(fileno(fd)) != (long) sizeof(config) ||
					fread(&cfg, 1, sizeof(config), fd) != (long) sizeof(config))
                {
                memset(&cfg, 0, sizeof(cfg));
                reconfig = TRUE;
                }

            fclose(fd);
            unlink(etcTab);


            // If ETC.TAB could be loaded, load the rest
            if (!reconfig)
                {
                changedir(cfg.homepath);

                allocateTables();

                if (!LogTab.Load() || !MessageDat.LoadTable() || !RoomTab.Load())
                    {
                    reconfig = TRUE;
                    }

                Cron.ReadTable(WC_TWpn);
                }
            }
        else
            {
            if (!batchmode)
                {
#ifdef WINCIT
                MessageBox(NULL, "No ETC.TAB.", NULL, MB_ICONSTOP | MB_OK);
#else
                doccr();

                discardable *d;

                if ((d = readData(6)) != NULL)
                    {
                    int i;

                    for (i = 0; ((char **) d->next->aux)[i][0] != '#'; i++)
                        {
                        cPrintf(pcts, ((char **) d->next->aux)[i]);
                        doccr();
                        }

                    doccr();

                    discardData(d);
                    }
                else
                    {
                    cOutOfMemory(28);
                    }

                DeinitializeTimer();
                critical(FALSE);
#endif
                exit(1);
                }

            reconfig = TRUE;
            }
        }



    if (reconfig)
        {
        cfg.attr = 7;

#ifndef WINCIT
        pause(200);
        cls(SCROLL_SAVE);

        cCPrintf(getcfgmsg(126));
        doccr();
#endif


        if (!configcit())
            {
#ifdef WINCIT
            MessageBox(NULL, getcfgmsg(127), NULL, MB_ICONSTOP | MB_OK);
#else
            doccr();
            doccr();
            cPrintf(getcfgmsg(127));
            doccr();
#endif
            dump_cfg_messages();
            return (FALSE);
            }


#ifndef WINCIT
        setdefaultTerm(TT_ANSI);
        CurrentUser->SetWidth(80);
#endif

        Cron.ReadCronCit(WC_TWpn);
        }
    else
        {
#ifndef WINCIT
        if (!CreateScrollBackBuffer())
            {
            cPrintf(getcfgmsg(60));
            doccr();
            }
#endif


        if (readconfigcit)  // forced to read in config.cit
            {
            if (!readconfig(NULL, 1))
                {
#ifdef WINCIT
                MessageBox(NULL, getcfgmsg(129), NULL, MB_ICONSTOP | MB_OK);
#else
                doccr();
                doccr();
                cPrintf(getcfgmsg(129));
                doccr();
#endif
                dump_cfg_messages();
                return (FALSE);
                }
            }
        }

    VerifyHeap(1);

    makeBorders();
    readBordersDat();

    if (cmd_nobells)
        {
        cfg.noBells = 2;
        }

    if (cmd_nochat)
        {
        cfg.noChat = TRUE;
        }

    if (cmd_mdata != CERROR)
        {
        cfg.mdata = cmd_mdata;
        }

    if (*cfg.f6pass)
        {
        if (SameString(cfg.f6pass, getmsg(670)))
            {
            ConsoleLock.LockF6();
            }
        else
            {
            ConsoleLock.Lock();
            }
        }


#ifndef WINCIT
    if (cfg.ovrEms)
        {
        if (_OvrInitEms(0, 0, 0))
            {
            cPrintf(getcfgmsg(130));
            doccr();
            pause(200);
            }
        }

    if (cfg.ovrExt)
        {
        if (_OvrInitExt(0, 0))
            {
            cPrintf(getcfgmsg(131));
            doccr();
            pause(200);
            }
        }

    CommPort->Init();
    setscreen();
#endif

    logo(TRUE); // no go for debug version; td32 go crash crash

#ifndef WINCIT
    StatusLine.Update(WC_TWp);
#endif

    if (cfg.msgpath[(strlen(cfg.msgpath) - 1)] == '\\')
        {
        cfg.msgpath[(strlen(cfg.msgpath) - 1)] = '\0';
        }

    // move to home path
    changedir(cfg.homepath);
    char FileName[128];

    ReIndexFileInfo();  // keep fileinfo.dat nice and pretty

    // open message file
    if (!MessageDat.OpenMessageFile(cfg.msgpath))
		{
		illegal(getmsg(78), MessageDat.GetFilename());
		}

    // Then room file
    sprintf(FileName, sbs, cfg.homepath, roomDat);
    openFile(FileName, &RoomFile);

    citOpen(cfg.trapfile, CO_A, &TrapFile);
    initMenus();
    dump_cfg_messages();

    if(!read_tr_messages())
        {
        errorDisp(getmsg(172));
        }
    else
        {
#ifdef WINCIT
    trap(T_SYSOP, "", gettrmsg(37));
#else
    trap(T_SYSOP, gettrmsg(37));
#endif
        dump_tr_messages();
        }

        read_cfg_messages();            // uh-oh!

    if (!GroupData.Load())
        {
        return (FALSE);
        }

    if (!HallData.Load())
        {
        return (FALSE);
        }

    getRoomPos();

    if (cfg.accounting)
        {
        ReadGrpdataCit(WC_TWpn);
        }

    ReadExternalCit(WC_TWpn);
    ReadProtocolCit(WC_TWpn);
    ReadMdmresltCit(WC_TWpn);
    ReadCommandsCit(WC_TWpn);


#ifndef WINCIT
    ReadMCICit(FALSE);

    CurrentRoom->Load(LOBBY);
    thisRoom = LOBBY;
    checkdir();

    if (!slv_door)
        {
        CITWINDOW *w = CitWindowsMsg(NULL, getmsg(19));

        Initport();
        Initport();

        if (w)
            {
            destroyCitWindow(w, FALSE);
            }
        }
    else
        {
        CommPort->Enable();
        }

    OC.whichIO = MODEM;
    OC.setio();
#endif


    // record when we put system up
    time(&uptimestamp);

#ifndef WINCIT
    setdefaultconfig(FALSE);
    Talley->Fill();
#endif
    logo(FALSE);

    VerifyHeap(1);

    dump_cfg_messages();
    compactMemory(1);

    return (TRUE);
    }
Exemple #5
0
readTables()
{
    FILE  *fd;

    getcwd(etcpath, 64);

    /*
     * ETC.DAT
     */
    if ((fd  = fopen("etc.dat" , "rb")) == NULL)
        return(FALSE);
    if (!fread(&cfg, sizeof cfg, 1, fd))
    {
        fclose(fd);
        return FALSE;
    }
    fclose(fd);
    unlink("etc.dat");

    changedir(cfg.homepath);

    allocateTables();

    /*
     * LOG.TAB
     */
    if ((fd  = fopen("log.tab" , "rb")) == NULL)
        return(FALSE);
    if (!fread(logTab, sizeof(struct lTable), cfg.MAXLOGTAB, fd))
    {
        fclose(fd);
        return FALSE;
    }
    fclose(fd);
    unlink("log.tab" );

    /*
     * MSG.TAB
     */
    if (readMsgTab() == FALSE)  return FALSE;

    /*
     * ROOM.TAB
     */
    if ((fd = fopen("room.tab", "rb")) == NULL)
        return(FALSE);
    if (!fread(roomTab, sizeof(struct rTable), MAXROOMS, fd))
    {
        fclose(fd);
        return FALSE;
    }
    fclose(fd);
    unlink("room.tab");


/* new cron.tab stuff */

    readcron();         /* was being read before homepath set! */
    readCrontab();
    unlink("cron.tab");

/* end of new cron.tab stuff */


    return(TRUE);
}
Exemple #6
0
readTables()
{
    FILE  *fd;

    getcwd(etcpath, 64);

    /*
     * ETC.DAT
     */
    if ((fd  = fopen("etc.dat" , "rb")) == NULL)
        return(FALSE);
    if (!fread(&cfg, sizeof cfg, 1, fd))
    {
        fclose(fd);
        return FALSE;
    }
    fclose(fd);
    unlink("etc.dat");

    changedir(cfg.homepath);

    allocateTables();

    if (logTab == NULL)
        crashout("Error allocating logTab \n");
    if (msgTab1 == NULL || msgTab2 == NULL || /* msgTab3 == NULL || */
        msgTab4 == NULL || msgTab5 == NULL || msgTab6 == NULL ||
        msgTab7 == NULL || msgTab8 == NULL /*|| msgTab9 == NULL */)
        crashout("Error allocating msgTab \n");

    /*
     * LOG.TAB
     */
    if ((fd  = fopen("log.tab" , "rb")) == NULL)
        return(FALSE);
    if (!fread(logTab, sizeof(struct lTable), cfg.MAXLOGTAB, fd))
    {
        fclose(fd);
        return FALSE;
    }
    fclose(fd);
    unlink("log.tab" );

    /*
     * MSG.TAB
     */
    if (readMsgTab() == FALSE)  return FALSE;

    /*
     * ROOM.TAB
     */
    if ((fd = fopen("room.tab", "rb")) == NULL)
        return(FALSE);
    if (!fread(roomTab, sizeof(struct rTable), MAXROOMS, fd))
    {
        fclose(fd);
        return FALSE;
    }
    fclose(fd);
    unlink("room.tab");

    return(TRUE);
}