這兩天Gravatar被墻,真是吐血,博客上所有的頭像都不能顯示了。BS抽風的GFW。
經測試,雖然%d.gravatar.com不能訪問,但是gravatar.com還是可以訪問的,因此解決方法也很簡單:
將”wp-includes/pluggable.php”文件中的1649-1652行:
閱讀全文(338字)文章來源:
http://gccfeli.cn/2010/10/gravatar-gfw.html
C# 3.0及以后版本提供了擴展方法這一強大工具,使得動態擴展類變得十分方便。具體使用方法是定義一個static class,然后定義static擴展方法,注意擴展方法的第一個參數必須用this關鍵字修飾。擴展方法能像類本身定義的方法一樣被使用,而不需要修改類的代碼,這樣擴展原有庫中的類就變得非常容易了。擴展方法同樣對接口生效,更牛X的是,擴展方法中同樣可以使用泛型。
下面是一個例子,展示了怎樣擴展IEnumerable接口,增加一個RandomSelect的方法用于在表中隨機選取元素。
閱讀全文(865字)文章來源:
http://gccfeli.cn/2010/10/c-generic-extend-method.html
很久沒有做過逆向了,今天就玩了玩,并且玩了一整天。以下為研究成果。
Axp包其實是很簡單的,結構簡單,明文保存。
Axp文件格式大致上如下:
1.文件頭;
2.索引表;
3.文件名表;
4.數據。
其中,文件名表以文件名為(list)的文件存在于數據當中。我想,之所以要有這么一個東西,而不和索引表合二為一,恐怕是因為文件名是變長之故吧。
Axp文件頭的格式大致為:
1. 文件標示,一般為字符串“AXPK”,它占據了四個字節,占據空間為0x00-0x04;
2.索引表偏移量,為unit,它占據了四個字節,占據的空間為:0x10-0x13;
3.文件數,為unit,它占據了四個字節,占據的空間為:0x14-0x17。
文件頭占據40個字節,既是在0x00-0x27的空間內。
一般來說,索引表的偏移量為:0x60028,數據區的偏移量為:0x160028.
不過還是依照以下流程獲取偏移量為好:
1.獲取文件頭的索引表偏移量;
2.使用索引表偏移量定位到文件具體位置;
3.使用文件頭獲取到的文件數來讀取文件數條索引;
4.根據索引查找文件。
在
這里我是很納悶的:文件名表文件沒有特殊位置,也似乎沒有看到有文件頭保存的偏移量指向它,如何去獲取這個文件是個很令我困擾的事情。另外,表里面的文件
名順序和資源包里面的文件排列順序似乎是沒有一個順序對應的關系的。如何將索引表和文件名表進行關聯,又是一個令人困擾的事情,或許能夠解釋通的大概就是
他們是讀取后需要排序的,或者說還有什么特別的相關數據我沒有獲取到。
索引表的索引:
1.偏移量,unit;
2.文件大小,unit;
3.標志位,unit,現在似乎只有0x00000000和0x80000000兩個標識,用于標示該文件是否可以被使用或者已經被刪除。
到現在為止,最令我困惑的就是那兩張表該如何進行關聯和綁定數據。還有就是如何去獲取文件名表。
說明:本文章純屬學習之用,如有商業之用,與本人無關。網絡游戲《天龍八部》采用的是Ogre3d作為其客戶端渲染引擎,他們對之做了許多自定義的修改,在這里作為學習只用,特別說明一下其自定義的Skeleton的格式,以及如何加載的辦法。
天龍八部加入了這樣一個區段:
SKELETON_ANIMATION_TRACK_MULTI_KEYFRAME 0x4120 (16672)
在加入了這個區段的內容之后,其格式大概就是這樣一個樣子:
enum SkeletonChunkID {
SKELETON_HEADER = 0x1000,
// char* version : Version number check
SKELETON_BONE = 0x2000,
// Repeating section defining each bone in the system.
// Bones are assigned indexes automatically based on their order of declaration
// starting with 0.
// char* name : name of the bone
// unsigned short handle : handle of the bone, should be contiguous & start at 0
// Vector3 position : position of this bone relative to parent
// Quaternion orientation : orientation of this bone relative to parent
// Vector3 scale : scale of this bone relative to parent
SKELETON_BONE_PARENT = 0x3000,
// Record of the parent of a single bone, used to build the node tree
// Repeating section, listed in Bone Index order, one per Bone
// unsigned short handle : child bone
// unsigned short parentHandle : parent bone
SKELETON_ANIMATION = 0x4000,
// A single animation for this skeleton
// char* name : Name of the animation
// float length : Length of the animation in seconds
SKELETON_ANIMATION_TRACK = 0x4100,
// A single animation track (relates to a single bone)
// Repeating section (within SKELETON_ANIMATION)
// unsigned short boneIndex : Index of bone to apply to
SKELETON_ANIMATION_TRACK_KEYFRAME = 0x4110,
// A single keyframe within the track
// Repeating section
// float time : The time position (seconds)
// Quaternion rotate : Rotation to apply at this keyframe
// Vector3 translate : Translation to apply at this keyframe
// Vector3 scale : Scale to apply at this keyframe
SKELETON_ANIMATION_TRACK_MULTI_KEYFRAME = 0x4120,
// A multiple keyframe within the track
// Repeating section
// float length : Length of the animation in seconds
// float flags : Length of the animation in seconds
// float time : The time position (seconds)
// Quaternion rotate : Rotation to apply at this keyframe
// Vector3 translate : Translation to apply at this keyframe
SKELETON_ANIMATION_LINK = 0x5000
// Link to another skeleton, to re-use its animations
// char* skeletonName : name of skeleton to get animations from
// float scale : scale to apply to trans/scale keys
};
然后我們打開OgreSkeletonSerializer.cpp找到SkeletonSerializer::readAnimationTrack的實現,然后替換為下面的代碼:
void SkeletonSerializer::readAnimationTrack(DataStreamPtr& stream, Animation* anim,
Skeleton* pSkel)
{
// unsigned short boneIndex : Index of bone to apply to
unsigned short boneHandle;
readShorts(stream, &boneHandle, 1);
// Find bone
Bone *targetBone = pSkel->getBone(boneHandle);
// Create track
NodeAnimationTrack* pTrack = anim->createNodeTrack(boneHandle, targetBone);
// Keep looking for nested keyframes
if (!stream->eof())
{
unsigned short streamID = readChunk(stream);
while( (streamID == SKELETON_ANIMATION_TRACK_KEYFRAME || streamID == SKELETON_ANIMATION_TRACK_MULTI_KEYFRAME)
&& !stream->eof())
{
if (streamID == SKELETON_ANIMATION_TRACK_MULTI_KEYFRAME)
{
// TLBB 新增了此部分
unsigned short len;
unsigned short flags;
readShorts(stream, &len, 1);
readShorts(stream, &flags, 1);
int count = (mCurrentstreamLen - 4 - 4) / 4;
if (len != count / 8)
{
len = len;
}
float time;
for (int i = 0; i < len; i += 1)
{
readFloats(stream, &time, 1);
TransformKeyFrame *kf = pTrack->createNodeKeyFrame(time);
Quaternion rot = Quaternion::IDENTITY;
if (flags & 1)
{
readObject(stream, rot);
}
kf->setRotation(rot);
Vector3 trans = Vector3::ZERO;
if (flags & 2)
{
readObject(stream, trans);
}
kf->setTranslate(trans);
}
}
else
{
readKeyFrame(stream, pTrack, pSkel);
}
if (!stream->eof())
{
// Get next stream
streamID = readChunk(stream);
}
}
if (!stream->eof())
{
// Backpedal back to start of this stream if we've found a non-keyframe
stream->skip(-STREAM_OVERHEAD_SIZE);
}
}
}
保存然后重新編譯Ogre就OK了,理論上就是可以加載其骨骼動畫了。
另外,其骨骼文件名,模型文件名都是用的中文,而VS2005對中文路徑名的支持是有一個bug的,解決此問題參見下面這篇文章:
http://www.shnenglu.com/tx7do/archive/2008/12/09/68897.html
每次在telnet下退出珞珈山水,都會隨機出現一個離版畫面。
我最喜歡的是這首詩
就這樣走了嗎 親愛的 Felicia
你可知道 與你相遇在這十字路口 是我的最美回憶
我知道你會回來 在這熟悉路口 不要說是否曾經相約 不去說諾言 我知道你的腳步 終會明白 這心的約定
讓我靜靜等你再次出現
|