Esempio n. 1
0
void S1Init()
{
	char str[16];
	char name[16];

	ScreenBox.g_x = ScreenBox.g_y = 0;
	ScreenBox.g_w = 320;
	ScreenBox.g_h = 192;

	/* initialiser ecrans */
	UnTiny(TnyRayoid);
	MemClear(_Screens[0],32000L);
	MemClear(_Screens[1],32000L);
	SwapReset();

	Alien.on = 0;
	Alien.mis.on = 0;
	Joueur[0].points = 0;
	S1Bonus = 2000;
	S1Level = 0;

	S1AstCreate();

	strcpy(str,"~8");
	strcpy(name,S1Stats.name);
	StrRight(name,8);
	strcat(str,name);
	_ShowStr(200,192,str,0);
	CopyZone(192,192,80,8);

	DrawNumber(272,192,S1Stats.score);

	S1ShowSpare(4);
}
Esempio n. 2
0
DCirfile *
DCirfile::SetConfigTemplate(const char *sect, const char *setting,
		                        bool link)
{
	DCirfile *bottomIni = SecFile ? SecFile : this;
	bool secfound = false;
	char *startdir =  _getcwd(NewName(1024), 1024);
	char *currdir = startdir;
	char *newdir = NULL;
	int startdrive = _getdrive();
	int currdrive = startdrive;
	int newdrive = 0;

	IniLevel = 0;

	if (!LogEventFunc)
		LastConfigSetting = NewName(setting);

	if (SecFile != NULL) {
		IniFileList.add(SecFile, ++IniLevel);
		IniNameList.add(SecFile->getBaseName(), IniLevel);
		IniChainList.add(SecFile->getFilePath(), IniLevel);
	}
	IniFileList.add(this, ++IniLevel);
	IniNameList.add(getBaseName(), IniLevel);
	IniChainList.add(getFilePath(), IniLevel);

	DCirfile *configTpl = NULL;
	char *configTplName = NULL;

	// SecFile (specific ini) overrides tpl choice in this
	DCirfile *topIni = this;
	secfound = Section(sect);

	if (secfound
	 && Find("Scope"))
		Scope = StrRight();

	if (secfound
	 && !stricmp(setting, "configs")
	 && Find("Document")) {   // insert document chain here
		DCirfile *topdoc = this;
		while (topdoc->Section(sect)) {
			if (!topdoc->Find("Document"))
				break;  // end of chain with no end flag ****
			char *nm = topdoc->StrRight();
			if (!nm)
				break;  // end of chain with no end flag ****
			if (!stricmp(nm, "end")) {
				DeleteName(nm);
				topdoc->ChainEnded = true;
				break;  // end of chain with end flag
			}
			DeleteName(nm);
			if ((configTplName = topdoc->PathRight()) == NULL)
				break;  // end of chain with no end flag ****
			if ((configTpl = new DCirfile(configTplName)) == NULL) {
				LogEvent(logwarn, 1, topdoc->getFilePath(), " refers to unopenable ",
					"Document template", " ", NewName(configTplName));
				DeleteName(configTplName);
				configTplName = NULL;
				break;
			}
			if (configTpl->FErr() != fok) {
				LogEvent(logwarn, 1, topdoc->getFilePath(), " refers to nonexistent ",
					"Document template", " ", NewName(configTpl->getFilePath()));
				DeleteName(configTplName);
				configTplName = NULL;
				delete configTpl;
				break;  // file not found
			}
			newdir = configTpl->getBasePath();
			if (*(newdir + 1) == ':')
				newdrive = (toupper(*newdir) - 'A') + 1;
			if (newdrive
			 && (currdrive != newdrive))
				_chdrive(currdrive = newdrive);
			if (stricmp(newdir, currdir))
				_chdir(currdir = newdir);

			if (IniNameList(configTpl->getBaseName())) {
				LogEvent(logwarn, 1, topdoc->getFilePath(), " repeats ",
					"Document template", " ", NewName(configTpl->getFilePath()));
				DeleteName(configTplName);
				configTplName = NULL;
				delete configTpl;
				break;  // deja vu, end of the line
			}

			topdoc = configTpl;  // step up
			if (topdoc->Section("Templates")
			 && topdoc->Find("Scope"))
				topdoc->Scope = topdoc->StrRight();
			DeleteName(configTplName);
			configTplName = NULL;
			IniFileList.add(topdoc, ++IniLevel);
			IniNameList.add(topdoc->getBaseName(), IniLevel);
			IniChainList.add(topdoc->getFilePath(), IniLevel);
		}
	}

	if (!secfound
	 || !Find(setting)) {  // check for old setting
		if (!stricmp(setting, "configs")) {
			if (Section("Setup")
			 && Find("ConfigTemplate")) {
				sect = "Setup";
				setting = "ConfigTemplate";
			}
			else if (Section("FDK")
			 && Find("ConfigTemplate")) {
				sect = "FDK";
				setting = "ConfigTemplate";
			}
		}
		else if (!stricmp(setting, "languages")) {
			if (Section("Setup")
			 && Find("LanguageText"))
				sect = "Setup";
				setting = "LanguageText";
		}
		else if (!stricmp(setting, "macros")) {
			if (Section("Macros")
			 && Find("MacroFile")) {
				sect = "Macros";
				setting = "MacroFile";
			}
		}
	}

	while (topIni->Section(sect)) {
		if (!topIni->Find(setting))
			break;  // end of chain with no end flag ****
		char *nm = topIni->StrRight();
		if (!nm)
			break;  // end of chain with no end flag ****
		if (!stricmp(nm, "end")) {
			DeleteName(nm);
			topIni->ChainEnded = true;
			break;  // end of chain with end flag
		}
		DeleteName(nm);
		if ((configTplName = topIni->PathRight()) == NULL)
			break;  // end of chain with no end flag ****
		if ((configTpl = new DCirfile(configTplName)) == NULL) {
			LogEvent(logwarn, 1, topIni->getFilePath(), " refers to unopenable ",
				setting, " ", NewName(configTplName));
			DeleteName(configTplName);
			configTplName = NULL;
			break;  // can't open file
		}
		if (configTpl->FErr() != fok) {
			LogEvent(logwarn, 1, topIni->getFilePath(), " refers to nonexistent ",
				setting, " ", NewName(configTpl->getFilePath()));
			DeleteName(configTplName);
			configTplName = NULL;
			delete configTpl;
			break;  // file not found
		}
		newdir = configTpl->getBasePath();
		if (*(newdir + 1) == ':')
			newdrive = (toupper(*newdir) - 'A') + 1;
		if (newdrive
		 && (currdrive != newdrive))
			_chdrive(currdrive = newdrive);
		if (stricmp(newdir, currdir))
			_chdir(currdir = newdir);

		if (IniNameList(configTpl->getBaseName())) {
			LogEvent(logwarn, 1, topIni->getFilePath(), " repeats ",
				setting, " ", NewName(configTpl->getFilePath()));
			DeleteName(configTplName);
			configTplName = NULL;
			delete configTpl;
			break;  // deja vu, end of the line
		}

		topIni = configTpl;  // step up
		if (topIni->Section("Templates")
		 && topIni->Find("Scope"))
			topIni->Scope = topIni->StrRight();
		DeleteName(configTplName);
		configTplName = NULL;
		IniFileList.add(topIni, ++IniLevel);
		IniNameList.add(topIni->getBaseName(), IniLevel);
		IniChainList.add(topIni->getFilePath(), IniLevel);
	}

	// topIni is now at the top of the chain, and
	// bottomIni is at the bottom, which may be same.
	if (link) {
		DCirfile *ifl = bottomIni;
		DCirfile *ift = NULL;
		for (long ilev = 1; ilev < IniLevel; ilev++) {
			ift = (DCirfile *) IniFileList.find(ilev + 1);
			if (!ift)
				break;
			ift->SetSecFile(ifl);
			ifl = ift;
			//if (ifl == topIni)
			//	break;
		}
	}

	WriteIniChain(setting);

	if (currdrive != startdrive)
		_chdrive(startdrive);
	if (stricmp(startdir, currdir))
		_chdir(startdir);

	if (this != topIni) {
		topIni->IniFileList = IniFileList;
		topIni->IniNameList = IniNameList;
		topIni->IniChainList = IniChainList;
		topIni->IniLevel = IniLevel;
	}

	return topIni;
}
Esempio n. 3
0
int Tdi1Using(int opcode, int narg, struct descriptor *list[],
              struct descriptor_xd *out_ptr)
{
    int status = 1;
    void *ctx;
    int reset_ctx = 0;
    int nid, shot, stat1;
    struct descriptor def = { 0, DTYPE_T, CLASS_D, 0 }, expt = def;
    unsigned char omits[] = { DTYPE_PATH, 0 };

