func (suite *ReleaseStoreLibrarySuite) SetUpTest(c *check.C) {
	suite.descriptors = objprop.StandardProperties()
	suite.nullObjpropProvider = objprop.NullProvider(suite.descriptors)

	suite.source = release.NewMemoryRelease()
	suite.sink = release.NewMemoryRelease()
	suite.library = NewReleaseStoreLibrary(suite.source, suite.sink, 0)
}
// NewReleaseStoreLibrary returns a StoreLibrary that covers two Release container.
// Stores are first tried from the sink, then from source; They are saved in the sink.
func NewReleaseStoreLibrary(source release.Release, sink release.Release, timeoutMSec int) StoreLibrary {
	library := &ReleaseStoreLibrary{
		source:      source,
		sink:        sink,
		timeoutMSec: timeoutMSec,
		chunkStores: make(map[string]chunk.Store),

		descriptors:   objprop.StandardProperties(),
		objpropStores: make(map[string]objprop.Store)}

	return library
}
Пример #3
0
// NewGameObjects returns a new instance of GameObjects.
func NewGameObjects(library io.StoreLibrary) (gameObjects *GameObjects, err error) {
	var cybstrng [model.LanguageCount]chunk.Store
	var objart chunk.Store
	var objProperties objprop.Store

	if err == nil {
		objart, err = library.ChunkStore("objart.res")
	}
	if err == nil {
		objProperties, err = library.ObjpropStore("objprop.dat")
	}
	for i := 0; i < model.LanguageCount && err == nil; i++ {
		cybstrng[i], err = library.ChunkStore(localized[i].cybstrng)
	}
	if err == nil {
		gameObjects = &GameObjects{
			cybstrng:       cybstrng,
			cp:             text.DefaultCodepage(),
			desc:           objprop.StandardProperties(),
			objProperties:  objProperties,
			objart:         objart,
			objIconOffsets: make(map[res.ObjectID]int),
			mapIconOffsets: make(map[res.ObjectID]int)}

		offset := 1
		for classIndex, classDesc := range gameObjects.desc {
			for subclassIndex, subclassDesc := range classDesc.Subclasses {
				for typeIndex := uint32(0); typeIndex < subclassDesc.TypeCount; typeIndex++ {
					objID := res.MakeObjectID(res.ObjectClass(classIndex), res.ObjectSubclass(subclassIndex), res.ObjectType(typeIndex))
					commonProperties := gameObjects.commonProperties(objID)
					extraImages := int(commonProperties.Extra >> 4)

					gameObjects.objIconOffsets[objID] = offset
					offset = offset + 3 + extraImages
					gameObjects.mapIconOffsets[objID] = offset - 1
				}
			}
		}
	}

	return
}