        /**********************
        Evaluate with current.
        Use current if omitted.
        Must get expt if shot.
        **********************/
    if (narg > 1 && status & 1) {
        if (list[1]) {
            struct descriptor_xd xd = EMPTY_XD;
            status = TdiGetData(omits, list[1], &xd);
            if (status & 1 && xd.pointer)
                switch (xd.pointer->dtype) {
                case DTYPE_T:
                case DTYPE_PATH:
                    status = StrCopyDx(&def, xd.pointer);
                    break;
                default:
                    status = TdiINVDTYDSC;
                    break;
                }
            MdsFree1Dx(&xd, NULL);
        }
        if (!list[1] || def.length == 0) {
            DBI_ITM def_itm[] = { {0, DbiDEFAULT, 0, 0}
            , EOL };
            status = TreeGetDbi(def_itm);
            if (def_itm[0].pointer == NULL) {
                STATIC_CONSTANT DESCRIPTOR(top, "\\TOP");
                StrCopyDx(&def, &top);
                status = 1;
            } else {
                unsigned short len =
                    (unsigned short)strlen((char *)def_itm[0].pointer);
                StrCopyR(&def, &len, def_itm[0].pointer);
                TreeFree(def_itm[0].pointer);
            }
            if (status & 1) {
                stat1 = StrPosition(&def, &coloncolon, 0) + 1;
                status = StrRight(&def, &def, &stat1);
            }
            if (status & 1)
                *def.pointer = '\\';
        }
    }
    if ((narg > 2) && ((list[2] != 0) || ((narg > 3) && (list[3] != 0)))
        && ((status & 1) != 0)) {
        if (list[2])
            status = TdiGetLong(list[2], &shot);
        else {
            DBI_ITM shot_itm[] = { {sizeof(shot), DbiSHOTID, 0, 0}
            , EOL };
            shot_itm[0].pointer = (unsigned char *)&shot;
            status = TreeGetDbi(shot_itm);
        }

        if (status & 1) {
            if (narg > 3 && list[3])
                status = TdiData(list[3], &expt MDS_END_ARG);
            else {
                DBI_ITM expt_itm[] = { {0, DbiNAME, 0, 0}
                , EOL };
                status = TreeGetDbi(expt_itm);
                if (expt_itm[0].pointer) {
                    unsigned short len =
                        (unsigned short)strlen((char *)expt_itm[0].pointer);
                    StrCopyR(&expt, &len, expt_itm[0].pointer);
                    TreeFree(expt_itm[0].pointer);
                }
            }
        }
                /*********************
                Set new tree and path.
                Allow some rel paths.
                *********************/
        if (status & 1) {
            char *tree = MdsDescrToCstring(&expt);
            ctx = TreeSwitchDbid(0);
            reset_ctx = 1;
            status = TreeOpen(tree, shot, 1);
            MdsFree(tree);
        }
    }
    if (narg > 1) {
        char *path = MdsDescrToCstring(&def);
        if (status & 1)
            status = TreeSetDefault(path, &nid);
        MdsFree(path);
        if (narg > 2)
            StrFree1Dx(&expt);
        StrFree1Dx(&def);
    }
        /***********************
        Evaluate with temporary.
        ***********************/
    if (status & 1) {
        struct descriptor_xd tmp = EMPTY_XD;
        status = TdiEvaluate(list[0], &tmp MDS_END_ARG);
        if (status & 1)
            status = MdsCopyDxXdZ((struct descriptor *)&tmp, out_ptr, NULL,
                                  fixup_nid, NULL, fixup_path, NULL);
        MdsFree1Dx(&tmp, NULL);
    }
    if (reset_ctx) {
        while (TreeClose(0, 0) & 1) ;
        TreeFreeDbid(TreeSwitchDbid(ctx));

    }
    return status;
}