??xml version="1.0" encoding="utf-8" standalone="yes"?>久久经典免费视频,久久精品亚洲日本波多野结衣,国产精品伊人久久伊人电影http://www.shnenglu.com/heath/There is no end, it is just the beginning! - A Game Developer's Noteszh-cnTue, 06 May 2025 23:13:28 GMTTue, 06 May 2025 23:13:28 GMT60解决在Unity中封装Debug.Log后代码行定位问题http://www.shnenglu.com/heath/archive/2016/06/21/213777.htmlHeathHeathTue, 21 Jun 2016 02:53:00 GMThttp://www.shnenglu.com/heath/archive/2016/06/21/213777.htmlhttp://www.shnenglu.com/heath/comments/213777.htmlhttp://www.shnenglu.com/heath/archive/2016/06/21/213777.html#Feedback3http://www.shnenglu.com/heath/comments/commentRss/213777.htmlhttp://www.shnenglu.com/heath/services/trackbacks/213777.html众所周知Q代码中使用Debug.Log*输出的日志在Unity的ConsoleWindow中可以双d位到对应的代码行Q然而将Debug.Log*装到自q日志cM后,定位失L义了(jin)。原因很单,Unity只会(x)处理StackFrame的栈信息,它们保存在LogEntry中,栈顶的方法对应的脚本文g?x)以其instanceID来保存,其他StackTrace信息则以字符串结果存储,最l在双击ConsoleWindow中的ListView条目旉过指定?jin)OnOpenAssetAttribute的callback来打开代码~辑器。其中,OnOpenAssetAttribute参数用于处理存在多个Callback时的优先U问题?/p>

image

通过阅读ConsoleWindow代码Q想C(jin)一个解x\Q自己实现OnOpenAssetQ通过获取ConsoleWindow中的ListView得到当前选中的rowQ然后在LogEntries中取得该行对应的LogEntryQ其中的condition字段保存?jin)StackTrace字符Ԍ最后过滤掉包装的日志类后拿到脚本文件名和代码行Q用OpenFileAtLineExternal直接打开。在实现q程中发玎ͼ完全没有必要拿到LogEntryQ因为ConsoleWindow中的m_ActiveText是StackTrace字符Ԍ直接处理好?jin)?/p>

在想到该Ҏ(gu)之前Q看q两个解x法:(x)1Q将日志cȝ译成DLLQ?Q输出日志时自己记录StackFrameQ通过一pd手段在OnOpenAsset查找LogEntry中对应的StackFrame。不q这两种Ҏ(gu)都不能满个人的完美M情节Q方?失去?jin)预~译宏的灉|Q一旦日志系l改动需要重~DLL和处理依赖,Ҏ(gu)2低效且过于复杂?/p>

最后摘Z码供参考,实现环境为:(x)Unity 4.7.5f1, UnityVS+Visual Studio 2015 Pro?/p>

2016-06-21_10-35-04



Heath 2016-06-21 10:53 发表评论
]]>
Unity中短距离寻\Ҏ(gu)http://www.shnenglu.com/heath/archive/2016/03/13/212997.htmlHeathHeathSun, 13 Mar 2016 10:40:00 GMThttp://www.shnenglu.com/heath/archive/2016/03/13/212997.htmlhttp://www.shnenglu.com/heath/comments/212997.htmlhttp://www.shnenglu.com/heath/archive/2016/03/13/212997.html#Feedback0http://www.shnenglu.com/heath/comments/commentRss/212997.htmlhttp://www.shnenglu.com/heath/services/trackbacks/212997.html

从A*到Navmesh都是完备的寻路方案,能满Q意距ȝ路径搜烦(ch)。它们都需要根据场景预先生成相x据(A*是规整的2D格子数据QNavmesh则是mesh数据Q,在场景尺寸确定的情况下,Navmesh法的网格数?x)随障碍的复杂程度改变,而A*是固定的。就时空复杂度而言Q通常情况下Navmesh要优于A*Q但一些优化的变种A*法Q如QHierarchy A*Q在长距d路上要优于Navmesh。然而对于动态改变的场景障碍Q在使用以上两种法旉?x)有性能和设计上的限制。在实际目中,我们通常战斗约束在一定区域内Q而且q些区域有可能是诸如Udq_之类的,此时A*和Navmesh可能?x)面临无法用的境地。下面这个方案是在洗澡时H然惛_的,切点应该称之ؓ(f)遉K法Q因为它源自之前做智能避障小车时的经验?/p>

设,角色到目标点的方向向量ؓ(f)D0Q投线长度为LQ探间隙角为θ,N = 180 / θQ算法流E如下:(x)

image

法通过优先搜烦(ch)目标方向左右无障空_(d)减少(g)次敎ͼ通过讄θ和L可以控制(g)精度和范围。此外,讄合适的Collision Matrix和检频率可以约束RayCast的性能开销?/p>

Heath 2016-03-13 18:40 发表评论
]]>
Font Outline in Unityhttp://www.shnenglu.com/heath/archive/2016/02/05/212793.htmlHeathHeathFri, 05 Feb 2016 09:36:00 GMThttp://www.shnenglu.com/heath/archive/2016/02/05/212793.htmlhttp://www.shnenglu.com/heath/comments/212793.htmlhttp://www.shnenglu.com/heath/archive/2016/02/05/212793.html#Feedback0http://www.shnenglu.com/heath/comments/commentRss/212793.htmlhttp://www.shnenglu.com/heath/services/trackbacks/212793.html

团队在用UGUIӞ发现其Outline实现是将文字的顶点在上下左右方向上做偏移生成?jin)新的顶点,所以顶点和三角面数量都增加?倍。受Glow中Gaussian Filter可实现边界外扩效果的启发Q做?jin)个实验Q在W一个pass中用Filter对Font Texture的Alphaq行4或?方向采样Q第二个pass正常渲染字体Q然后将两者进行Alpha blend?/p>

image

No Outline

image

Tow-Pass Outline with Four-Direction Sampling

image

Outline in UGUI

从结果上来看Q在一定范围的U理坐标偏移下可以接受,但限制也很明显,下图是偏U过大导致失?/p>

image



Heath 2016-02-05 17:36 发表评论
]]>
Real-time Cutscene中的摄像机插值研I?/title><link>http://www.shnenglu.com/heath/archive/2013/10/26/203921.html</link><dc:creator>Heath</dc:creator><author>Heath</author><pubDate>Sat, 26 Oct 2013 01:07:00 GMT</pubDate><guid>http://www.shnenglu.com/heath/archive/2013/10/26/203921.html</guid><wfw:comment>http://www.shnenglu.com/heath/comments/203921.html</wfw:comment><comments>http://www.shnenglu.com/heath/archive/2013/10/26/203921.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.shnenglu.com/heath/comments/commentRss/203921.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/heath/services/trackbacks/203921.html</trackback:ping><description><![CDATA[<p>     很多DCC工具都提供了(jin)Curves EditorQ通过控制Ҏ(gu)构造插值曲U,q样可以_地插DqV在我们游戏的过场编辑器中,我们q没有开发这cdP一斚w׃旉人力有限Q另一斚w希望能够提供一U直观简便的方式辑ֈ惌的效果。因此我们支持两U摄像机路径创徏Ҏ(gu)Q?Q以摄像角直接将摄像机摆到想要位|,保存此时摄像机的位置与旋转;2Q将3DS Max中的路径导出为游戏的q场格式。前者可以满?0%的过场编辑需求,后者满了(jin)10%的复杂\径编辑需求?<p>     不管使用那种方式Q都需要将L点进行插|interpolationQ以便得到^滑\径。这里就牉|C|插值和朝向插倹{?<p>     从插值函C可分Zc:(x)1Q线性;2Q多式Q?Q样条。顾名思义Q线性插值采用线性函敎ͼ多项式插值采用多式Q而样条插值则采用?jin)一l多式l成的分D函数。由于摄像机的关键\径点通常都会(x)大于2个,所以插值方法上必选取hҎ(gu)?<p><font size="4" face="Arial"><strong>一、位|插?/strong></font></p> <p><font size="3"><strong>1.1 hcd选择</strong></font> <p>     在这里我们仅考虑三次h插|因ؓ(f)它们可达到C2q箋。三ơ样条中主要以Bezier、Catmull-Rom、均匀Bh查对象Q它们都h计算开销的优点。可以通过下面公式来定义它们:(x) <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(18)_2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Image(18)" border="0" alt="Image(18)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(18)_thumb.png" width="500" height="117"></a> <p>     化ؓ(f)Q?<p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(19)_2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Image(19)" border="0" alt="Image(19)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(19)_thumb.png" width="130" height="32"></a> <p>     下面表格列出?jin)三U插值曲U对应的G和MQ?<p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(20)_2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Image(20)" border="0" alt="Image(20)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(20)_thumb.png" width="483" height="339"></a> <p>     如下图所C,?个点q行Bezier插值得到的曲线只会(x)有两个点被曲U穿q,而B-Spline插值得到的曲线不会(x)l过控制点,只有Catmull-Rom Spline可以得到I过除v点和l点之间的所有控制点。正因ؓ(f)Catmull-Romhq个Ҏ(gu),使得它被q泛地应用在关键帧^滑插gQ因此我们选择?jin)Catmull-Romh作ؓ(f)摄像Z|点的插值算法?<p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(21)_2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Image(21)" border="0" alt="Image(21)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(21)_thumb.png" width="400" height="917"></a> <p><font size="3"><strong>1.2 实现</strong></font> <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image_2.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image" border="0" alt="Image" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image_thumb.jpg" width="759" height="732"></a> <p><font size="3"><strong>参考:(x)</strong></font> <p>[1] <a >Mathematics for 3D Game Programming and Computer Graphics 3e by Eric Lengyel</a> <p>[2] <a >http://en.wikipedia.org/wiki/Catmull-Rom_spline#Catmull.E2.80.93Rom_spline</a> <p>[3] <a >http://www.codeproject.com/Articles/30838/Overhauser-Catmull-Rom-Splines-for-Camera-Animatio</a> <p><font size="4"><strong>二、朝向(旋{Q插?/strong></font>   <p><font size="3"><strong>2.1 Euler Angles VS Quaternion</strong></font>         <p>     三维I间中描q旋转的主要Ҏ(gu)有Euler Angles和Quaternion。Euler Angles有三个明昄问题Q?Q三轴上的旋转顺序敏感;2QGimbal Lock现象D旋{自由度丢失;3Q独立地对三个旋转分量进行插|忽略?jin)三轴之间的依赖关系Q导致插值结果不理想。与Euler Angles不同的是QQuaternion没有旋转分解到三个轴向上,而是用一个旋转u和绕该u的旋转角度来描述Q所以从Ҏ(gu)上消除了(jin)Euler Angles的三大问题。有关Quaternion的详l描q可参考[1]Q在此不再篏q?<p><font size="3"><strong>2.2 LERP VS SLERP</strong></font> <p>     四元数线性插|Linear Quaternion interpolationQ的计算公式为:(x) <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(1)_2.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Image(1)" border="0" alt="Image(1)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(1)_thumb.jpg" width="510" height="306"></a> <p>     四元数球面线性插|Spherical Linear Quaternion interpolationQ的计算公式为:(x) <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(2)_2.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Image(2)" border="0" alt="Image(2)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(2)_thumb.jpg" width="315" height="43"></a> <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(3)_2.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Image(3)" border="0" alt="Image(3)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(3)_thumb.jpg" width="221" height="138"></a> <p>     其中Qؓ(f)两个四元数的夹角?<p>     Z(jin)方便展示Q我们考虑?D情况对角度Vq行两次插|两种法在插值效果上存在的差异,如下图(b为LERP、c为SLERPQ:(x) <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(4)_2.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Image(4)" border="0" alt="Image(4)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(4)_thumb.jpg" width="640" height="128"></a> <p>     从图中可以看出LERP其实是对两四元数在圆上的弦进行了(jin){分Q而SLERP则是对圆弧进行等分。由此得出的l论是,SLERP得到?jin)比LERP更^滑的插值结果?<p>     Z(jin)保证插值曲U的C2q箋性,需要用球面四边Ş插|Spherical Quadrangle interpolationQ方法。例如,对q1和q2插|首先要用q0、q1、q2、q3计算Z个控制点QInner Quadrangle PointQ,公式如下Q?<p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(5)_2.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Image(5)" border="0" alt="Image(5)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(5)_thumb.jpg" width="286" height="79"></a> <p>     然后通过下式得到最l插值结果:(x) <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(6)_2.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Image(6)" border="0" alt="Image(6)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(6)_thumb.jpg" width="760" height="41"></a> <p><font size="3"><strong>2.3 实现</strong></font> <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(7)_2.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image(7)" border="0" alt="Image(7)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(7)_thumb.jpg" width="696" height="1022"></a> <p>     上面代码没有考虑两个四元C间夹角大?80的情c(din)例如,考虑q1->q2的插D度?gt;180Q我们可以让q1->q2反向旋{2π-θQ即旋{-(2π-θ)Q根据四元数的定义[v*sin(θ/2) , cos(θ/2)]Q那么对q2q行处理变ؓ(f)[-v*sin(θ/2) , -cos(θ/2)]。这个处理可以放在AddSplinePoint中来做:(x) <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(8)_2.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image(8)" border="0" alt="Image(8)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/Real-time-Cutscene_7DED/Image(8)_thumb.jpg" width="527" height="234"></a> <p><font size="3"><strong>参考:(x)</strong></font> <p>[1] <a >Quaternions, Interpolation and Animation by EB Dam - 1998</a> <p>[2] <a >Game Engine Architecture by Jason Gregory - 2009</a> <p>[3] <a >https://theory.org/software/qfa/writeup/node12.html</a><img src ="http://www.shnenglu.com/heath/aggbug/203921.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/heath/" target="_blank">Heath</a> 2013-10-26 09:07 <a href="http://www.shnenglu.com/heath/archive/2013/10/26/203921.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Windowsq_下针对C/C++目的内存泄漏检方?/title><link>http://www.shnenglu.com/heath/archive/2013/10/26/203920.html</link><dc:creator>Heath</dc:creator><author>Heath</author><pubDate>Sat, 26 Oct 2013 00:55:00 GMT</pubDate><guid>http://www.shnenglu.com/heath/archive/2013/10/26/203920.html</guid><wfw:comment>http://www.shnenglu.com/heath/comments/203920.html</wfw:comment><comments>http://www.shnenglu.com/heath/archive/2013/10/26/203920.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.shnenglu.com/heath/comments/commentRss/203920.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/heath/services/trackbacks/203920.html</trackback:ping><description><![CDATA[<p>     ׃语言在自动内存管理上的欠~,C/C++在内存管理上从来都是需要程序员心(j)处理的一个方面,当项目代码上?jin)一定规模,内存消耗和泄漏׃(x)成ؓ(f)E序E_q行的第一大敌。如果不在项目之初就建立内存理和泄漏检机Ӟ后面蛋疼的问题就?x)接t而来。这文章着重讨论内存泄漏检,而内存管理与具体目cd关系密切Q后面有旉我会(x)着重游戏项目来讨论?<p>     内存泄漏(g)的基本步骤是:(x)1Q包装(重蝲Q内存分?释放APIQ?Q进行内存分配时C相关信息Q地址、大、调用栈Q?Q释放时清除之前记录的对应信息;4Q程序退出时Q确保在所有内存释放操作完成之后)(j)Q输出剩下的记录。其中,对进行分配操作是的调用栈回溯是个重点信息Q它能够帮助我们扑և内存泄漏代码?<p>     Windows中的Dbghelp库提供了(jin)丰富的调试API。StackWalk应该是进行栈回溯最直接的一U接口了(jin)Q但是它不够快。如果能先记录下调用栈上的CALL指o(h)地址Q然后在输出日志时解析出W号Q将?x)大大降低检机制对E序本n性能的媄(jing)响。Dbghelp库中提供?jin)Sym*FromAddrpdAPIQ可以通过指o(h)地址获取函数W号Q那么剩下的是如何记录指o(h)地址的问题了(jin)。从|上借了(jin)一张x86调用栈示意图Q如下:(x) <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/WindowsCC_7CB0/Image(12)_2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Image(12)" border="0" alt="Image(12)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/WindowsCC_7CB0/Image(12)_thumb.png" width="263" height="458"></a> <p>     从图中可以看出,Callee的EBP始终指向Caller的EBPQEBP下面是指向Caller下一条指令(注意x86体系下栈的增长方向是地址Q,因此通过EBP可以回溯整个调用栈?jin)。通过下面代码可以实现此功能:(x) <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/WindowsCC_7CB0/Image(13)_2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image(13)" border="0" alt="Image(13)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/WindowsCC_7CB0/Image(13)_thumb.png" width="512" height="335"></a> <p>     宏参数frame是个void*指针数组Q数l的大小取决于想要回溯的栈深度。内存分配和回收的包装代码如下:(x) <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/WindowsCC_7CB0/Image(14)_2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image(14)" border="0" alt="Image(14)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/WindowsCC_7CB0/Image(14)_thumb.png" width="768" height="311"></a> <p>     我们看到Q内存管理系l内部终I还是要使用语言提供的内存分?释放APIQ只要配对实C(jin)分配与释攄理,pȝ内部的无泄漏是很Ҏ(gu)保证的。在q里着重讲解原理,׃重蝲new/delete operator?jin)。最后看一下调用栈函数W号的回溯代码:(x) <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/WindowsCC_7CB0/Image(15)_2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image(15)" border="0" alt="Image(15)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/WindowsCC_7CB0/Image(15)_thumb.png" width="1236" height="868"></a> <p>     我们用下面代码做试用例Q?<p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/WindowsCC_7CB0/Image(16)_2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image(16)" border="0" alt="Image(16)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/WindowsCC_7CB0/Image(16)_thumb.png" width="537" height="567"></a> <p>     泄漏(g)结果:(x) <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/WindowsCC_7CB0/Image(17)_2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image(17)" border="0" alt="Image(17)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/WindowsCC_7CB0/Image(17)_thumb.png" width="800" height="322"></a> <p>参考:(x) <p>[1] <a >Using DbgHelp</a> <p>[2] <a >Intel x86 Function-call Conventions - Assembly View</a><img src ="http://www.shnenglu.com/heath/aggbug/203920.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/heath/" target="_blank">Heath</a> 2013-10-26 08:55 <a href="http://www.shnenglu.com/heath/archive/2013/10/26/203920.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>3DS Max坐标pMD3D左手pȝ单{换方?/title><link>http://www.shnenglu.com/heath/archive/2013/06/08/200890.html</link><dc:creator>Heath</dc:creator><author>Heath</author><pubDate>Sat, 08 Jun 2013 14:31:00 GMT</pubDate><guid>http://www.shnenglu.com/heath/archive/2013/06/08/200890.html</guid><wfw:comment>http://www.shnenglu.com/heath/comments/200890.html</wfw:comment><comments>http://www.shnenglu.com/heath/archive/2013/06/08/200890.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.shnenglu.com/heath/comments/commentRss/200890.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/heath/services/trackbacks/200890.html</trackback:ping><description><![CDATA[     摘要:   <a href='http://www.shnenglu.com/heath/archive/2013/06/08/200890.html'>阅读全文</a><img src ="http://www.shnenglu.com/heath/aggbug/200890.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/heath/" target="_blank">Heath</a> 2013-06-08 22:31 <a href="http://www.shnenglu.com/heath/archive/2013/06/08/200890.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>解决A*寻\中边~行走问?/title><link>http://www.shnenglu.com/heath/archive/2013/05/04/199973.html</link><dc:creator>Heath</dc:creator><author>Heath</author><pubDate>Sat, 04 May 2013 15:49:00 GMT</pubDate><guid>http://www.shnenglu.com/heath/archive/2013/05/04/199973.html</guid><wfw:comment>http://www.shnenglu.com/heath/comments/199973.html</wfw:comment><comments>http://www.shnenglu.com/heath/archive/2013/05/04/199973.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/heath/comments/commentRss/199973.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/heath/services/trackbacks/199973.html</trackback:ping><description><![CDATA[<p>     用碰撞体来约束世界范围已l用得很q泛?jin),玩家与世界边~的交互问题也容易用撞面的法线和玩家朝向来解决。然而对于一个基于A* PathFinding的游戏,貌似q没有h去考虑和解册个问题。最初考虑q个问题Q是因ؓ(f)游戏中加入了(jin)AWSD的移动方式,当碰到阻挡就?rn)止不动了(jin),加上有时L刷得与场景不太脓(chung)合,造成玩家在移动上的不爽快。考虑下图的情况,蓝色三角是角ԌU色U段l出?jin)前q方向和l点Q游戏中配置色朝向上5m处)(j)?<p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/988bf6b67b08_14D26/Image(9)%5B6%5D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Image(9)[6]" border="0" alt="Image(9)[6]" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/988bf6b67b08_14D26/Image(9)%5B6%5D_thumb.png" width="503" height="290"></a> <p>     我想?jin)两U方案,最初的Ҏ(gu)灉|来自光线反射Q如下图所C?<p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/988bf6b67b08_14D26/Image(10)_2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Image(10)" border="0" alt="Image(10)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/988bf6b67b08_14D26/Image(10)_thumb.png" width="516" height="282"></a> <p>     因ؓ(f)L格子是u寚w的,通过法向量n可以得到b点的反射向量e'-oQ将|e'-o|限定在一个固定|此时如果e'不在L里面Q就它作ؓ(f)新的l点。该Ҏ(gu)的实验结果不太o(h)人满意,当角色离L较近时断l感太明显,因ؓ(f)|e' - b|的长度较短。另外它不能处理e'在阻挡里的情况,被卡住不动的概率依然较大?<p>     W二U方案是Ҏ(gu)Ud向在一个u向找一个可达试探点Q然后用限制?jin)搜索空_(d)搜烦(ch)节点?0以内Q的A*法扑ֈ一条到试探点的路径Q如下图?<p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/988bf6b67b08_14D26/Image(11)_2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Image(11)" border="0" alt="Image(11)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/988bf6b67b08_14D26/Image(11)_thumb.png" width="506" height="285"></a> <p>     设diff_x = l点x - L(fng)xQdiff_y = l点y - L(fng)yQ当diff_x > diff_yQ认定ؓ(f)向x方向上移动,在这U情况下在终点y轴向上?0个格子内LC个最接近l点的无L点(U它为可达试探点Q。由于试探点与玩家当前点极有可能是直U不q通的Q而且它们不可能太q,所以用了(jin)一个将搜烦(ch)节点个数限制?0以内A*来得C条\径。该Ҏ(gu)大部分情况都能在边缘扑ֈ合理点,但如果玩家垂直面朝阻挡内Ud且不能在限制搜烦(ch)范围内找到可辄Q角色就?x)卡住不动,q种情况只能让玩家自己调整一下朝向了(jin)?<img src ="http://www.shnenglu.com/heath/aggbug/199973.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/heath/" target="_blank">Heath</a> 2013-05-04 23:49 <a href="http://www.shnenglu.com/heath/archive/2013/05/04/199973.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>toLua++的导出函数如何访问Lua Tablehttp://www.shnenglu.com/heath/archive/2013/02/12/197808.htmlHeathHeathTue, 12 Feb 2013 11:30:00 GMThttp://www.shnenglu.com/heath/archive/2013/02/12/197808.htmlhttp://www.shnenglu.com/heath/comments/197808.htmlhttp://www.shnenglu.com/heath/archive/2013/02/12/197808.html#Feedback0http://www.shnenglu.com/heath/comments/commentRss/197808.htmlhttp://www.shnenglu.com/heath/services/trackbacks/197808.html有些函数需要向luaq回多个l果Q将q些l果存在table中是理所当然的。因为toLua++已经自动生成?jin)函数的wrapperQ所以没办法直接栈tableq回lLua。好在toLua预留?jin)lua_Objectq个cdQ可以代表lua中的McdQ其实它只是int的typedef|了(jin)Q主要是在toLua解析E序时作为标C生tolua_tovalue调用。在C/C++函数中,需要检查一下栈是否ؓ(f)tablecdQ进行table元素的插入操作,例子函数如下Q?pre class="code">void ActorMgr::GetPlayerEntityIDs( lua_Object lua_table ) { TEntityListIt tIt ; std::list <int> result; for(int i = 0; i < ACOTOR_BUCKET_LEN ; ++i) { for(tIt =mSceneEntities[i].mEntities.begin(); tIt != mSceneEntities[i].mEntities.end( ); ++tIt ) { TActorPtr tpActor = tIt->second->mpActor ; if(tpActor ->GetActorType() == LOCAL_PLAYER) { result.push_front(tpActor->GetEntityID()); } else if (tpActor-> GetActorType() == REMOTE_PLAYER ) { result.push_back(tpActor->GetEntityID()); } } } lua_State* L = LuaVM::GetInstPtr()->mLS ; assert(lua_istable (L , -1)); std::list <int>:: iterator iter = result. begin(); for(int i = 1; iter != result .end(); ++ iter , ++i ) { lua_pushinteger(L , *iter); lua_rawseti(L , -2 , i); } lua_pop(L , 1); }

需要注意的是,如果是多个参敎ͼLua的压栈顺序是object pointer、参C左到叻I所以栈元素是函数{֐最双的参数?/p>

Heath 2013-02-12 19:30 发表评论
]]>
Lua和C的那些事http://www.shnenglu.com/heath/archive/2013/02/12/197807.htmlHeathHeathTue, 12 Feb 2013 11:17:00 GMThttp://www.shnenglu.com/heath/archive/2013/02/12/197807.htmlhttp://www.shnenglu.com/heath/comments/197807.htmlhttp://www.shnenglu.com/heath/archive/2013/02/12/197807.html#Feedback1http://www.shnenglu.com/heath/comments/commentRss/197807.htmlhttp://www.shnenglu.com/heath/services/trackbacks/197807.html        Lua和C是天生的好基友,语言开发者提供了(jin)一pdAPIQ让他们通过栈进行交。用Lua做游戏逻辑开发有些时日了(jin)Q下面主要针对Lua C API的应用进行ȝ?/p>

一、扩展Lua

        Lua核心(j)很小Q主要包含一个解释器Q其他功能可以通过动态库的Ş式作为插件来扩展Qio、string、math、table{内|库都是通过此方式来实现Q只是他们被集成C(jin)一个lua.dll中Ş?jin)。制作一个动态库形式的moduleQ需要在代码中通过luaL_Reg数组指定lua function到c function的映,接着实现c functionQ最后在luaopen_xxx(xxx为module name)注册q个luaL_Reg。这里给Z个非常简单的例子Q它使用VC++创徏一个Console DLLQ?/p>

#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
#include <math.h>

int mysin (lua_State* L);

static const struct luaL_Reg mymathlib [] =
{
    { "sin" , mysin } ,
    { NULL , NULL }
};

static int mysin( lua_State* L )
{
    double d = luaL_checknumber( L , 1);
    lua_pushnumber(L , sin( d));
    return 1;
}

__declspec(dllexport) int luaopen_mymathlib(lua_State * L)
{
    luaL_register(L , "mymathlib" , mymathlib);
    return 1;
}

~译成dll后放到l(f)ua解释器目录下。Lua test codeQ?/p>

require "mymathlib"

local a = mymathlib.sin(0.5)
print(a)

二、作本系l?/strong>

        Lua应用最多的领域当属游戏开发,W(xu)OW的UI和插件让它名声大噪。在q种应用中,Lua作ؓ(f)应用E序的一个子pȝQ用作配|或者业务处理。在Lua与应用集成v来时Q必ȝ到Lua C APIQ根据其规范Q你需要写一pd的static函数Q作为Lua与应用程序的_合代码。如果要在Lua使用C++对象Q可其作ؓ(f)userdataQؓ(f)它创Z个metatableQƈ粘合函数放入其中,关键是要让__index指向metatable自nQ这样当Lua讉Kuserdata的fieldӞ__index?x)引导它L索metatable自nQ从而获得注册的_合函数?/p>

        有很多开源的_合代码生成器,他们都是在precompile时做?jin)一些工作,因而不是用macro是templateQ这两种Ҏ(gu)的代表是toLua++和luaBind。个人更們֐使用toLua++Q一斚wq种方式比较直白Q另一斚w本h׃使用template。在WGAME中也原来写得不是很好的bind代码替换成了(jin)toLua++Q目前UI和关卡逻辑重度使用?jin)LuaQ生的bind代码?x)有几万行,׃目采用事g驱动的方式,在profile时看到对游戏整体性能影响非常。luaBind大概?jin)解q,没有在实际项目中用过Q在此就不做评论?jin)?/p>

        在用toLua++时我最好奇的是它对C++关键Ҏ(gu)是如何支持的。除?jin)上面说的成员函数外Q对于多态的支持Q它是通过在static函数后加~号Q调用时判断参数是否对应来遍历找到正static函数的;对于复杂成员变量Q它?x)自动生成get/setҎ(gu)Q而承关p,则是通过子类父cM为metatable来实现。秉着重新发明车轮的精,我试着写了(jin)一个简化的自动生成器[我在github?/a>]。我定义?jin)几个关键字作?f)cMҎ(gu)的导出标识:(x)

    {module_begin = "LUACBIND_MODULE_BEGIN" , module_end = "LUACBIND_MODULE_END" , method_begin = "LUACBIND_METHOD_BEGIN" , method_end = "LUACBIND_METHOD_END"}

    util.h定义?jin)生bind代码需要的宏,parser.luaҎ(gu)定的.h文gq行扫描产生bind代码Q在main函数中register后,可以在lua中用了(jin)?/p>

三、调试器

        Lua的C API和Debug库提供了(jin)实现调试器的必要Ҏ(gu)Q对应了(jin)两种实现方式Q一U是Remdebug所采用的,直接用lua实现Q另外一U是使用C API。不哪U方式,使用HOOK都是必须的,但用Lua debug库会(x)比C API更方便,因ؓ(f)不用考虑栈^衡问题。在用C API实现调试器时Q可用lua_newthread创徏一个coroutineQ之后yield/resume/getstack/getlocal都作用它上面Qbreakpoint通常?x)采用在hook中yield的方式来实现Q但不能{hookq回之后去进行栈回溯Q因为traceexecҎ(gu)hook mask调用对应hook函数后,如果state是ؓ(f)LUA_YIELD状态,会(x)调用luaD_throwQ最l用longjmpD无法q行回溯?/p>

        利用春节值班两天清闲时光Q基于lua 5.2实现?jin)一个命令行调试器[我在github?/a>]Q目前仅有几个简单的功能Q加?q行lua脚本、设|?清除断点、单步、查看简单类型变量|命o(h)格式可参考README?/p>

Heath 2013-02-12 19:17 发表评论
]]>
单想?jin)一下《(chng)泡龙》的实现http://www.shnenglu.com/heath/archive/2012/11/27/195752.htmlHeathHeathTue, 27 Nov 2012 15:43:00 GMThttp://www.shnenglu.com/heath/archive/2012/11/27/195752.htmlhttp://www.shnenglu.com/heath/comments/195752.htmlhttp://www.shnenglu.com/heath/archive/2012/11/27/195752.html#Feedback0http://www.shnenglu.com/heath/comments/commentRss/195752.htmlhttp://www.shnenglu.com/heath/services/trackbacks/195752.html         领导最q在玩(chng)泡龙Q我也想不通ؓ(f)什么突然又对这么古老的游戏感兴了(jin)。昨晚在地铁上,奚w我这U游戏能做吗Q我不加思考回{道Q当?dng)简单。今天从深大地铁站出来,q个问题H然冒了(jin)出来Q到公司的\上花?jin)几分钟思考了(jin)下实现细节。从最单的玩法开始:(x)相同颜色的(chng)泡三个以上可以消除?

         核心(j)数据l构我采用链表数l,相同颜色且L的(chng)泡串成一个链表。采用这U数据结构,是基于下面考虑Q?Q通过颜色划分~小搜烦(ch)区域Q?Q没有排序,没有中间插入节点的需求;3Q节省内存。当?dng)游戏界面中的泡?chng)q是把它对应C个二l数l中Q每个元素存储一个(chng)泡对象的指针Q该对象中至包含:(x)颜色、坐标,分倹{如下图所C:(x)

Image(8)

         剩下需要考虑的是发射泡(chng)颜色如何产生Q如果从I关卡开始,前面可以用随机,后面p使用l计信息?jin)。在每个链表头可以统计该堆(chng)泡开闭性、数量等Q利用这些信息可以决定发(chng)泡的颜色?

Heath 2012-11-27 23:43 发表评论
]]>
HackingW记&mdash;&mdash;HDDHACKR自制320GB XBOX SLIM盘http://www.shnenglu.com/heath/archive/2012/11/27/195751.htmlHeathHeathTue, 27 Nov 2012 15:40:00 GMThttp://www.shnenglu.com/heath/archive/2012/11/27/195751.htmlhttp://www.shnenglu.com/heath/comments/195751.htmlhttp://www.shnenglu.com/heath/archive/2012/11/27/195751.html#Feedback0http://www.shnenglu.com/heath/comments/commentRss/195751.htmlhttp://www.shnenglu.com/heath/services/trackbacks/195751.html        ?60装上盘Q最大的好处是减少光驱的用,避免噪音。HDDHackr可以西部数据特定型L(fng)盘(WD3200BPVT、WD3200BEVT)刷写成微?60所使用的希L(fng)盘。比起不够厚道的MS出的官方盘Q我当然选择HDDHackr啦?

准备:

1QUSB DOS启动盘;

2QHDDHackr 1.3?60 320 GBZgQ?

3Q一台支持SATA接口的电(sh)脑。(我有一台SATAIII接口的PC和一台支持SATAII的ThinkPad X200W记本)(j)

        在PC上运行失败了(jin),出现不能写入的问题,在X200W记本上成功?jin)。在此过E中,只需要选择写入Zg,E序?x)帮你自动备份原Zg。需要妥善保原ZgQ以便后面需要用做数据硬盘的时候可以恢复?/p>

Heath 2012-11-27 23:40 发表评论
]]>
HackingW记&mdash;&mdash;为XBOX360 SLIM刷光?/title><link>http://www.shnenglu.com/heath/archive/2012/11/27/195750.html</link><dc:creator>Heath</dc:creator><author>Heath</author><pubDate>Tue, 27 Nov 2012 15:37:00 GMT</pubDate><guid>http://www.shnenglu.com/heath/archive/2012/11/27/195750.html</guid><wfw:comment>http://www.shnenglu.com/heath/comments/195750.html</wfw:comment><comments>http://www.shnenglu.com/heath/archive/2012/11/27/195750.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/heath/comments/commentRss/195750.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/heath/services/trackbacks/195750.html</trackback:ping><description><![CDATA[<p>        机器2011q?月䆾购于香港Q前后买?张正版碟。最q周末可以双休了(jin)Q正好Black OpsIIZ(jin)Q想到机器已l过?jin)保修期Q所以今天动手把机器拆开看看光驱的FW版本Q看能否为去买几元一张的子玩。根据网上的拆机教程Q需要破坏两个保修封条。拆开后发现是0225QJungleFlasher0.1.92(304)已经可以d它的DVD KEY?jin)。但我的PCL芯片l是INTEL P45Q南桥芯片ؓ(f)ICH10RQ虽然网上很多说该芯片不能识别徏?225Q但我还是抱着试一试的?j)态。因为机׃有eSATA接口Q所以我接机内部SATAU接在了(jin)SATA1位置Q其他位|不能被JF识别Q现象可能今天是SATA1可用Q明天就SATA6可用?jin),W(xu)IN7内部做了(jin)什么恐怕只能MS清楚?jin)?j)?<p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/XBOX360-SLIM_1475B/Image(7)_2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Image(7)" border="0" alt="Image(7)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/XBOX360-SLIM_1475B/Image(7)_thumb.png" width="504" height="377"></a> <p>        然后q入BIOSQ将SATA模式从AHCI改ؓ(f)Enhanced IDEQ在我的?sh)脑上也不能用Compatible IDEQ不然会(x)出现可以识别不能d的问题)(j)。至于XBOX何时启动的问题,我给出的l论是无所谓,如果XBOX后启动,则需要进讑֤理器扫瞄一下新讑֤。在整个操作q程中,虽然在设备管理器中看不到光驱Q但是进入JF的DVDKey 32늭是可以看到的Q注意选择I/O PortQ。如果是W一ơ提取光qKEYQDVD KEY一会(x)昄not foundQ这是正常的Q因为程序找不到与已知KEY匚w的。最后点击SlimKeyQ过E中不要unlock?<p>        接下来就是去|上?504Q将0225上提取的KEY合入其中?<p>        被骗?jin),拿到的还?225Q值得?jin)幸的是光驱?2q?月䆾的MXIC版,具体用什么方法破解的Q我也难的去拆开l究。问?jin)LTL(fng)是哪个版本,回答?.0。在|上又买?jin)两张LT3.0和一张不分版本的Q应该就是低于AP2.5的吧Q。结果是3.0可以安装Q运行提C"此光盘不支援Q,另外一张不?.0q是3.0的可以运行,于是开始怀疑光驱刷的是2.0。ؓ(f)?jin)验证自q怀疑,军_自己动手刷LT plus 3.0Q另一斚w也验证一下破解是否完(不用拆板焊线可以反复刷Q,l果决定是否退掉光驱?<p>        在Win7下试?jin)Nơ,SATA1,6都试?jin),是写入不?jin)Qstatus 0x051Q,但是可以识别和读KEY。没办法Q改变策略:(x)1)先用JF拿前面提取的KEY和LT+3.0合成ZgQ?)用U盘启动,到纯DOS下用dosflash来写入固件。这个方案很奏效Q成功写入固Ӟ到win7下用JF查看光驱KEY的状态是verified。启?60Q买的LT3.0子都能玩了(jin)?<p>        |上的资料繁杂而难以L别真伪,所以凡事都要自己实c(din)补充一下:(x) <p>1Qdashboard版本与刷光驱Zg有没有关p?没有。光q甉|接口提供三种?sh)?3.3?.0?2Q、出舱控制、托盘状态外其余都是地线Q所以刷机时的数据通讯只会(x)通过SATAU传输,因此360无法q预hq程。我用u盘离U从13599更新C(jin)最新的15574Q能玩「黑色行?」、「极?7」、「忍?」?<p>2Q验证光盘是否是LT3.0Q用abgx加蝲光盘信息Q如果出?strong>Topology data is currently verified</strong>p明是LT3.0Q注意对于超ȝ,普通光驱无法识别,或者读取出错)(j)?<p>3Qdosflash使用注意事项Q将SATAU接在第一个口上。进入dos后先别启?60Q运行dosflash一ơ,保所有sata接口没有错误提示。然后执行dosflashQ正常情况下应该没有错误提示Q最后选w直接选合好的Zg写入?<img src ="http://www.shnenglu.com/heath/aggbug/195750.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/heath/" target="_blank">Heath</a> 2012-11-27 23:37 <a href="http://www.shnenglu.com/heath/archive/2012/11/27/195750.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>针对CUDA的GPU架构知识与性能Ҏ(gu)http://www.shnenglu.com/heath/archive/2012/11/27/195748.htmlHeathHeathTue, 27 Nov 2012 15:13:00 GMThttp://www.shnenglu.com/heath/archive/2012/11/27/195748.htmlhttp://www.shnenglu.com/heath/comments/195748.htmlhttp://www.shnenglu.com/heath/archive/2012/11/27/195748.html#Feedback4http://www.shnenglu.com/heath/comments/commentRss/195748.htmlhttp://www.shnenglu.com/heath/services/trackbacks/195748.html     5q前《GPU Gems 2》中的“Octree Textures on the GPU”用C(jin)论文的实时纹理创作一节,那时候C(j)UDA才刚出生QOpenCL应该q在规范阶段Q所以将GPU用于加速和通用计算的成熟方法还是compution by texturing。至于同L(fng)计算量在CPU和GPU上跑Q性能到底提升多少Q也没有做过Ҏ(gu)实验。周末翻?jin)下《CUDA by Example: An Introduction to General-Purpose GPU Programming》,基本掌握?jin)用CUDA~写GPU思想和语法,比v数据做为纹理、Shader写算法来Q进步了(jin)不少Q?Q开发h员不需要熟(zhn)渲染管U及(qing)囑ŞAPIQ?Q不用花旉L建DX或者OpenGL的框Ӟ3QHost与Device代码L(fng)Q?Q不必采用Hacking思想处理包装成纹理的数据Q?Q可指定参与计算的线E数。有?jin)如此方便的~程环境Q就随手来做一下对比吧Q这个例子来自《CUDA by Example》的4.2.2生成Julia集?

     试代码需要做一些调_(d)才能更好C现出GPU的^行计优势,q其中牵涉到支持CUDA的GPU架构知识Q在q里做一下梳理?

     在Nvidia推出Fermi架构之前Q支持CUDA的Nvidia昄芯片都是由多个Streaming MultiprocessorQ简USMQ组成,每个SM包含?jin)八个Stream ProcessorQ简USPQ,每四个SPl成一个组Q也是说SM实际上可以看成包含两l?D的SIMD处理器。此外,每个SMq包含Register、share memory、texture cache以及(qing)constant cache。在执行 CUDA E序的时候,每个SM对应一?blockQ而每个SP是对应一?thread。虽然一个SM只有八个SPQ但是由于SPq行各种q算都有延迟Q更不用提内存存取的延迟?jin),因?CUDA 在执行程序的时候,实际是以 warp 为单位。目前的支持CUDA昑֍Q一?warp 里面?2?threadsQ分成两l?6 threads的half-warp。由于SP的运至有4个时钟周期的延迟Q因此对一?D的SP来说Q一ơ至执?6?threads(?half-warp)才能有效覆盖掉各U运的延迟[1]?

Image

?1

     在GeForce GTX 400pd上,Nvidia采用?jin)全新的Fermi架构[2]Q之后的昑֍的Compute Capability也从1.3跃升?.0。SP改名为CUDA CoreQ提升到?2?SM[3]。图2为Fermi核心(j)演变Q从GF104和由其发展v来的GF114、GF106、GF108的CUDA Core都上升到?8?SMQ支?.1的Compute CapabilityQ而GF100和GF110依旧?2个。最新基于Kepler架构的GeForce GTX 680支持3.0的Compute CapabilityQCUDA Core数量辑ֈ?92?SM?

Image(1)

?2

     ׃试q_采用的是GTX 560 TiQ所以需要分析一下它的架构。GTX 560 Ti?个SMl成Q下图中Q左Ҏ(gu)从程序获取的讑֤属性,双为单个SM内部l构CZ图。可以看刎ͼGTX 560 Ti的每个SM配备?jin)两个Warp调度器,因此每个周期对两个包?2个线E的Warpq行分发。另外,对于一个二l图像,为kernel指定2D的grid和block可代码更加直观。ؓ(f)此,block采用Q?6,16Q,d分配256个(64*4Qthreads在一个SM上执行,如果需要?024*1024的Julia分Ş图,则需要grid为(64,64Q?

Image(2) Image(3)

?3

     试q_为:(x)

Image(4)

     试代码说明Q?/strong>

     1Q代码分为CPU实现和CUDA实现Q?

     2Q均采用CPU计时Ҏ(gu)Q?

     3Q只针对计算部分试Q不包括内存分配、传输以?qing)文件写入?

     下面列出main函数代码Q左边ؓ(f)CPU实现Q右边ؓ(f)CUDA实现Q均~译为release版本?

Image(5)Image(6)

     试l论Q?/strong>CPU版本耗时244msQCUDA版本耗时2.1087ms。这可是100倍的效率提升啊。不qCPU版本没有l过多核优化Q所以这栯样对比实在不公^Q但q却凸显出CUDA Cƈ行思想融入语言规则的优ѝ?

out

     在惊讶GPU用作通用计算的执行效率时Q别忘了(jin)它还是有诸多应用上的问题Q?

     1)初始化耗时Q需要在昑֭分配I间Q然后将数据从内存copy到显存;
     2)数据量受GPU昑֭限制Q?br>     3)Ҏ(gu)w就需要GPU参与q算的程序,如:(x)3D游戏Q通用计算?x)争夺GPU资源Q如果做qQ?br>     4)计算数据之间的不相关性限制了(jin)GPU通用计算的应用范_(d)

     5)CPU法到适合GPU架构法的移植;

     最后,GPUg设计本n已l决定了(jin)它的强项是密集数据处理(如:(x)U学计算、医疗图像处理)(j)Q在逻辑处理斚wq是CPU的天下,所以它们是互补的,只会(x)有整合而非替代的趋ѝ?

[1] http://www2.kimicat.com/gpu%E7%9A%84%E7%A1%AC%E9%AB%94%E6%9E%B6%E6%A7%8B

[2] http://www.chip.cn/index.php?option=com_content&view=article&id=2857:geforce-gtx-400-gpu&catid=7:test-technology&Itemid=15

[3] http://www.geeks3d.com/20100606/gpu-computing-nvidia-cuda-compute-capability-comparative-table

[4] http://www.expreview.com/13590-2.html

[5] http://en.wikipedia.org/wiki/CUDA

Heath 2012-11-27 23:13 发表评论
]]>
Pentax的小眼睛http://www.shnenglu.com/heath/archive/2012/09/23/191723.htmlHeathHeathSun, 23 Sep 2012 09:34:00 GMThttp://www.shnenglu.com/heath/archive/2012/09/23/191723.htmlhttp://www.shnenglu.com/heath/comments/191723.htmlhttp://www.shnenglu.com/heath/archive/2012/09/23/191723.html#Feedback0http://www.shnenglu.com/heath/comments/commentRss/191723.htmlhttp://www.shnenglu.com/heath/services/trackbacks/191723.html        摄媄(jing)是实现Ray-Tracing Rendering的完方式了(jin)吧,以快门速度、光圈大、感光度作ؓ(f)控制参数Q渲染出惌表达的光影效果?/p>

        有时候,你会(x)H然Ҏ(gu)事很感兴,但理性思维?x)让你冷静(rn)一下,看是不是一时冲动。Nq前Q对摄媄(jing)的需求仅满于旅游记录,所以一般DCp够。一个多月前Q想要提升照片品质的需求突然串?jin)出来,让这U想法发酵了(jin)几天后,发现可能是该入一台DSLR的时候了(jin)。在Nikon D7000/Pentax K-5/Canon 60D中选择?jin)K5Q就成像效果D7000与K5是同一次Q喜ƢK5的手感和味道Q小巧是个很重要的因素,q样同样喜欢摄媄(jing)的Rain也可以用得很好。宾得的对焦pȝ和镜头群一向都被CN饭喷Q不q个为K5的对焦在日常拍摄中已l够用,镜头但全。对于刚使用DSLR不久的我来说QDA 18-55mm F/3.5-5.6 AL虽然在成像锐度方面弱?jin)点Q但日常的风景h像还是够了(jin)。DA 55-300mm F/4-5.8 EDq端大光圈拍人像的虚化效果和q端打鸟的远摄效果都q比较满意,׃55-110光圈可以恒定?Q?10-200最大光圈恒定在4.5Q所以两者组合v来在性h(hun)比上要比DA 18-135mm F/3.5-5.6 ED高。凤?0mm F/1.7手动_(d)在成像效果方面真?j)对得v315RMBQ有兴趣的同学可以看q里?/p>

        摄媄(jing)技术的提高是个漫长的过E,对初U阶D需要掌握的知识Q我ȝ如下Q?/p>

        1Q器材的熟?zhn)到精通:(x)阅读使用手册Q熟知各个按钮及(qing)选项的意义?/p>

        2Q保证对焦点Q想拍摄物)(j)清晰?/p>

        3Q相机的基本原理Q快门、光圈、感光度对媄(jing)像的影响?/p>

        4Q构图:(x)左右对称、三{分、曲Uѝ对角线、T/L型、明暗对比?/p>

        5Q光U感知:(x)如何才能做到合适的曝光?/p>

        6Q利用学到的新知识,不断l习(fn)Q让相机成ؓ(f)你的另一只眼睛?/p>

        在参考书斚wQ虽然反感“宝典”之,但《数码单反摄影完全宝典》还是本不错的入门书了(jin)Q涵盖了(jin)DSLR的基知识Q加上配图(包括拍摄参数Q,可以提升对好照片的认知?/p>

        写此文的同时Q快门数也近3k?jin),遂将一些习(fn)作(没有后期Q整理了(jin)攑օflickr上,IDp一点吧?a target="_blank">Pentax的小眼睛』?/p>

        彼得的《理解曝光》是我学?fn)的W二本书Q对掌握光技巧从而正曝光有很大帮助Q距L惛_所得的目标有近?jin)一步。此书还涉及(qing)?jin)快门速度、光圈对拍摄效果产生的媄(jing)响,应该是入门者必ȝ一本经怹作?/p>

        国庆(jin)M(jin)厦门Q经q一个月的准备,拍出的片较之前有很大q步Q感觉生zd多了(jin)些乐?/p>

Heath 2012-09-23 17:34 发表评论
]]>
从CPU频中学些硬件知?/title><link>http://www.shnenglu.com/heath/archive/2012/06/10/178365.html</link><dc:creator>Heath</dc:creator><author>Heath</author><pubDate>Sun, 10 Jun 2012 15:16:00 GMT</pubDate><guid>http://www.shnenglu.com/heath/archive/2012/06/10/178365.html</guid><wfw:comment>http://www.shnenglu.com/heath/comments/178365.html</wfw:comment><comments>http://www.shnenglu.com/heath/archive/2012/06/10/178365.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/heath/comments/commentRss/178365.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/heath/services/trackbacks/178365.html</trackback:ping><description><![CDATA[<p><strong><font size="4">一、前a</font></strong> <p>     从大学到现在配过两台PCQ第一台Celeron的机器从大二用到研究生毕业,之后开始用W记本。第二台PC?9q入手的Q那阵子玩超频,但心(j)气w,胡ؕ试一下就尝辄止?jin),q一些基本原理都没有弄清楚。最q刚搞好新房安顿下来Q有?jin)自q工作_(d)在重新组装PC和设|BIOS的时候又惌频了(jin)Q但q次我期望做到知其所以然Q故在网上查阅了(jin)一些资料恶补了(jin)一下硬件知识,权当作学?fn)笔记。由于网l上关于gQ特别是内存部分Q知识很杂,仅以自己认ؓ(f)比较靠谱的内容ؓ(f)依据Q如有不准确之处Q欢q指正。由于用的是Intel CPUQ本文限于Intel架构Q且不适用Ipd架构? <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/18e4652fc073_1450A/500px-Motherboard_diagram.svg_2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="500px-Motherboard_diagram.svg" border="0" alt="500px-Motherboard_diagram.svg" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/18e4652fc073_1450A/500px-Motherboard_diagram.svg_thumb.png" width="500" height="770" /></a> <p align="center">ȝ概览 <p><strong><font size="4">二、术?/font></strong> <p><strong><br /></strong> <p><strong>L芯片l:(x)</strong>北桥芯片和南桥芯片? <p><strong>北桥QNorthbridgeQ:(x)</strong>PCL芯片l其中之一Q设计用来处理高速信P与CPU、内存、AGP/PCIE、南桥芯片进行通信? <p>南桥QSouthbridgeQ:(x)PCL芯片l其中之一Q设计用来处理低俗信P通过北桥和CPU通信Q与大多数I/O控制讑֤接口Q如PCI控制器、ATA控制器、USB控制器、网l控制器、音效控制器。各个芯片厂商对南桥芯片的命名有所不同QIntel其UCؓ(f)ICHQnVidiaUCؓ(f)MCPQATIUCؓ(f)IXP/SB? <p><strong>前端ȝQF(tun)SB, Front Side BusQ:(x)</strong>指CPU与北桥芯片之间的数据传输通道? <p><strong>锁相环(PLL, Phase-Locked LoopQ:(x)</strong>一个闭环的反馈控制pȝQ它可以使PLL的输出可以与一个参考信号保持固定的怽关系? <p><strong>旉频率Q?/strong>切Ҏ(gu)晶振频率Q与锁相环电(sh)路配合用ؓ(f)PC提供定时信号Q通过倍频/分频产生不同频率的基准信P用以同步pȝ的每一步操作。对于CPU主频Q它是由晶振提供的频率通过CPU内部的PLL?sh)\倍频而来? <p><strong>CPU外频Q?/strong>pȝȝ的工作频率,体现?jin)CPU与芯片组之间的ȝ速度? <p><strong>前端ȝ频率Q?/strong>CPU与北桥芯片之间的ȝ工作频率。之所以将CPU外频与前端ȝ频率区分开来,是因为Intel在Pentium 4中加入了(jin)Quad Pumped Bus架构Q得系lȝ在一个时钟周期内传输4ơ数据,也就相当于工作频率ؓ(f)CPU外频?倍? <p><strong>CPU倍频Q?/strong>为倍频pL的简Uͼ是指CPU主频与CPU外频之间的相Ҏ(gu)例关pR在PC发展初期Q由于CPU速度不高Q大部分元g旉均保持同步,直到80486时代Q在CPU制程持箋q步下,CPU的速度也加速增长,当时׃其他外部元g受电(sh)气结构所限,无法跟进成长Q因此Intel首次在CPU中加入了(jin)倍频设计。它的作用是使系lȝ工作在相对较低的频率上,而CPU速度可以通过倍频来提升? <p><strong>双倍数据速率QDDR, Double Data RateQ:(x)</strong>使SDRAM在一个时钟周期内q行两次数据传输的技术,具体地说它在信号的上升沿和下降沿传输数据一ơ,数据传输率是之前仅利用上升沿q行数据传输的SDRAM的两倍? <p><strong>内存频率Q?/strong>分ؓ(f)核心(j)频率(Internal rate)和I/Oȝ频率(Bus clock)。每条内存都是由内存芯片l成Q内存芯片的频率是核心(j)频率。I/Oȝ频率是指北桥与内存之间的ȝ频率。通常内存条标U的实际上是最大数据传输频率:(x)I/Oȝ频率X2。其实,从DDR到DDR3Q其内存颗粒的频率没有怎么提升Q提升的是ȝ频率。JEDEC制定的DDR三代参数对照如下表所C:(x) <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/18e4652fc073_1450A/Image(11)_2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Image(11)" border="0" alt="Image(11)" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/18e4652fc073_1450A/Image(11)_thumb.png" width="644" height="140" /></a> <p><strong>双通道Q?/strong>是在北桥芯片里设计两个内存控制器,q两个内存控制器可相互独立工作,每个控制器控制一个内存通道。在q两个内存通道上CPU可分别寻址、读取数据,从而内存的带宽增加一倍,数据存取速度也相应增加一倍(理论上)(j)。流行的双通道内存构架是由两个64bit DDR内存控制器构{而成的,其带宽可?28bit。因为双通道体系的两个内存控制器是独立的、具备互补性的内存控制器,因此二者能实现彼此间零{待旉Q同时运作。两个内存控制器的这U互?#8220;天?#8221;可让有效{待旉~减50%Q从而内存的带宽翻倍。双通道内存技术是解决CPUȝ带宽与内存带宽的矛盾的低仗高性能的方案? <p>  <p><strong><font size="4">三、原?/font></strong> <p align="center"><em><font size="4">CPU主频=外频×倍频</font></em></p><em> <p><br /></p></em> <p>     从公式可以看出,要提升CPU主频可以从提高外频和倍频两方面着手。然而在实际操作q程中,两者都?x)受CPU本n?qing)外部硬Ӟ主要是主板?j)体质的限Ӟ如:(x)锁倍频、主板FSB Frequency上限? <p>1Q提高外? <p>     因ؓ(f)CPU外频的设|直接媄(jing)响系lȝ工作频率Q所以通过提升外频和搭配合适的内存Q可以在L支持的前端ȝ频率上限内有效提升系l的整体性能。之所以要搭配合适的内存Q是因ؓ(f)前端ȝ频率提高Q最大的受媄(jing)响者就是内存,所以内存能够支持的最高工作频率也需要考虑。虽然GPU数据也要通过前端ȝ由CPUl过北桥到达昑֍Q但是在仅针对CPU频的情况下Q一般会(x)CPU与显卡之间通信的频率锁定在100MHz。D个例子:(x)有一块前端ȝ上限频率?600MHz的主板,假如搭配一块上限ؓ(f)1600MT/s的DDRIII内存Q?:2分频比的前提下,需要将CPU的外频提升到接近400MHzQ整个系l才?x)比较^衡? <p>2Q提高倍频 <p>     通过倍频的定义,可以看出Q在外频一定的情况下,提高倍频Q只能单U地提高CPU工作频率。虽?dng)CPU的计能力除?jin)跟工作频率有关外,q与g架构和指令集有关Q成倍提高工作频率肯定不{于成倍提高了(jin)计算能力Q但可以肯定的是频率提高肯定?x)在一定程度上提高计算能力? <p><strong><font size="4">四、实?/font></strong> <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/18e4652fc073_1450A/CaptureMB.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="CaptureMB" border="0" alt="CaptureMB" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/18e4652fc073_1450A/CaptureMB_thumb.png" width="573" height="118" /></a> <p>      <p>    五电(sh)容版E5200h很强的超频空_(d)在倍频定在X8的情况下Q?.2V便可以轻松上370MHz。主板在不超频情况下FSB已l支?600MHz?jin),Corsair在用XMP时支?600Q在整体考量Q散热、CPU寿命Q后军_CPU外频定在350MHz、倍频设ؓ(f)x10Q这样FSB可工作在1400MHzQ内存按?1:2分频比I/Oȝ工作?00MHz下(数据传输频率?400MT/sQ。BIOS讄如下Q? <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/18e4652fc073_1450A/IMG_0602.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="IMG_0602" border="0" alt="IMG_0602" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/18e4652fc073_1450A/IMG_0602_thumb.jpg" width="640" height="478" /></a> <p>内存CL、tRCD{D其自动读取SPD配置? <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/18e4652fc073_1450A/IMG_0604.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="IMG_0604" border="0" alt="IMG_0604" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/18e4652fc073_1450A/IMG_0604_thumb.jpg" width="640" height="478" /></a> <p align="center"><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/18e4652fc073_1450A/Capture.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Capture" border="0" alt="Capture" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/18e4652fc073_1450A/Capture_thumb.png" width="496" height="480" /></a><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/18e4652fc073_1450A/CaptureMem.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="CaptureMem" border="0" alt="CaptureMem" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/18e4652fc073_1450A/CaptureMem_thumb.png" width="499" height="480" /></a></p><strong> <p><br /></p></strong> <p><strong>参考:(x)</strong> <p><strong><br /></strong> <p>[1] 前端ȝ <a >http://zh.wikipedia.org/wiki/%E5%89%8D%E7%AB%AF%E6%80%BB%E7%BA%BF</a> <p>[2] 晶振?qing)其选用指南 <a >http://www.naiteli.com.cn/Info/Detail_50139_7547.html</a> <p>[3] 倍频 <a >http://baike.baidu.com/view/25647.htm</a> <p>[4] DDR SDRAM <a >http://en.wikipedia.org/wiki/DDR_SDRAM</a> <p>[5] DDR2 SDRAM <a >http://en.wikipedia.org/wiki/DDR2_SDRAM</a> <p>[6] DDR3 SDRAM <a >http://en.wikipedia.org/wiki/DDR3_SDRAM</a> <p>[7] 五电(sh)容E5200 <a >http://tech.163.com/digi/09/0316/08/54H0RJNT001618J7.html</a> </p><img src ="http://www.shnenglu.com/heath/aggbug/178365.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/heath/" target="_blank">Heath</a> 2012-06-10 23:16 <a href="http://www.shnenglu.com/heath/archive/2012/06/10/178365.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Window调试中的W号文g与源代码理http://www.shnenglu.com/heath/archive/2012/03/26/169068.htmlHeathHeathMon, 26 Mar 2012 15:10:00 GMThttp://www.shnenglu.com/heath/archive/2012/03/26/169068.htmlhttp://www.shnenglu.com/heath/comments/169068.htmlhttp://www.shnenglu.com/heath/archive/2012/03/26/169068.html#Feedback2http://www.shnenglu.com/heath/comments/commentRss/169068.htmlhttp://www.shnenglu.com/heath/services/trackbacks/169068.html    游戏开始进行第二次闭试Q这ơ参与h数较多,随之而来的便是无数的崩溃dump。虽然在自动构徏程中已l对PDB和EXE按版本号q行?jin)保存,但由于构建操作h员手动修Ҏ(gu)建号Q出现多个版本对应相同版本号的问题,以及(qing)BUG单填写h以基U版本号而非真实版本h交的情况Q经常浪费开发h员的旉和精力去扑֯应的PDBQ降低了(jin)崩溃解决的响应速度。所以非常有必要建立一套自动化Ҏ(gu)Q得到dump文g后启动WinDbgq行分析时能够自动获取对应的PDB和源代码QW(xu)inDbg提供了(jin)q样一套方便实用的工具?/p>

1. 建立源代码烦(ch)?/font>

     WinDbg提供?jin)一套用于管理pdb对应的源代码的工P位于其安装目录的srcsrv下,对VSS、SVN、CVS、Perforce提供?jin)支持,分别对应vssindex.cmd、svnindex.cmd、cvsindex.cmd、p4index.cmdq四个perl脚本。其实,ssindex.cmd才是具体实现Q它Ҏ(gu)传入的版本控制系l标识,调用对应的perl module?

     svnindex.cmd通过/source?symbols参数来指定源代码目录和PDB目录Q?debug可输出处理的详细信息Q?user?pass提供svn账户和密码。PDB文g中有一节专门用于存放源代码文g列表?qing)处理命令,可通过pdbstr -r -p:PdbFileName -s:srcsrv查看?

 

     svnindex.cmd /debug /source="E:\CodeBase_SVN\Client\trunk\tools\CutSceneEditor" /symbols="E:\CodeBase_SVN\Client\trunk\bin\Release\CutSceneEditor" /user="user" /pass="pwd"

 

     在执行上面命令前Q确保Perl和Subversion已经被安装且讄?jin)PATH环境变量。该命o(h)提取source code的服务器路径和当前RevisionQ然后写入PDB。下面是通过pdbstr获取的信息:(x)

     Image(9)

     上面输出是经q格式化的,原始信息可以通过srctool -n查看Q?

     Image(10)

     可以看出Q原始代码\径后面跟?jin)一条svn cat指o(h)Q由于没有指定sourcepathQ所?targ%~省为当前\径("C:\Program Files\Debugging Tools for Windows (x64)\srcsrv"Q?nbsp;

2. 创徏W号服务?/font>

    所谓符h务器Q最单的形式是文g׃n服务器。我们?a target="_blank">symstore命o(h)Q将1中生的pdbdC个文件共享服务器上,如:(x)

 

     symstore.exe add /f "E:\CodeBase_SVN\Client\trunk\bin\Release\CutSceneEditor\*.pdb" /s "\\server.com\pub\Symbols" /t "CutSceneEditor" /v "Build 4171" /c "fix memory leak"

 

     该命令会(x)Ҏ(gu)PDB的signature和age产生一个GUIDQƈPDB攄于以改GUID为名字的目录下:(x)

     Image8

    当debugӞUNC路径d到_NT_SYMBOL_PATH中(如:(x)_NT_SYMBOL_PATH=CACHE*F:\Symbols;SRV*http://msdl.microsoft.com/download/symbols;SRV*\\server.com\pub\SymbolsQ,调试器会(x)自动到指定的W号服务器上L索对应的pdb文g?

     symstore大大化了(jin)W号的版本管理问题,关于它的详细介绍可参?a target="_blank">symstore介绍?

     值得注意的是Qsymstore没有锁机Ӟq不支持多h同时操作。实际情况中Q也只有自动构徏时才?x)做此操作?

3. 使用WinDbg分析Dump文g

      我们在代码中加入发生异常写MiniDump的功能,在程序崩溃时产生dump文g。在使用WinDbg分析dump文gӞ需要设|Symbol File Path和Source File PathQ也可以直接讄环境变量_NT_SYMBOL_PATH和_NT_SOURCE_PATH。在讄_NT_SOURCE_PATH时?SRV*CachePath"表C启用代码提取功能,执行svn cat写入到CachePath指定的目录,否则用原始\径。此后,通过点击Call Stack中的函数调用便会(x)触发从svnd对应代码的操作(通常?x)有一个安全警告窗口弹出)(j)?

     对于使用WinDbgq行调试在此׃多讲?jin),推荐一本不错的书《Advanced Windows Debugging》?

 

参考资?/strong>

[1] Source Indexing and Symbol Servers: A Guide to Easier Debugging

[2] Source Server Helps You Kill Bugs Dead In Visual Studio 2005



Heath 2012-03-26 23:10 发表评论
]]>
Arduino实践&mdash;&mdash;用PS3手柄遥控你的玩具http://www.shnenglu.com/heath/archive/2012/02/02/164857.htmlHeathHeathThu, 02 Feb 2012 15:33:00 GMThttp://www.shnenglu.com/heath/archive/2012/02/02/164857.htmlhttp://www.shnenglu.com/heath/comments/164857.htmlhttp://www.shnenglu.com/heath/archive/2012/02/02/164857.html#Feedback4http://www.shnenglu.com/heath/comments/commentRss/164857.htmlhttp://www.shnenglu.com/heath/services/trackbacks/164857.html          着q年攑ց前的I闲旉Q开始着手实现在?a href="http://www.shnenglu.com/heath/archive/2011/11/13/160032.html" target="_blank">Arduino实践——遥?WDR”一文中提到q用PS3手柄作ؓ(f)遥控器的Ҏ(gu)Q因q没有带W记本回Ӟ现在来补一下?/p>

          首先要介l一下USB Host Shield[1]。它是Oleg?009q春开始设计的Arduino ShieldQ采用MAX3421E控制芯片Q目前最新版本ؓ(f)2.0Q旨在让Arduino能够与USB讑֤Q如Q键盘、鼠标、游戏手柄、相机、GPS、手机)(j)q行通讯Q当然也能完成ADK的功能。在软g斚wQOleg也在github上开放了(jin)驱动代码和例子程序[2]Q此后又有hZ前者的代码l出?jin)更为方便简z的USB蓝牙适配器与PS3手柄通讯的示例代码[3,4]?/p>

image

           PS3手柄只能与具有相同蓝牙地址的主机配对,所以需要先USB蓝牙适配器的地址写入PS3手柄。可以用[3]中的PS3Pair代码Q将BDADDRg改ؓ(f)蓝牙适配器的地址。[4]中提供的PS3BT例子Q将蓝牙地址修改和通讯功能整合C(jin)一P省了(jin)一ơsketch的uploadQ注意也需要将代码中的my_bdaddr修改为适配器的地址。配Ҏ(gu)需要将PS3手柄q接U与USB Host Shield相连Q待完成后将蓝牙适配器接上,打开手柄Q可从Serial Monitor看到日志Q注意L特率的一_(d)(j)?/p>

imageimage

        USB Host Shield占用?jin)SPI、P9、P10Q注意不要冲H了(jin)?/p>

 

Reference:

[1] http://www.circuitsathome.com/arduino_usb_host_shield_projects

[2] https://github.com/felis/USB_Host_Shield_2.0

[3] https://github.com/Lauszus/PS3-Controller-BT-Library-for-Arduino

[4] https://github.com/TKJElectronics/USB_Host_Shield_2.0



Heath 2012-02-02 23:33 发表评论
]]>
Playing with Proxmarkhttp://www.shnenglu.com/heath/archive/2012/01/08/163832.htmlHeathHeathSun, 08 Jan 2012 08:21:00 GMThttp://www.shnenglu.com/heath/archive/2012/01/08/163832.htmlhttp://www.shnenglu.com/heath/comments/163832.htmlhttp://www.shnenglu.com/heath/archive/2012/01/08/163832.html#Feedback11http://www.shnenglu.com/heath/comments/commentRss/163832.htmlhttp://www.shnenglu.com/heath/services/trackbacks/163832.html阅读全文

Heath 2012-01-08 16:21 发表评论
]]>
Arduino实践——遥?WDRhttp://www.shnenglu.com/heath/archive/2011/11/13/160032.htmlHeathHeathSun, 13 Nov 2011 10:22:00 GMThttp://www.shnenglu.com/heath/archive/2011/11/13/160032.htmlhttp://www.shnenglu.com/heath/comments/160032.htmlhttp://www.shnenglu.com/heath/archive/2011/11/13/160032.html#Feedback1http://www.shnenglu.com/heath/comments/commentRss/160032.htmlhttp://www.shnenglu.com/heath/services/trackbacks/160032.html阅读全文

Heath 2011-11-13 18:22 发表评论
]]>
RFID Securityhttp://www.shnenglu.com/heath/archive/2011/11/12/159992.htmlHeathHeathSat, 12 Nov 2011 09:43:00 GMThttp://www.shnenglu.com/heath/archive/2011/11/12/159992.htmlhttp://www.shnenglu.com/heath/comments/159992.htmlhttp://www.shnenglu.com/heath/archive/2011/11/12/159992.html#Feedback0http://www.shnenglu.com/heath/comments/commentRss/159992.htmlhttp://www.shnenglu.com/heath/services/trackbacks/159992.html    虽然MIFARE Classic encryption Crypto-1法?8q就被攻_(d)因ؓ(f)升成本以及(qing)大众对其产生的安全问题还未引赯够的重视{原因,S50/70目前仍旧大量用于诸如公交卡、校园一卡通之cȝ额支付卡。目前已l有Zlibnfc的开源工具可以获取M1的KEY。用NFC reader做了(jin)一下实验,获取一张M1 S50的A/B KEY大概需?时左右?/p>

    手上的ShenZhen Tong和HongKong Octopus均是SONY?a >Felica CardQ与ISO/IEC 18092QNFCQ用类似的调制Ҏ(gu)Q采用曼切斯特编码,?3.56MHZ?12kbit/sq行通讯。用动态密钥,加密法为DES?-DES、AESQ攻击难度较大,但是从动态密钥的交换q程入手Q还是有Z(x)的。目前,有些手机刉商QNOKIA,SAMSUNG,BLACKBERRYQ将NFC Reader集成到手ZQ未来RFID的应用将比现在更q,安全问题也会(x)来受到关注?/p>

 

References:

http://rfidiot.org/

http://wiki.yobi.be/wiki/RFID

http://www.openpcd.org/

http://cq.cx/proxmark3.pl
http://www.proxmark.org/

http://www.libnfc.org/documentation/introduction

http://www.cs.ru.nl/~flaviog/publications/Pickpocketing.Mifare.pdf

http://www.sos.cs.ru.nl/applications/rfid/2008-esorics.pdf



Heath 2011-11-12 17:43 发表评论
]]>
BackTrack 5 KDE 64bit USB启动不能q入X的解x?/title><link>http://www.shnenglu.com/heath/archive/2011/11/12/159986.html</link><dc:creator>Heath</dc:creator><author>Heath</author><pubDate>Sat, 12 Nov 2011 05:24:00 GMT</pubDate><guid>http://www.shnenglu.com/heath/archive/2011/11/12/159986.html</guid><wfw:comment>http://www.shnenglu.com/heath/comments/159986.html</wfw:comment><comments>http://www.shnenglu.com/heath/archive/2011/11/12/159986.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/heath/comments/commentRss/159986.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/heath/services/trackbacks/159986.html</trackback:ping><description><![CDATA[<p>rm /root/.kde/cache-root/icon-cache.kcache</p> <p>rm /root/.kde/cache-root/plasma_theme_Volatile.kcache</p> <p>rm /root/.kde/cache-bt/icon-cache.kcache</p> <p>rm /root/.kde/cache-bt/plasma_theme_Volatile.kcache</p><img src ="http://www.shnenglu.com/heath/aggbug/159986.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/heath/" target="_blank">Heath</a> 2011-11-12 13:24 <a href="http://www.shnenglu.com/heath/archive/2011/11/12/159986.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Hierarchical Path-Findinghttp://www.shnenglu.com/heath/archive/2011/11/12/159984.htmlHeathHeathSat, 12 Nov 2011 04:50:00 GMThttp://www.shnenglu.com/heath/archive/2011/11/12/159984.htmlhttp://www.shnenglu.com/heath/comments/159984.htmlhttp://www.shnenglu.com/heath/archive/2011/11/12/159984.html#Feedback0http://www.shnenglu.com/heath/comments/commentRss/159984.htmlhttp://www.shnenglu.com/heath/services/trackbacks/159984.html     ?a >Near Optimal Hierarchical Path-Finding》中提出?jin)一U层ơA*法Q正好能够用于解决项目大地图寻\的问题。大致思\是:(x)1Q预处理。将地图划分为nxn大小的区块,扑և每个区块与周围四个区块在边界上的互通点Q在区块中用局部A*Ҏ(gu)出的点做q通性测试ƈ其保存下来Q?Q寻路时Q用预处理得到的数据(边界上的可通点与区块内部的互通点Q,先在区块层上做一ơA*Q根据结果再在每个区块中使用局部A*扑ֈ区块与区块之间的路径Q最l得到完整\径?

一、A* Path-Finding

     A*法׃多讲?jin),可参考:(x)

     A*法的优化可从搜索节点储存和OpenList排序两方面入手?

二、预处理

     每个盔R区块QC1和C2Q都有一条由公共边,该边两侧格l成L1和L2Q则q通点集E满下列条gQ?

  • E ?L1 ?L2
  • ∀t ?L1 ?L2 : t ?E ?symm(t) ?E Q其中symm(t)为对U关p?
  • E不含不可行走格子
     对在E中且同边的连l格子取其中点,如下图所C:(x)

Image(6)

    对上面得到的位于同一区块的点集合使用local A*做连通性测试,下图用直U连接来表示两点互通:(x)

Image(7)

三、寻?/font>

     使用区块q通信息,q行区块UA*Q得到区块之间的q接点,如果在预处理时保存了(jin)区块内互通点的\径,׃必再q行区块内的local A*?jin)?

     实验l果表明Q在未采用区块内预存路径的情况下Q中长距d路用层ơA*后的q_效率是普通A*?倍以上,距离长效率Ҏ(gu)明显?

image

     A* 93ms

image

HPA* 15ms

     从上图中可以看出QHPA*得到的\径ƈ不是最优的Q它是在最优和效率上的折中Q适合作ؓ(f)长距d路的一U优化方案?

四、优化点

  • 可扩展ؓ(f)多层而不仅限于一?
  • 预存区块内连通点路径
  • 区块边界可通面U较大时Q生不自然路径Q如下图所C:(x)

image

          一个改q的Ҏ(gu)是对q长的边界再做划分:(x)

Image(5)



Heath 2011-11-12 12:50 发表评论
]]>
修正D3DXQuaternionSquad不能正确处理反向Quaternions的BUGhttp://www.shnenglu.com/heath/archive/2011/08/21/154037.htmlHeathHeathSun, 21 Aug 2011 14:16:00 GMThttp://www.shnenglu.com/heath/archive/2011/08/21/154037.htmlhttp://www.shnenglu.com/heath/comments/154037.htmlhttp://www.shnenglu.com/heath/archive/2011/08/21/154037.html#Feedback0http://www.shnenglu.com/heath/comments/commentRss/154037.htmlhttp://www.shnenglu.com/heath/services/trackbacks/154037.html微YDX库里提供?jin)对Quaternionq行球面四边形内插的接口Q能够在多个Quaternion之间qx插倹{这里涉?qing)到两个接口Q?/p>
void D3DXQuaternionSquadSetup(
  __out  D3DXQUATERNION *pAOut,
  __out  D3DXQUATERNION *pBOut,
  __out  D3DXQUATERNION *pCOut,
  __in   const D3DXQUATERNION *pQ0,
  __in   const D3DXQUATERNION *pQ1,
  __in   const D3DXQUATERNION *pQ2,
  __in   const D3DXQUATERNION *pQ3
);
D3DXQUATERNION* D3DXQuaternionSquad(
  __inout  D3DXQUATERNION *pOut,
  __in     const D3DXQUATERNION *pQ1,
  __in     const D3DXQUATERNION *pA,
  __in     const D3DXQUATERNION *pB,
  __in     const D3DXQUATERNION *pC,
  __in     FLOAT t
);
其中QD3DXQuaternionSquadSetup用于q回内插的控制点。它们具体的实现公式和用法,有兴的同学可以参考MSDN。在此需要说明的是,
D3DXQuaternionSquad使用?jin)Slerp作ؓ(f)内部实现Q会(x)D在两个夹角ؓ(f)180左右的Quaternion之间插g(x)出现断裂的问题。下面代码通过
实现一个考虑?jin)上q情늚Slerp版本Q在q1和q2夹角?或?80Ӟ使用U性内插而非球面Q来解决该问题?/pre>
  1. Quaternion QuatSlerpNoInvert(const Quaternion& q1 , const Quaternion& q2 , float t)
  2. {
  3.     float cosAngle = DotProduct(q1, q2);
  4.  
  5.     float c1, c2;
  6.     // Linear interpolation for close orientations
  7.     if ((1.0f - fabs(cosAngle)) < 1e-5f)
  8.     {
  9.         c1 = 1.0f - t;
  10.         c2 = t;
  11.     }
  12.     else
  13.     {
  14.         // Spherical interpolation
  15.         float angle    = acos(fabs(cosAngle));
  16.         float sinAngle = sin(angle);
  17.         c1 = sin(angle * (1.0f - t)) / sinAngle;
  18.         c2 = sin(angle * t) / sinAngle;
  19.     }
  20.  
  21.     Quaternion q = q1 * c1 + q2 * c2;
  22.     q.Normalize();
  23.  
  24.     return q;
  25. }
  26.  
  27. Quaternion QuatSquad(const Quaternion& p1 , const Quaternion& p2 , const Quaternion& p3 , const Quaternion& p4 , float t)
  28. {
  29.     static Quaternion a , b , c;
  30.  
  31.     D3DXQuaternionSquadSetup((D3DXQUATERNION*)&a , (D3DXQUATERNION*)&b , (D3DXQUATERNION*)&c ,
  32.         (D3DXQUATERNION*)&p1 , (D3DXQUATERNION*)&p2 , (D3DXQUATERNION*)&p3 , (D3DXQUATERNION*)&p4);
  33.  
  34.     return QuatSlerpNoInvert(QuatSlerpNoInvert(p2 , c , t) , QuatSlerpNoInvert(a , b , t) , 2 * t * (1-t));
  35. }

 

参考:(x)

[1] http://msdn.microsoft.com/en-us/library/bb205419(v=vs.85).aspx

[2] http://msdn.microsoft.com/en-us/library/bb205420(v=vs.85).aspx



Heath 2011-08-21 22:16 发表评论
]]>一个QTE原型框架http://www.shnenglu.com/heath/archive/2011/08/13/153251.htmlHeathHeathSat, 13 Aug 2011 02:25:00 GMThttp://www.shnenglu.com/heath/archive/2011/08/13/153251.htmlhttp://www.shnenglu.com/heath/comments/153251.htmlhttp://www.shnenglu.com/heath/archive/2011/08/13/153251.html#Feedback4http://www.shnenglu.com/heath/comments/commentRss/153251.htmlhttp://www.shnenglu.com/heath/services/trackbacks/153251.html本文主要Ҏ(gu)自己在项目中开发的QTEpȝQ介l一个相Ҏ(gu)较简单的原型框架?nbsp; 阅读全文

Heath 2011-08-13 10:25 发表评论
]]>
实现一个以字符串ؓ(f)Key大小写不敏感的Hash Maphttp://www.shnenglu.com/heath/archive/2011/07/13/150906.htmlHeathHeathWed, 13 Jul 2011 15:36:00 GMThttp://www.shnenglu.com/heath/archive/2011/07/13/150906.htmlhttp://www.shnenglu.com/heath/comments/150906.htmlhttp://www.shnenglu.com/heath/archive/2011/07/13/150906.html#Feedback0http://www.shnenglu.com/heath/comments/commentRss/150906.htmlhttp://www.shnenglu.com/heath/services/trackbacks/150906.html    Hash Map有两个关键方法:(x)哈希D方法和比较Ҏ(gu)。以STLPortZQ通过Hash Map的模版定义可以看出,其缺省的哈希Functor是hashQ比较functor为equal_toQ?/p>
  1. template <class _Key, class _Tp, _STLP_DFL_TMPL_PARAM(_HashFcn,hash<_Key>),
  2.           _STLP_DFL_TMPL_PARAM(_EqualKey,equal_to<_Key>),
  3.           _STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) >
  4. class hash_map

    在_hash_fun.h中有针对各种cd的哈希D特化版本,下面仅摘录针对C字符串的代码Q?/p>

  1. inline size_t __stl_hash_string(const char* __s) {
  2.   _STLP_FIX_LITERAL_BUG(__s)
  3.   unsigned long __h = 0;
  4.   for ( ; *__s; ++__s)
  5.     __h = 5*__h + *__s;
  6.  
  7.   return size_t(__h);
  8. }
  9.  
  10. _STLP_MOVE_TO_STD_NAMESPACE
  11.  
  12. _STLP_TEMPLATE_NULL
  13. struct hash<char*> {
  14.   size_t operator()(const char* __s) const {
  15.     _STLP_FIX_LITERAL_BUG(__s)
  16.     return _STLP_PRIV __stl_hash_string(__s);
  17.   }
  18. };
  19.  
  20. _STLP_TEMPLATE_NULL
  21. struct hash<const char*> {
  22.   size_t operator()(const char* __s) const {
  23.     _STLP_FIX_LITERAL_BUG(__s)
  24.     return _STLP_PRIV __stl_hash_string(__s);
  25.   }
  26. };

    __stl_hash_string实现?jin)一个简单的哈希法Q因为算法中使用?jin)字W的ASCII码,Z(jin)辑ֈ大小写不敏感的目的,可将每个字符转换成小?大写来计。对于hash functorQ我们也需要一个string的特化版?/p>

    在_function_base.h中定义了(jin)equal_to functorQ?/p>

  1. template <class _Arg1, class _Arg2, class _Result>
  2. struct binary_function {
  3.   typedef _Arg1 first_argument_type;
  4.   typedef _Arg2 second_argument_type;
  5.   typedef _Result result_type;
  6. #if !defined (__BORLANDC__) || (__BORLANDC__ < 0x580)
  7. protected:
  8.   /* See unary_function comment. */
  9.   ~binary_function() {}
  10. #endif
  11. };
  12.  
  13. template <class _Tp>
  14. struct equal_to : public binary_function<_Tp, _Tp, bool> {
  15.   bool operator()(const _Tp& __x, const _Tp& __y) const { return __x == __y; }
  16. };

    通过定制一个string版本的equal_toQ用stricmpq行字符串比较。下面列出实现及(qing)试代码Q?/p>

Test Codes
  1. #include <hash_map>
  2. #include <string>
  3. #include <algorithm>
  4. #include <cctype>
  5.  
  6. inline size_t __stl_hash_string(const char* __s)
  7. {
  8.     unsigned long __h = 0;
  9.     for ( ; *__s; ++__s)
  10.         __h = 5*__h + tolower(*__s);
  11.  
  12.     return size_t(__h);
  13. }
  14.  
  15. template<>
  16. struct stlport::hash<stlport::string>
  17. {
  18.     size_t operator()(const stlport::string& __s) const
  19.     {
  20.         return __stl_hash_string(__s.c_str());
  21.     }
  22. };
  23.  
  24. template<>
  25. struct stlport::equal_to<stlport::string>
  26.     : public stlport::binary_function<stlport::string , stlport::string , bool>
  27. {
  28.     bool operator()(const stlport::string& __x, const stlport::string& __y) const
  29.     {
  30.         return !_stricmp(__x.c_str() , __y.c_str());
  31.     }
  32. };
  33.  
  34. int _tmain(int argc, _TCHAR* argv[])
  35. {
  36.     stlport::hash_map<stlport::string , int> map;
  37.  
  38.     map.insert(stlport::make_pair("Test" , 123));
  39.  
  40.     stlport::hash_map<stlport::string , int>::iterator iter = map.find("teSt");
  41.     if(iter != map.end())
  42.         printf("Found!\n");
  43.  
  44.     return 0;
  45. }


Heath 2011-07-13 23:36 发表评论
]]>
让VC++ 2003与Win7和睦相处http://www.shnenglu.com/heath/archive/2011/03/14/141837.htmlHeathHeathMon, 14 Mar 2011 15:49:00 GMThttp://www.shnenglu.com/heath/archive/2011/03/14/141837.htmlhttp://www.shnenglu.com/heath/comments/141837.htmlhttp://www.shnenglu.com/heath/archive/2011/03/14/141837.html#Feedback1http://www.shnenglu.com/heath/comments/commentRss/141837.htmlhttp://www.shnenglu.com/heath/services/trackbacks/141837.html    微Y太谦虚了(jin)QW(xu)in7对VS2003的兼Ҏ(gu)ƈ不像他说的那样差。其实仅有两个问题:(x)

1、search时程序死?/p>

2、debug旉住pdb不释放,下次build时出现文件写错误

    对于W一个问题,在devenv.exe属性的Compatibility的Settings中勾选“Disable visual themes”,或者停用Aero主题Q用Basic themes?/p>

    对于W二个问题,可用sysinternals工具handle来释攑֯pdb的引用,在此不列出handle的用,有兴可以自qI。下面给Z个批处理Q关闭指定名U的pdb文g占用Q?/p>

@echo off
cd /d "%~dp0"
for /f "tokens=2-3 skip=5 delims=:" %%a in ('handle -p devenv.exe "%1.pdb"') do (
  for /f "tokens=1,4" %%c in ("%%a%%b") do (
      handle.exe -c %%d -y -p %%c
  )
)
@echo on

    其保存C个文Ӟ攑֜project的pre-build event。当?dng)q需要一个参数来喂批处理中的%1?/p>

Heath 2011-03-14 23:49 发表评论
]]>
HACKING EBOOT.BINhttp://www.shnenglu.com/heath/archive/2011/03/06/141220.htmlHeathHeathSun, 06 Mar 2011 09:52:00 GMThttp://www.shnenglu.com/heath/archive/2011/03/06/141220.htmlhttp://www.shnenglu.com/heath/comments/141220.htmlhttp://www.shnenglu.com/heath/archive/2011/03/06/141220.html#Feedback0http://www.shnenglu.com/heath/comments/commentRss/141220.htmlhttp://www.shnenglu.com/heath/services/trackbacks/141220.html阅读全文

Heath 2011-03-06 17:52 发表评论
]]>
法优化&mdash;&mdash;递归到@?/title><link>http://www.shnenglu.com/heath/archive/2011/03/05/141160.html</link><dc:creator>Heath</dc:creator><author>Heath</author><pubDate>Sat, 05 Mar 2011 05:42:00 GMT</pubDate><guid>http://www.shnenglu.com/heath/archive/2011/03/05/141160.html</guid><wfw:comment>http://www.shnenglu.com/heath/comments/141160.html</wfw:comment><comments>http://www.shnenglu.com/heath/archive/2011/03/05/141160.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.shnenglu.com/heath/comments/commentRss/141160.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/heath/services/trackbacks/141160.html</trackback:ping><description><![CDATA[<p>     递归通常很直白地描述?jin)一个求解过E,因此也是最Ҏ(gu)被想到和实现的算法。@环其实和递归h相同的特性(卻I(x)做重复Q务)(j)Q但有时Q用@环的法q不?x)那么清晰地描述解决问题步骤。单从算法设计上看,递归和@环ƈ无优劣之别。然而,在实际开发中Q因为函数调用的开销Q递归常常?x)带来性能问题Q特别是在求解规模不定的情况下。而@环因为没有函数调用开销Q所以效率会(x)比递归高。除数~程语言寚w归q行?jin)优化外Q大部分语言在实现递归法时还是十分笨拙,由此带来?jin)如何将递归法转换为@环算法的问题。算法{换应当徏立在Ҏ(gu)解过E充分理解的基础上,有时甚至需要另辟蹊径? <p>     前段旉遇到q这L(fng)问题Q已知一2D地图格子的长宽(w、hQ及(qing)每个格子的边长(aQ格子ؓ(f)正方形)(j)Q给定物体的2D坐标Qpos[x , y]Q及(qing)半径QrQ,求解物体?D地图格子中所占的格子Q仅考虑n*n的情c(din)大概的求解q程如下Q? <p>1Q根据半径,定n*n中的n。假定计公式ؓ(f)Qn = Round(2*r / a) <p>2Q根?D坐标得到物体的“中?j)格子”。根据n的奇Ӟ计算公式不同Q如下图所C? <p align="center"><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/e7377895b269_9CB8/image_10.png"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/e7377895b269_9CB8/image_thumb_4.png" width="239" height="244"></a>                  <a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/e7377895b269_9CB8/image_12.png"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/e7377895b269_9CB8/image_thumb_5.png" width="240" height="244"></a></p> <p align="center">n为偶数[1]                                                                    n为奇数[2]</p> <p>[1]Qgrid(x , y) = Round(pos / a) <p>[2]Qgrid(x , y) = Floor(pos / a) <p>其中Q格子坐标x >= 0 , y >= 0? <p>3Q以“中?j)格子”ؓ(f)基础Q求出物体占据的其他格子。这L(fng)描述Q让人容易想到递归Q就像用深度优先Ҏ(gu)遍历?wi)那P伪代码算法如下:(x)</p> <div style="padding-bottom: 0px; padding-left: 0px; width: 1032px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:866d37ab-87f1-4aea-9d49-b7235fcfb0e9" class="wlWriterEditableSmartContent"><pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #0000FF;">if</span><span style="color: #000000;"> n is even { get the index of </span><span style="color: #800000;">'</span><span style="color: #800000;">center grid</span><span style="color: #800000;">'</span><span style="color: #000000;"> (row , col) ExtendHeldGrid(row , col , n) ExtendHeldGrid(row </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> , col , n) ExtendHeldGrid(row </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> , col </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> , n) ExtendHeldGrid(row , col </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> , n) } </span><span style="color: #0000FF;">else</span><span style="color: #000000;"> { get the index of </span><span style="color: #800000;">'</span><span style="color: #800000;">center grid</span><span style="color: #800000;">'</span><span style="color: #000000;"> (row , col) ExtendHeldGrid(row , col , n) } </span><span style="color: #0000FF;">function</span><span style="color: #000000;"> ExtendHeldGrid(row , col , level) { </span><span style="color: #0000FF;">if</span><span style="color: #000000;">(level </span><span style="color: #000000;"><=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">) </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> </span><span style="color: #0000FF;">if</span><span style="color: #000000;">((row </span><span style="color: #000000;">>=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;"> </span><span style="color: #0000FF;">and</span><span style="color: #000000;"> row </span><span style="color: #000000;"><</span><span style="color: #000000;"> MaxGridWidth) </span><span style="color: #0000FF;">and</span><span style="color: #000000;"> (col </span><span style="color: #000000;">>=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;"> </span><span style="color: #0000FF;">and</span><span style="color: #000000;"> col </span><span style="color: #000000;"><</span><span style="color: #000000;"> MaxGridHeight)) { mark the grid(row , col) ExtendHeldGrid(row , col , level </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">2</span><span style="color: #000000;">) </span><span style="color: #0000FF;">if</span><span style="color: #000000;">(level </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">2</span><span style="color: #000000;"> </span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">) { ExtendHeldGrid(row </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> , col , level </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">2</span><span style="color: #000000;">) ExtendHeldGrid(row </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> , col , level </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">2</span><span style="color: #000000;">) ExtendHeldGrid(row , col </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> , level </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">2</span><span style="color: #000000;">) ExtendHeldGrid(row , col </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> , level </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">2</span><span style="color: #000000;">) ExtendHeldGrid(row </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> , col </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> , level </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">2</span><span style="color: #000000;">) ExtendHeldGrid(row </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> , col </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> , level </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">2</span><span style="color: #000000;">) ExtendHeldGrid(row </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> , col </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> , level </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">2</span><span style="color: #000000;">) ExtendHeldGrid(row </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> , col </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> , level </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">2</span><span style="color: #000000;">) } } } </span></pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p>虽然Q该法得到?jin)正的求解l果Q但是由于每个格子都?x)标记周围?个格子,所以存在大量的重复Q再者如果上面的q程每都进行的话,函数调用开销也是相当可观?/p> <p>循环自然是不可避免的Q消除重复便成了(jin)优化的目标。分析格子图和n??的情况,试图扑և用@环代曉K归的方法,我发C(jin)下面一个有的规律Q?/p> <p align="center"><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/e7377895b269_9CB8/image_16.png"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/e7377895b269_9CB8/image_thumb_7.png" width="239" height="244"></a>                <a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/e7377895b269_9CB8/image_18.png"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/e7377895b269_9CB8/image_thumb_8.png" width="240" height="244"></a></p> <p>从“中?j)格子”出发,时针(或逆时针)(j)以上图方式可以走遍所求解的每个格子而不重复。在实现上,每个转角也是有规律的Q可以通过一?*2的{角矩阉|控制Q?/p> <p align="center">[1 , 0][0 , -1]</p> <p align="center">[0 , 1][-1 , 0]</p> <p align="center">时针方式的转角?/p> <p align="left"> </p> <p>矩阵中的每个元素代表从当前格子走C个格子在row和col上的变化。加之,在{角之间的路长Q以格子个数计)(j)有每转两ơ递增单位1的规律,法׃隑־C(jin)Q下面同样以伪代码示Q?/p> <div style="padding-bottom: 0px; padding-left: 0px; width: 1032px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:c1053f9b-292c-4f91-b901-a530b31c17c3" class="wlWriterEditableSmartContent"><pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">conerMat </span><span style="color: #000000;">=</span><span style="color: #000000;"> { {</span><span style="color: #800080;">0</span><span style="color: #000000;"> , </span><span style="color: #000000;">-</span><span style="color: #800080;">1</span><span style="color: #000000;">} , {</span><span style="color: #000000;">-</span><span style="color: #800080;">1</span><span style="color: #000000;"> , </span><span style="color: #800080;">0</span><span style="color: #000000;">} , {</span><span style="color: #800080;">0</span><span style="color: #000000;"> , </span><span style="color: #800080;">1</span><span style="color: #000000;">} , {</span><span style="color: #800080;">1</span><span style="color: #000000;"> , </span><span style="color: #800080;">0</span><span style="color: #000000;">} } dir </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;"> </span><span style="color: #000000;">///</span><span style="color: #000000;"> 转角控制Q四个{角顺旉0~</span><span style="color: #800080;">3</span><span style="color: #000000;"> span </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> </span><span style="color: #000000;">///</span><span style="color: #000000;"> 转角间的跨度 count </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> </span><span style="color: #000000;">///</span><span style="color: #000000;"> 每两ơ增加一个跨? rin </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> </span><span style="color: #000000;">///</span><span style="color: #000000;"> 下一个{角的循环索引 </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> n is even get the index of </span><span style="color: #800000;">'</span><span style="color: #800000;">center grid</span><span style="color: #800000;">'</span><span style="color: #000000;"> (row , col) </span><span style="color: #0000FF;">else</span><span style="color: #000000;"> get the index of </span><span style="color: #800000;">'</span><span style="color: #800000;">center grid</span><span style="color: #800000;">'</span><span style="color: #000000;"> (row , col) </span><span style="color: #0000FF;">for</span><span style="color: #000000;">(i </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">; i </span><span style="color: #000000;"><</span><span style="color: #000000;"> n </span><span style="color: #000000;">*</span><span style="color: #000000;"> n; </span><span style="color: #000000;">++</span><span style="color: #000000;">i) { </span><span style="color: #0000FF;">if</span><span style="color: #000000;">((row </span><span style="color: #000000;">>=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;"> </span><span style="color: #0000FF;">and</span><span style="color: #000000;"> row </span><span style="color: #000000;"><</span><span style="color: #000000;"> MaxGridWidth) </span><span style="color: #0000FF;">and</span><span style="color: #000000;"> (col </span><span style="color: #000000;">>=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;"> </span><span style="color: #0000FF;">and</span><span style="color: #000000;"> col </span><span style="color: #000000;"><</span><span style="color: #000000;"> MaxGridHeight)) mark the grid(row , col) </span><span style="color: #0000FF;">if</span><span style="color: #000000;">(i </span><span style="color: #000000;">==</span><span style="color: #000000;"> rin) { dir </span><span style="color: #000000;">=</span><span style="color: #000000;"> (dir </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;">) </span><span style="color: #000000;">%</span><span style="color: #000000;"> </span><span style="color: #800080;">4</span><span style="color: #000000;"> </span><span style="color: #0000FF;">if</span><span style="color: #000000;">(count </span><span style="color: #000000;">==</span><span style="color: #000000;"> </span><span style="color: #800080;">2</span><span style="color: #000000;">) { </span><span style="color: #000000;">++</span><span style="color: #000000;">span count </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> } </span><span style="color: #0000FF;">else</span><span style="color: #000000;"> </span><span style="color: #000000;">++</span><span style="color: #000000;">count rin </span><span style="color: #000000;">=</span><span style="color: #000000;"> i </span><span style="color: #000000;">+</span><span style="color: #000000;"> span } row </span><span style="color: #000000;">=</span><span style="color: #000000;"> row </span><span style="color: #000000;">+</span><span style="color: #000000;"> conerMat[dir][</span><span style="color: #800080;">0</span><span style="color: #000000;">] col </span><span style="color: #000000;">=</span><span style="color: #000000;"> col </span><span style="color: #000000;">+</span><span style="color: #000000;"> conerMat[dir][</span><span style="color: #800080;">1</span><span style="color: #000000;">] } </span></pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p>用MFCE序验证?jin)一下算法的正确性,标号展示?jin)@环的路线Q注意GDI的坐标系中Y的正方向朝下Q:(x)</p> <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/e7377895b269_9CB8/image_20.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/e7377895b269_9CB8/image_thumb_9.png" width="863" height="510"></a></p><img src ="http://www.shnenglu.com/heath/aggbug/141160.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/heath/" target="_blank">Heath</a> 2011-03-05 13:42 <a href="http://www.shnenglu.com/heath/archive/2011/03/05/141160.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>对TortoiseSVN的扩展实?/title><link>http://www.shnenglu.com/heath/archive/2011/01/23/139190.html</link><dc:creator>Heath</dc:creator><author>Heath</author><pubDate>Sun, 23 Jan 2011 13:55:00 GMT</pubDate><guid>http://www.shnenglu.com/heath/archive/2011/01/23/139190.html</guid><wfw:comment>http://www.shnenglu.com/heath/comments/139190.html</wfw:comment><comments>http://www.shnenglu.com/heath/archive/2011/01/23/139190.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/heath/comments/commentRss/139190.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/heath/services/trackbacks/139190.html</trackback:ping><description><![CDATA[<p>    个h有个需求,希望在update时用颜色高亮?gu)己感兴趣的文Ӟ目前我只对sln?qing)vcproj文g感兴?/p> <p>    首先惛_的是用TSVN的hook script(client side)Q但仔细研究后发C入script的参C有操作\径,且通过script也不可能讉K/修改Notify对话框中的信息和字体颜色。唯一的办法就是修Ҏ(gu)代码重新~译Q从TSVN官方代码库获取到?jin)trunk source code后,按照根\径下的build.txt文档q行构徏Qdoc\build-zh_CN.txt有些q时?jin),不要按照该文进行构建?j)Q最C码需要用到VC++10.0~译Q过E中除了(jin)hunspell下affixmgr.cxx、hashmgr.cxx和hunspell.cxx三个文g׃svn的编码{换导致文件内容异常外Q没什么大问题?/p> <p>    TSVN的代码写得很beautifulQ这个要赞一下。在清晰的结构下很快对source codeq行?jin)分析,发现TSVN的操作处理代码位于src\TortoiseProc下面Q而对各种操作的UI反馈主要攑֜SVNProgressDlg中。找到要修改的地方,d?jin)几行代码,用NAnt构徏后,替换现装版中的对应文Ӟ出现subversion too old问题Q点开TortoiseProc.exe发现最C码中的subversion版本已经用到?.7.2Q而TSVN对外发布的最新版却还?.6.15Q可能是开发者认MinorVersionqtoo old?jin)吧。算?jin),不折腾?jin)Q直接拉发布?.6.12的tag来修改吧?/p> <p>    1.6.12版的source code用VC++9.0~译Q按照build文档调整一下与前面构徏有差异的地方Q值得注意的是TSVN用到?jin)RibbonQ所以必d安装一下vs2008 sp1补丁。在构徏TortoiseProcӞ有个头文件中重复声明?jin)MFC中已l定义了(jin)的类型,D构徏p|Q需要将重复定义之处注释掉。TortoiseProc一出,我的目的pC(jin)Q由于构建的版本与我安装的一_(d)所以只需替换TortoiseProc.exeQ经试一切OK?/p> <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/3869eb50ee51_FB58/test_2.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="test" border="0" alt="test" src="http://www.shnenglu.com/images/cppblog_com/heath/Windows-Live-Writer/3869eb50ee51_FB58/test_thumb.png" width="671" height="310"></a> </p> <p>    个h觉得Q对TSVN的扩展还是麻?ch)?jin)一点,整个构徏q程p?jin)大量时_(d)增强hook script?/p><img src ="http://www.shnenglu.com/heath/aggbug/139190.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/heath/" target="_blank">Heath</a> 2011-01-23 21:55 <a href="http://www.shnenglu.com/heath/archive/2011/01/23/139190.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用Android手机的Recovery模式Downgrade &amp; Jailbreak PS3http://www.shnenglu.com/heath/archive/2010/12/25/137418.htmlHeathHeathSat, 25 Dec 2010 04:34:00 GMThttp://www.shnenglu.com/heath/archive/2010/12/25/137418.htmlhttp://www.shnenglu.com/heath/comments/137418.htmlhttp://www.shnenglu.com/heath/archive/2010/12/25/137418.html#Feedback0http://www.shnenglu.com/heath/comments/commentRss/137418.htmlhttp://www.shnenglu.com/heath/services/trackbacks/137418.html    从HK买来一台白色slim已经好几个月?jin),一直玩子和下载游戏,pȝ保持?.5。周末到?sh)子市(jng)场逛,看看二手子hQ随便也甩了(jin)手上收藏价g大的游戏。从几个JS处得知现在他们都已经不进新碟?jin),收二手的也就几十块钱。郁闷了(jin)回家Q决定让白JB?jin)。印象中gJB代码已经开源,而且有h已经把它攑֜Android手机上了(jin)Q在|上搜烦(ch)?jin)一下,可以用psfServiceMod刷Recovery来很方便的实现DG&JBQ下面是摘自制作者博客(www.klutsh.comQ上手机支持列表Q?/p>

psfServiceMod Recovery Images

Commtivia Z71 - 0.3.1 3.7 MiB - 55 hits - December 21, 2010

HTC Aria - 0.3.1 3.8 MiB - 35 hits - December 21, 2010

HTC Desire (CDMA) - 0.3.1 3.4 MiB - 74 hits - December 21, 2010

HTC Desire (GSM) - 0.3.1 3.4 MiB - 381 hits - December 21, 2010

HTC Desire HD - 0.3.1 4.2 MiB - 166 hits - December 21, 2010

HTC Desire Z (G2) - 0.3.1 4.3 MiB - 55 hits - December 21, 2010

HTC Dream/Sapphire (32B) - 0.3.1 3.3 MiB - 156 hits - December 21, 2010

HTC Droid Eris - 0.3.1 3.4 MiB - 39 hits - December 21, 2010

HTC Droid Incredible - 0.3.2 3.6 MiB - 75 hits - December 21, 2010

HTC Evo 4G - 0.3.1 3.4 MiB - 109 hits - December 21, 2010

HTC Hero (CDMA) - 0.3.1 3.4 MiB - 75 hits - December 21, 2010

HTC Hero (GSM) - 0.3.1 3.4 MiB - 94 hits - December 21, 2010

HTC Magic/Sapphire (32A) - 0.3.1 3.4 MiB - 73 hits - December 21, 2010

HTC Tattoo - 0.3.1 3.2 MiB - 77 hits - December 21, 2010

HTC Wildfire - 0.3.1 3.6 MiB - 140 hits - December 21, 2010

Motorola Droid - 0.3.1 3.4 MiB - 132 hits - December 21, 2010

Nexus One - 0.3.1 3.4 MiB - 122 hits - December 21, 2010

T-Mobile myTouch 3G Slide - 0.3.1 3.8 MiB - 34 hits - December 21, 2010

T-Mobile myTouch 4G - 0.3.1 4.3 MiB - 30 hits - December 21, 2010

    W者用的HTC Magic(32A)也在其中Q于是用fastboot的USB方式Q关机后按Power+Returnq入后接上USB至PCQ当然PC必须安装DriverQ刷?jin)Recovery。进入Recovery模式Q关机后按Power+HomeQ,断开USBq接Q选择"PSFreedom settings"q入发现用于DG?Put PS3 in Service Mode"、用于JB?Jailbreak FW 3.41"、以?qing)从SD卡加载Payload的功能项一应俱全?/p>

psfServiceMod

    剩下的就和用Dog一L(fng)操作方式来DG&JB?jin),值得注意的是操作旉需要接在右边USB口上QJB操作提示是接在左边)(j)Q?/p>

  • DG操作
  •     1Q关闭PS3q切断电(sh)源,选择"Put PS3 in Service Mode"q入Q?/p>

        2Q将手机q接至PS3双USB口;

        3Q打开PS3甉|Q按开机键后迅速按Z键;

        4Q手柄连接主机重新配对后QPS3q入Factory/Service ModeQ关闭PS3Q?/p>

        5Q找一个U盘(只要是PS3识别的FAT/FAT32格式Q未必需格式化)(j)插上PCQ解?.41修改版固Ӟ有三个文件夹Q“Lv2diag.self FILE 1”,“Lv2diag.self FILE 2”和“Modified 3.41 PUP”?Lv2diag.self FILE 1中的Lv2diag.self以及(qing)Modified 3.41 PUP中的PS3UPDAT.PUP拯到U盘根目录Q?/p>

        6Q拔下U盘插入PS3双的USB口,打开PS3Q屏q没有Q何显C,PS3L的硬盘灯和U盘的指示灯会(x)闪烁Q等待大U?分钟直到PS3甉|l灯闪烁q自动关机;

        7Q拔下U盘,PS3正常开机,仍在服务模式Q确认系l信息已l变?.41。(如需l箋降到更低系l版本,勿删除U盘上的Lv2diag.selfQ将其它pȝ版本PS3UPDATE.PUP攑օU盘,重新执行一遍步?Q。若不需l箋降Q关闭PS3甉|Q?/p>

        8Q在PC上,删除U盘中的Lv2diag.self和PS3UPDAT.PUP两个文gQ把Lv2diag.self FILE 2文g夹中的Lv2diag.self拯到U盘根目录。将U盘插上PS3q开机,仍然黑屏Q等?0U后?x)自动关机。再开机,?x)出现重新连接手柄、新建用L(fng)初始开机画面,完成讄后进入系l信息查看,已是普通的3.41pȝ?jin),降步骤全部完成?/p>

  • JB操作
  •     1Q关闭PS3q切断电(sh)源,选择"Jailbreak FW 3.41"q入Q?/p>

        2Q将手机q接至PS3双USB口;

        3Q打开PS3甉|Q按开机键后迅速按Z键;

        4Q确认JB成功与否Q查看Game下面是否多了(jin)两个新菜单项Q?/p>

        5Q之后就可以?a target="_blank">PS3-HacksM载BackupManager/OpenManager?jin)?/p>

        其实JB是让PS3q入Debug模式Q一旦进入后便可U除JB讑֤。PS3刚JB那会(x)儿,BackupManager是必备工P后面出的Manager都是在其基础上增强,OpenManager比BackupManager多了(jin)从外接硬盘copy/play game的功能。此外Gaia manager也是个很受欢q的ManagerQ除?jin)在UI上比OpenManager好看之外Q还加入?jin)Direct Boot/FTP Server{功能,但Direct Bootq不是那么好使,比如《忍者龙剑传 Sigma2》用Gaiap屏死机,用OM׃?x),M感觉q是OM更稳定?/p>

    Reference

    [1] http://www.klutsh.com

    [2] http://www.ps3-hacks.com/

    [3] Simple Tutorial on How to Downgrade and Jailbreak your PS3 with PsfServiceMod

    [4] http://ps3.cngba.com/ps3_xw/20101215119290.shtml



    Heath 2010-12-25 12:34 发表评论
    ]]>
    Windows下Perforce Command Line处理中文参数的两U方?/title><link>http://www.shnenglu.com/heath/archive/2010/11/15/133692.html</link><dc:creator>Heath</dc:creator><author>Heath</author><pubDate>Mon, 15 Nov 2010 09:58:00 GMT</pubDate><guid>http://www.shnenglu.com/heath/archive/2010/11/15/133692.html</guid><wfw:comment>http://www.shnenglu.com/heath/comments/133692.html</wfw:comment><comments>http://www.shnenglu.com/heath/archive/2010/11/15/133692.html#Feedback</comments><slash:comments>7</slash:comments><wfw:commentRss>http://www.shnenglu.com/heath/comments/commentRss/133692.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/heath/services/trackbacks/133692.html</trackback:ping><description><![CDATA[<p>    Windows下Command Line中的中文字符是采用ANSI~码来处理的Q而Perforce command line要求传入的中文参敎ͼ文gQ夹Q名Qؓ(f)UTF-8~码Q所以需要将中文参数转换为UTF-8后再做处理,下面介绍两种处理Ҏ(gu)?/p> <p>一、系l调?/p> <p>    通过使用WinExec、ShellExecute或systemQ如Q?/p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:a202efe8-f955-49cf-8f11-16a2b3b1f36b" class="wlWriterEditableSmartContent"><pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #008080;">_snprintf</span><span style="color: #000000;">(cmdbuf , </span><span style="color: #800080;">1024</span><span style="color: #000000;"> , </span><span style="color: #800000;">"</span><span style="color: #800000;">p4 -c %s add \</span><span style="color: #800000;">"</span><span style="color: #000000;">%</span><span style="color: #000000;">s\</span><span style="color: #800000;">""</span><span style="color: #000000;"> , argv[</span><span style="color: #800080;">1</span><span style="color: #000000;">] , ANSIToUTF8(path.c_str())); system(cmdbuf);</span></pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p>    此方法的虽然单,但存在效率问题,因ؓ(f)有创E的巨大开销。此外不同版本的Perforce也会(x)出现不同的执行结果,针对特定的中文会(x)出现操作p|的诡异问题?/p> <p>二、Perforce SDK</p> <p>    Perforce提供有SDK用以扩展或集成到其他应用中,虽然没有详细的文,但可以通过学习(fn)SDK中的sample文g来学?fn),此方法最E_?/p> <p>    下面代码展示?jin)通过SDK中ClientAPI来递归d指定文g夹下的所有文Ӟ(x)</p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:891e1b70-295a-4daf-9c0d-8f0ad2ef8b07" class="wlWriterEditableSmartContent"><pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">#</span><span style="color: #000000;"> include </span><span style="color: #800000;">"</span><span style="color: #800000;">clientapi.h</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">#</span><span style="color: #000000;"> include </span><span style="color: #800000;">"</span><span style="color: #800000;">i18napi.h</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">#</span><span style="color: #000000;"> include </span><span style="color: #800000;">"</span><span style="color: #800000;">CharSetConvertUtil.h</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">#</span><span style="color: #000000;"> include </span><span style="color: #000000;"><</span><span style="color: #000000;">string</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">#</span><span style="color: #000000;"> include </span><span style="color: #000000;"><</span><span style="color: #000000;">vector</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">#</span><span style="color: #000000;"> include </span><span style="color: #000000;"><</span><span style="color: #000000;">list</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">#</span><span style="color: #000000;"> include </span><span style="color: #000000;"><</span><span style="color: #000000;">io.h</span><span style="color: #000000;">></span><span style="color: #000000;"> using namespace std; </span><span style="color: #000000;">//</span><span style="color: #000000;"> structure to hold a directory </span><span style="color: #0000FF;">and</span><span style="color: #000000;"> all its filenames. struct FILELIST { string path; vector</span><span style="color: #000000;"><</span><span style="color: #000000;">string</span><span style="color: #000000;">></span><span style="color: #000000;"> theList; }; void TransverseDirectory(string path, list</span><span style="color: #000000;"><</span><span style="color: #000000;">FILELIST</span><span style="color: #000000;">></span><span style="color: #000000;">& theList) { struct </span><span style="color: #008080;">_finddatai</span><span style="color: #000000;">64</span><span style="color: #008080;">_t</span><span style="color: #000000;"> data; string fname </span><span style="color: #000000;">=</span><span style="color: #000000;"> path </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">\\*.*</span><span style="color: #800000;">"</span><span style="color: #000000;">; long h </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #008080;">_findfirsti</span><span style="color: #800080;">64</span><span style="color: #000000;">(fname.c_str(),&data); </span><span style="color: #0000FF;">if</span><span style="color: #000000;">(h </span><span style="color: #000000;">>=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">) { FILELIST thisList; theList.push_back(thisList); list</span><span style="color: #000000;"><</span><span style="color: #000000;">FILELIST</span><span style="color: #000000;">></span><span style="color: #000000;">::iterator it </span><span style="color: #000000;">=</span><span style="color: #000000;"> theList.</span><span style="color: #0000FF;">end</span><span style="color: #000000;">(); it</span><span style="color: #008000;">--</span><span style="color: #008000;">;</span><span style="color: #008000;"> </span><span style="color: #000000;"> (</span><span style="color: #000000;">*</span><span style="color: #000000;">it).path </span><span style="color: #000000;">=</span><span style="color: #000000;"> path; </span><span style="color: #0000FF;">do</span><span style="color: #000000;"> { </span><span style="color: #0000FF;">if</span><span style="color: #000000;">( (data.attrib & </span><span style="color: #008080;">_A_SUBDIR</span><span style="color: #000000;">) ) { </span><span style="color: #000000;">//</span><span style="color: #000000;"> make sure we skip </span><span style="color: #800000;">"</span><span style="color: #800000;">.</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #0000FF;">and</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">..</span><span style="color: #800000;">"</span><span style="color: #000000;">. Have to use strcmp here because </span><span style="color: #000000;">//</span><span style="color: #000000;"> some file names can start with a dot, so just testing </span><span style="color: #0000FF;">for</span><span style="color: #000000;"> the </span><span style="color: #000000;">//</span><span style="color: #000000;"> first dot is </span><span style="color: #0000FF;">not</span><span style="color: #000000;"> suffient. </span><span style="color: #0000FF;">if</span><span style="color: #000000;">( strcmp(data.name,</span><span style="color: #800000;">"</span><span style="color: #800000;">.</span><span style="color: #800000;">"</span><span style="color: #000000;">) !</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;"> &&strcmp(data.name,</span><span style="color: #800000;">"</span><span style="color: #800000;">..</span><span style="color: #800000;">"</span><span style="color: #000000;">) !</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">) { </span><span style="color: #000000;">//</span><span style="color: #000000;"> We found a sub</span><span style="color: #000000;">-</span><span style="color: #000000;">directory, so get the files </span><span style="color: #0000FF;">in</span><span style="color: #000000;"> it too fname </span><span style="color: #000000;">=</span><span style="color: #000000;"> path </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">\\</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> data.name; </span><span style="color: #000000;">//</span><span style="color: #000000;"> recurrsion here! TransverseDirectory(fname,theList); } } </span><span style="color: #0000FF;">else</span><span style="color: #000000;"> { </span><span style="color: #000000;">//</span><span style="color: #000000;"> this is just a normal filename. So just add it to our vector (</span><span style="color: #000000;">*</span><span style="color: #000000;">it).theList.push_back(data.name); } }</span><span style="color: #0000FF;">while</span><span style="color: #000000;">( </span><span style="color: #008080;">_findnexti</span><span style="color: #800080;">64</span><span style="color: #000000;">(h,&data) </span><span style="color: #000000;">==</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">); </span><span style="color: #008080;">_findclose</span><span style="color: #000000;">(h); } } int main( int argc, char </span><span style="color: #000000;">**</span><span style="color: #000000;">argv ) { list</span><span style="color: #000000;"><</span><span style="color: #000000;">FILELIST</span><span style="color: #000000;">></span><span style="color: #000000;"> MyList; string path; ClientUser ui; ClientApi client; StrBuf msg; Error e; </span><span style="color: #0000FF;">if</span><span style="color: #000000;">(argc </span><span style="color: #000000;"><</span><span style="color: #000000;"> </span><span style="color: #800080;">4</span><span style="color: #000000;">) { fprintf( stderr , </span><span style="color: #800000;">"</span><span style="color: #800000;">P4 Transverse Add: Arguments Error!\n</span><span style="color: #800000;">"</span><span style="color: #000000;">); </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> </span><span style="color: #000000;">-</span><span style="color: #800080;">1</span><span style="color: #000000;">; } client.SetPort(argv[</span><span style="color: #800080;">1</span><span style="color: #000000;">]); client.SetClient(argv[</span><span style="color: #800080;">2</span><span style="color: #000000;">]); client.SetTrans(CharSetApi::UTF_8 , CharSetApi::UTF_8 , CharSetApi::UTF_8, CharSetApi::UTF_8); TransverseDirectory(argv[</span><span style="color: #800080;">3</span><span style="color: #000000;">],MyList); </span><span style="color: #000000;">//</span><span style="color: #000000;"> Connect to server client.Init( &e ); </span><span style="color: #0000FF;">if</span><span style="color: #000000;">( e.Test() ) { e.Fmt( &msg ); fprintf( stderr, </span><span style="color: #800000;">"</span><span style="color: #800000;">%s\n</span><span style="color: #800000;">"</span><span style="color: #000000;">, msg.Text() ); </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> </span><span style="color: #000000;">-</span><span style="color: #800080;">1</span><span style="color: #000000;">; } list</span><span style="color: #000000;"><</span><span style="color: #000000;">FILELIST</span><span style="color: #000000;">></span><span style="color: #000000;">::iterator it; </span><span style="color: #0000FF;">for</span><span style="color: #000000;">(it </span><span style="color: #000000;">=</span><span style="color: #000000;"> MyList.begin(); it !</span><span style="color: #000000;">=</span><span style="color: #000000;"> MyList.</span><span style="color: #0000FF;">end</span><span style="color: #000000;">(); it</span><span style="color: #000000;">++</span><span style="color: #000000;">) { vector</span><span style="color: #000000;"><</span><span style="color: #000000;">string</span><span style="color: #000000;">></span><span style="color: #000000;">::iterator its; </span><span style="color: #0000FF;">for</span><span style="color: #000000;">(its </span><span style="color: #000000;">=</span><span style="color: #000000;"> (</span><span style="color: #000000;">*</span><span style="color: #000000;">it).theList.begin(); its !</span><span style="color: #000000;">=</span><span style="color: #000000;"> (</span><span style="color: #000000;">*</span><span style="color: #000000;">it).theList.</span><span style="color: #0000FF;">end</span><span style="color: #000000;">(); its</span><span style="color: #000000;">++</span><span style="color: #000000;">) { path </span><span style="color: #000000;">=</span><span style="color: #000000;"> (</span><span style="color: #000000;">*</span><span style="color: #000000;">it).path </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">\\</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> (</span><span style="color: #000000;">*</span><span style="color: #000000;">its); char</span><span style="color: #000000;">*</span><span style="color: #000000;"> pText </span><span style="color: #000000;">=</span><span style="color: #000000;"> ANSIToUTF8(path.c_str()); client.SetArgv( </span><span style="color: #800080;">1</span><span style="color: #000000;"> , &pText); client.Run( </span><span style="color: #800000;">"</span><span style="color: #800000;">add</span><span style="color: #800000;">"</span><span style="color: #000000;"> , &ui ); } } </span><span style="color: #000000;">//</span><span style="color: #000000;"> Close connection client.Final( &e ); </span><span style="color: #0000FF;">if</span><span style="color: #000000;">( e.Test() ) { e.Fmt( &msg ); fprintf( stderr, </span><span style="color: #800000;">"</span><span style="color: #800000;">%s\n</span><span style="color: #800000;">"</span><span style="color: #000000;">, msg.Text() ); </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> </span><span style="color: #000000;">-</span><span style="color: #800080;">1</span><span style="color: #000000;">; } </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">; }</span></pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p>    此方法省M(jin)创徏p4q程的开销QQ务执行效率会(x)提高不少Q而且也不?x)出现执行结果不E_的问题?nbsp;   </p> <p> </p> <p>附一QSDK下蝲地址</p> <p><a title="ftp://ftp.perforce.com/perforce/" href="ftp://ftp.perforce.com/perforce/">ftp://ftp.perforce.com/perforce/</a></p> <p>附二Q附上ANSI转UTF-8代码</p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:de1a1357-3f18-424a-bec7-b29768d70f5f" class="wlWriterEditableSmartContent"><pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;"> wchar_t</span><span style="color: #000000;">*</span><span style="color: #000000;"> ANSIToUnicode( const char</span><span style="color: #000000;">*</span><span style="color: #000000;"> str ) { int textlen ; wchar_t </span><span style="color: #000000;">*</span><span style="color: #000000;"> result; textlen </span><span style="color: #000000;">=</span><span style="color: #000000;"> MultiByteToWideChar( CP_ACP, </span><span style="color: #800080;">0</span><span style="color: #000000;">, str,</span><span style="color: #000000;">-</span><span style="color: #800080;">1</span><span style="color: #000000;">, NULL,</span><span style="color: #800080;">0</span><span style="color: #000000;"> ); result </span><span style="color: #000000;">=</span><span style="color: #000000;"> (wchar_t </span><span style="color: #000000;">*</span><span style="color: #000000;">)malloc((textlen</span><span style="color: #000000;">+</span><span style="color: #800080;">1</span><span style="color: #000000;">)</span><span style="color: #000000;">*</span><span style="color: #000000;">sizeof(wchar_t)); memset(result,</span><span style="color: #800080;">0</span><span style="color: #000000;">,(textlen</span><span style="color: #000000;">+</span><span style="color: #800080;">1</span><span style="color: #000000;">)</span><span style="color: #000000;">*</span><span style="color: #000000;">sizeof(wchar_t)); MultiByteToWideChar(CP_ACP, </span><span style="color: #800080;">0</span><span style="color: #000000;">,str,</span><span style="color: #000000;">-</span><span style="color: #800080;">1</span><span style="color: #000000;">,(LPWSTR)result,textlen ); </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> result; } char</span><span style="color: #000000;">*</span><span style="color: #000000;"> UnicodeToANSI( const wchar_t </span><span style="color: #000000;">*</span><span style="color: #000000;">str ) { char </span><span style="color: #000000;">*</span><span style="color: #000000;"> result; int textlen; </span><span style="color: #000000;">//</span><span style="color: #000000;"> wide char to multi char textlen </span><span style="color: #000000;">=</span><span style="color: #000000;"> WideCharToMultiByte( CP_ACP, </span><span style="color: #800080;">0</span><span style="color: #000000;">, str, </span><span style="color: #000000;">-</span><span style="color: #800080;">1</span><span style="color: #000000;">, NULL, </span><span style="color: #800080;">0</span><span style="color: #000000;">, NULL, NULL ); result </span><span style="color: #000000;">=</span><span style="color: #000000;">(char </span><span style="color: #000000;">*</span><span style="color: #000000;">)malloc((textlen</span><span style="color: #000000;">+</span><span style="color: #800080;">1</span><span style="color: #000000;">)</span><span style="color: #000000;">*</span><span style="color: #000000;">sizeof(char)); memset( result, </span><span style="color: #800080;">0</span><span style="color: #000000;">, sizeof(char) </span><span style="color: #000000;">*</span><span style="color: #000000;"> ( textlen </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> ) ); WideCharToMultiByte( CP_ACP, </span><span style="color: #800080;">0</span><span style="color: #000000;">, str, </span><span style="color: #000000;">-</span><span style="color: #800080;">1</span><span style="color: #000000;">, result, textlen, NULL, NULL ); </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> result; } wchar_t</span><span style="color: #000000;">*</span><span style="color: #000000;"> UTF8ToUnicode( const char</span><span style="color: #000000;">*</span><span style="color: #000000;"> str ) { int textlen ; wchar_t </span><span style="color: #000000;">*</span><span style="color: #000000;"> result; textlen </span><span style="color: #000000;">=</span><span style="color: #000000;"> MultiByteToWideChar( CP_UTF8, </span><span style="color: #800080;">0</span><span style="color: #000000;">, str,</span><span style="color: #000000;">-</span><span style="color: #800080;">1</span><span style="color: #000000;">, NULL,</span><span style="color: #800080;">0</span><span style="color: #000000;"> ); result </span><span style="color: #000000;">=</span><span style="color: #000000;"> (wchar_t </span><span style="color: #000000;">*</span><span style="color: #000000;">)malloc((textlen</span><span style="color: #000000;">+</span><span style="color: #800080;">1</span><span style="color: #000000;">)</span><span style="color: #000000;">*</span><span style="color: #000000;">sizeof(wchar_t)); memset(result,</span><span style="color: #800080;">0</span><span style="color: #000000;">,(textlen</span><span style="color: #000000;">+</span><span style="color: #800080;">1</span><span style="color: #000000;">)</span><span style="color: #000000;">*</span><span style="color: #000000;">sizeof(wchar_t)); MultiByteToWideChar(CP_UTF8, </span><span style="color: #800080;">0</span><span style="color: #000000;">,str,</span><span style="color: #000000;">-</span><span style="color: #800080;">1</span><span style="color: #000000;">,(LPWSTR)result,textlen ); </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> result; } char</span><span style="color: #000000;">*</span><span style="color: #000000;"> UnicodeToUTF8( const wchar_t </span><span style="color: #000000;">*</span><span style="color: #000000;">str ) { char </span><span style="color: #000000;">*</span><span style="color: #000000;"> result; int textlen; </span><span style="color: #000000;">//</span><span style="color: #000000;"> wide char to multi char textlen </span><span style="color: #000000;">=</span><span style="color: #000000;"> WideCharToMultiByte( CP_UTF8, </span><span style="color: #800080;">0</span><span style="color: #000000;">, str, </span><span style="color: #000000;">-</span><span style="color: #800080;">1</span><span style="color: #000000;">, NULL, </span><span style="color: #800080;">0</span><span style="color: #000000;">, NULL, NULL ); result </span><span style="color: #000000;">=</span><span style="color: #000000;">(char </span><span style="color: #000000;">*</span><span style="color: #000000;">)malloc((textlen</span><span style="color: #000000;">+</span><span style="color: #800080;">1</span><span style="color: #000000;">)</span><span style="color: #000000;">*</span><span style="color: #000000;">sizeof(char)); memset(result, </span><span style="color: #800080;">0</span><span style="color: #000000;">, sizeof(char) </span><span style="color: #000000;">*</span><span style="color: #000000;"> ( textlen </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> ) ); WideCharToMultiByte( CP_UTF8, </span><span style="color: #800080;">0</span><span style="color: #000000;">, str, </span><span style="color: #000000;">-</span><span style="color: #800080;">1</span><span style="color: #000000;">, result, textlen, NULL, NULL ); </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> result; } char</span><span style="color: #000000;">*</span><span style="color: #000000;"> ANSIToUTF8(const char</span><span style="color: #000000;">*</span><span style="color: #000000;"> str) { wchar_t</span><span style="color: #000000;">*</span><span style="color: #000000;"> pUnicodeBuff </span><span style="color: #000000;">=</span><span style="color: #000000;"> ANSIToUnicode(str); char</span><span style="color: #000000;">*</span><span style="color: #000000;"> pUtf8Buff </span><span style="color: #000000;">=</span><span style="color: #000000;"> UnicodeToUTF8(pUnicodeBuff); free(pUnicodeBuff); </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> pUtf8Buff; }</span></pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div><img src ="http://www.shnenglu.com/heath/aggbug/133692.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/heath/" target="_blank">Heath</a> 2010-11-15 17:58 <a href="http://www.shnenglu.com/heath/archive/2010/11/15/133692.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>&quot;Inception&quot; ?/title><link>http://www.shnenglu.com/heath/archive/2010/09/05/125961.html</link><dc:creator>Heath</dc:creator><author>Heath</author><pubDate>Sun, 05 Sep 2010 15:02:00 GMT</pubDate><guid>http://www.shnenglu.com/heath/archive/2010/09/05/125961.html</guid><wfw:comment>http://www.shnenglu.com/heath/comments/125961.html</wfw:comment><comments>http://www.shnenglu.com/heath/archive/2010/09/05/125961.html#Feedback</comments><slash:comments>7</slash:comments><wfw:commentRss>http://www.shnenglu.com/heath/comments/commentRss/125961.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/heath/services/trackbacks/125961.html</trackback:ping><description><![CDATA[<p>    不愧为“天才导演”,Nolan选取?jin)h们很关注的梦境作ؓ(f)题材Q利用梦中梦的递归手法拓宽?jin)时I感Q让观众觉得q很有嚼头。媄(jing)片首֑应,中间以入늛标梦境ƈ植入一个想法ؓ(f)ȝQ递归深度辑ֈ?层,可见导演的用?j)之处。期间还I插着一条支U,那就是柯布的梦境Q这一直是他的痛,直到故事最后,他才释怀?/p> <p>    ?j)理学?f)该媄(jing)片了(jin)理论基础Q盗梦的目的是Z(jin)H探目标埋藏在心(j)里的U密Q因为梦是伪装得最的潜意识表现。而作入目标梦境的工具Q导演却是一W带q,不得不说是一个遗憾,因而该q也就成了(jin)一部纯U?sh)?jing)?/p> <p>    观媄(jing)毕,个h感觉Dream Design应该也和Game Design怼吧:(x)故事、h物、时间、场景的设计。Programmer也深d温习(fn)?jin)一下递归吧?/p> <p> </p> <p>B.T.W. 多年以来Q能够撼动我思想的媄(jing)片仅有两部:(x)"The Matrix"?Inception"?/p> <p> </p> <p><a href="http://www.shnenglu.com/images/cppblog_com/heath/WindowsLiveWriter/Inception_13B82/Inception_2.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Inception" border="0" alt="Inception" src="http://www.shnenglu.com/images/cppblog_com/heath/WindowsLiveWriter/Inception_13B82/Inception_thumb.jpg" width="409" height="570"></a></p><img src ="http://www.shnenglu.com/heath/aggbug/125961.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/heath/" target="_blank">Heath</a> 2010-09-05 23:02 <a href="http://www.shnenglu.com/heath/archive/2010/09/05/125961.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Kindle DXGhttp://www.shnenglu.com/heath/archive/2010/08/21/124193.htmlHeathHeathSat, 21 Aug 2010 08:44:00 GMThttp://www.shnenglu.com/heath/archive/2010/08/21/124193.htmlhttp://www.shnenglu.com/heath/comments/124193.htmlhttp://www.shnenglu.com/heath/archive/2010/08/21/124193.html#Feedback2http://www.shnenglu.com/heath/comments/commentRss/124193.htmlhttp://www.shnenglu.com/heath/services/trackbacks/124193.html    Amazon??日发布了(jin)代号为Graphite的Kindle DXQ同时全面下调kindle 2和kindle DX的h(hun)根{原计划{IPad在HK上市(jng)后去那边买的Q后来考虑C用于看电(sh)子书Q还是E-INK屏比较好Q正?.7寸屏的Kindle DXG也落C(jin)?j)理价位Q于是决定入手之?7?日下单,期间遇上?jin)v关严打,货被扣了(jin)2周后交税放行Q??0日到手。用近一个月QM来讲q不错:(x)

    1QFree 3G速度快,看新L便;

    2Q分辨率高,字体清晰Q?/p>

    2QNative PDF SupportQ翻速度已经很快?jin),对于内嵌中文字体也有很好地支持。看PDF文档Ӟ9.7寸屏?寸屏更易于阅诅RZoom功能q乎鸡肋Q因为很不喜Ƣ拉着滚动条阅读,看扫描书的时候顶多用一下横屏。此外,׃Kindle?x)把颜色转换为灰度,所以对于非U色的文字,?x)显得很淡?/p>

    3Q由于AmazonMobipocket收归旗下的缘故,所以对mobi/prc文g格式的支持和azw格式一样好Q提供指译、字体羃放、注?W记{功能;

    4Q通过Gift Card的方式购买电(sh)子书也挺方便Q免M(jin)买纸质书的运费和q输延迟。不q技术书的电(sh)子版本很,且h(hun)格昂贵;

    5Q待机时间长Q这是E-INK阅读器的一大优势;

    6Q加上原装皮套,重量和一本A4 600左右的书差不多?/p>

        对于?sh)子书{换工P个h推荐QMobipocket和CalibreQ仅Mac OSQ。后者是开源的Q功能和输出文g质量胜于前者?/p>

    image

    image

    image

    image



    Heath 2010-08-21 16:44 发表评论
    ]]>
    CruiseControl.NET for CI in Game developmenthttp://www.shnenglu.com/heath/archive/2010/08/09/122834.htmlHeathHeathMon, 09 Aug 2010 12:22:00 GMThttp://www.shnenglu.com/heath/archive/2010/08/09/122834.htmlhttp://www.shnenglu.com/heath/comments/122834.htmlhttp://www.shnenglu.com/heath/archive/2010/08/09/122834.html#Feedback0http://www.shnenglu.com/heath/comments/commentRss/122834.htmlhttp://www.shnenglu.com/heath/services/trackbacks/122834.html    有个目使用?jin)CruiseControl.NETQ以下简UCC.NETQ作为持l集成工P周末抽空研究?jin)一下,发现q款?b>ThoughtWorks贡献的开源工具功能非常强大,主要体现在下面三个方面:(x)

    1Q灵zR高可配|性,如:(x)多重l合条g触发、多d队列{略Q?

    2Q兼容目前几乎所有的行SCM工具Q得多U异构系l能够由CruiseControl.NETl一监控和管理;

    3Q完善的使用文Q上手和维护变得容易;

        而该目引以自豪的代码check in触发构徏的功能通过CC.NET也很Ҏ(gu)实现。之前用过HudsonQ该pȝ采用M式架构,使用者通过|页让Master控制Slave动作Q由于Master由别的部门管理,出问题后需要联pȝ关h解决Q会(x)有一定的处理延迟Q而且安装在构建机上的Slave服务l常崩溃。而CC.NET直接安装在构建机上,配置IIS后可通过|页直接讉KQ操作维护都较前者容易。由于之前的构徏脚本是用VisualBuild实现的,所以不可能再花旉用CC.NET再写一遍。而通过实验得知Q其实CC.NET能够以ExecutableTask的Ş式很好地与VisualBuild集成Q目前每时定时构徏、NightBuild和构建成功后触发的自动测试都已经攑ֈ?jin)CC.NET上了(jin)?

        ccnet.config Example:

    <cruisecontrol xmlns:cb="urn:ccnet.config.builder">
      <queue name="Q1" duplicates="ApplyForceBuildsReAdd" />
      <queue name="Q2" duplicates="ApplyForceBuildsReAdd" />
      <project name="AgileBuild" queue="Q1" queuePriority="1">
        <category>AutoBuild</category>
        <triggers>
          <filterTrigger startTime="18:00" endTime="10:00">
            <trigger type="intervalTrigger" name="Continuous" seconds="1800" buildCondition="ForceBuild" />
            <weekDays>
              <weekDay>Monday</weekDay>
              <weekDay>Tuesday</weekDay>
              <weekDay>Wednesday</weekDay>
              <weekDay>Thursday</weekDay>
              <weekDay>Friday</weekDay>
            </weekDays>
          </filterTrigger>
        </triggers>
        <tasks>
          <exec>
            <executable>VisBuildCmd.exe</executable>
            <buildArgs>E:\GAMEDev\AgileBuilder.bld</buildArgs>
            <baseDirectory>D:\VisBuildPro7</baseDirectory>
            <buildTimeoutSeconds>3000</buildTimeoutSeconds>
          </exec>
        </tasks>
      </project>
      <project name="NightBuild" queue="Q2" queuePriority="1">
        <category>AutoBuild</category>
        <triggers>
          <scheduleTrigger time="23:00" buildCondition="ForceBuild" name="Scheduled">
            <weekDays>
              <weekDay>Monday</weekDay>
              <weekDay>Tuesday</weekDay>
              <weekDay>Wednesday</weekDay>
              <weekDay>Thursday</weekDay>
              <weekDay>Friday</weekDay>
            </weekDays>
          </scheduleTrigger>      
        </triggers>  
        <tasks>
          <exec>
            <executable>VisBuildCmd.exe</executable>
            <buildArgs>"BUILD_OPTION=clientworldeffect" "PACK_TYPE=RAR" E:\GAMEDev\NightBuilder.bld</buildArgs>
            <baseDirectory>D:\VisBuildPro7</baseDirectory>
            <buildTimeoutSeconds>0</buildTimeoutSeconds>
          </exec>
        </tasks>
      </project>
      <project name="NightAutoTest" queue="Q2" queuePriority="2">
        <category>AutoTest</category>
        <triggers>
          <projectTrigger serverUri="tcp://heath-builder:21234/CruiseManager.rem" project="NightBuild">
            <triggerStatus>Success</triggerStatus>
            <innerTrigger type="intervalTrigger" seconds="60" buildCondition="ForceBuild" />
          </projectTrigger>
        </triggers>
        <tasks>
          <exec>
            <executable>VisBuildCmd.exe</executable>
            <buildArgs>E:\GAMEDev\AutoTest.bld</buildArgs>
            <baseDirectory>D:\VisBuildPro7</baseDirectory>
            <buildTimeoutSeconds>0</buildTimeoutSeconds>
          </exec>
        </tasks>
      </project>  
    </cruisecontrol>
    

    References

    [1] http://cruisecontrol.sourceforge.net/

    [2] http://www.kinook.com/VisBuildPro/



    Heath 2010-08-09 20:22 发表评论
    ]]>
    Lua Insidehttp://www.shnenglu.com/heath/archive/2010/07/18/120686.htmlHeathHeathSun, 18 Jul 2010 04:46:00 GMThttp://www.shnenglu.com/heath/archive/2010/07/18/120686.htmlhttp://www.shnenglu.com/heath/comments/120686.htmlhttp://www.shnenglu.com/heath/archive/2010/07/18/120686.html#Feedback1http://www.shnenglu.com/heath/comments/commentRss/120686.htmlhttp://www.shnenglu.com/heath/services/trackbacks/120686.html一、Table

        Table实际上是数组和哈希表的؜合体。当保存以连l整Cؓ(f)索引的内Ҏ(gu)Q用数l结构;而对于离散烦(ch)引及(qing)键值对Q则使用哈希表存储。这样做对于I间节省和查找效率都是有好处的,举例Q?/p>

    tt = {"a" , "b" , "c"}
    print(#tt)  --> 3
    tt[100] = "d"
    print(#tt)    --> 3 (100-"d"键值对攑օ哈希?
    tt[4] = "e"
    print(#tt)    --> 4

    二、Closure

        Lua的变量引用规则造成?jin)闭包的出现Q在Lua中一个复杂数据结构(table、functionQ被赋予一个变量时Q变量仅仅拿取其引用。试考虑下面代码片段Q?/p>

    local f1 = function() ... end
    local f2 = function() ... end
    local f3 = f1

        判断f1与f2是否相等Q得到的l果为假Q而f3与f1则ؓ(f)真。这是因为f1与f2引用?jin)两个不同的函数chunkQ也可称为“定义”)(j)Q而f1直接其引用Q可以看成C/C++中的地址Q赋lf3Q故而相{?br>理解?jin)上面问题,再看看下面的一个函敎ͼ(x)

    function createCounter()
        local x = 0
        return function()
            x = x + 1
            print(x)
        end
    end

        那么Q下面c1与c2相等吗?

    c1 = createCounter()
    c2 = createCounter()

        ׃createCounter中的return部分创徏?jin)一个新函数Q因此c1和c2引用的函数ƈ不相同。因为return的匿名函C使用C(jin)外部函数(即createCounter)的局部变量xQ所以Lua必须要在某个地方保存q个变量Q又因ؓ(f)每次q回的都是一个新函数Q所以Lua不能׃ncreateCounter中的xQ进而Lua必须为每个新函数分配一个保存x的地方,q个问题D?jin)闭包概늚产生?br>    通过上面分析Q可以明白是语言机制D?jin)闭包,而绝非Lua作者故意制造出q么一个看似有点神U的东西?br>    下面l出闭包的定义:(x)一个保留了(jin)创徏时上下文的函数。而upvalue的定义是Q被闭包讉K的保留变量。实际上所有在Lua中创建的函数都是闭包Q在许多情况下仅有一个原型的闭包存在Q因为函数块只执行了(jin)一ơ(也可以说定义?jin)一ơ)(j)?

        下面代码用闭包实C(jin)一个对象工厂:(x)

    local function CounterFactory()
        local x = 0
        return 
        {
            Increase = function()
                x = x + 1
            end ,
            Decrease = function()
                x = x - 1
            end ,
            GetValue = function()
                return x
            end
        }
    end
    
    local c1 = CounterFactory()
    local c2 = CounterFactory()
    
    c1.Increase()
    c1.Increase()
    print(c1.GetValue())

    三、Tail Call

         首先需要明What is ‘Tail Call?——其形式为“return f(?”,return语句中的函数调用仅限于单一调用Q涉?qing)函数返回D的复合表达式不是尾调用Q如Qreturn i * f(i - 1)。由定义可以看出调用实际上是对位于q回语句中的函数调用的优化。通常调用一个函数都需要将其上下文入栈Q然后再q入被调函数。在Lua中执行符合尾调用形式的函数时Q因函数已经没有代码需要执行了(jin)Q故作者作?jin)不保存上下文的优化。这样带来的好处是:(x)对于_ֿ(j)构徏的递归调用Q不需要有栈的消耗,因而绝对不?x)出现overflowQ看看下面递归调用产生的死循环Q?/p>

    local function f(n)
        local i = n + 1
        print(i)
        return f(i)  -- tail call
    end
    
    f(0)

    四、Metatable

        Metatable常用来扩展table的行为,通过setmetatable(table , metatable)metatable挂接到table上,很多开发者用该特性来实现面向对象的设计。Metatable中提供了(jin)MetamethodsQ这些方法都以双下划U__开_(d)如:(x)

            __add , __call , __concat , __div , __eq , __index...

        以上Metamethods中,__index被调用的条g是:(x)key不在对应的table中。利用该Ҏ(gu)可以实现类-对象、承等面向对象概念Q下面是个简单例子:(x)

    local Actor = {}
    Actor.name  = "unnamed"
    Actor.hp    = 100
    Actor.dead  = false
    Actor.level = 1
    Actor.type  = "unknown"
    
    function Actor:Say(text)
        print(self.name..":"..text)
    end
    
    function Actor:IsDead()
        return self.dead
    end
    
    local AttackableActor = setmetatable({ } , { __index = Actor })
    AttackableActor.damage = 20
    
    function AttackableActor:ReceiveHit(attacker)
        self:Say("I'm being attacked by "..attacker.name)
        self.hp = self.hp - attacker.damage
        if self.hp <= 0 then
            self:Say("I'm died :(")
            self.dead = true
        else
            self:Say("My HP is "..self.hp)
        end
    end
    
    function AttackableActor:Attack(target)
        if target.dead == true then
            self:Say("Oh, "..target.name.." has been dead!")
        else
            self:Say("I'm is attacking "..target.name)
            target:ReceiveHit(self)
        end
    end
    
    function CreateMonster(name , damage)
        local m = setmetatable({ } , { __index = AttackableActor})
        m.name = name
        m.damage = damage
        m.type = "monster"
        return m
    end
    
    function CreatePlayer(name , damage)
        local p = setmetatable({ } , { __index = AttackableActor})
        p.name = name
        p.damage = damage
        p.type = "player"
        return p
    end
    
    math.randomseed(os.time())
    
    local boss = CreateMonster("Kerrigan" , math.floor(100 * math.random()))
    local player = CreatePlayer("Raynor" , math.floor(100 * math.random()))
    
    while player:IsDead() == false and boss:IsDead() == false do
        player:Attack(boss)
        boss:Attack(player)
    end

    五、Performance Tips

        请参?a target="_blank">Lua Performance Tips

    六、ȝ

        Lua是一门语法简z,用法灉|的动态语a。在全面掌握之后Q需(zhn)心(j)使用乃可构造出z高效的代码?/p>

    Heath 2010-07-18 12:46 发表评论
    ]]>
    How to install Mac OS X 10.6.3 on PC from Hard Diskhttp://www.shnenglu.com/heath/archive/2010/05/14/115403.htmlHeathHeathFri, 14 May 2010 13:57:00 GMThttp://www.shnenglu.com/heath/archive/2010/05/14/115403.htmlhttp://www.shnenglu.com/heath/comments/115403.htmlhttp://www.shnenglu.com/heath/archive/2010/05/14/115403.html#Feedback7http://www.shnenglu.com/heath/comments/commentRss/115403.htmlhttp://www.shnenglu.com/heath/services/trackbacks/115403.html阅读全文

    Heath 2010-05-14 21:57 发表评论
    ]]>
    Enable AHCI mode after installing Windows xphttp://www.shnenglu.com/heath/archive/2010/05/14/115400.htmlHeathHeathFri, 14 May 2010 13:26:00 GMThttp://www.shnenglu.com/heath/archive/2010/05/14/115400.htmlhttp://www.shnenglu.com/heath/comments/115400.htmlhttp://www.shnenglu.com/heath/archive/2010/05/14/115400.html#Feedback0http://www.shnenglu.com/heath/comments/commentRss/115400.htmlhttp://www.shnenglu.com/heath/services/trackbacks/115400.html阅读全文

    Heath 2010-05-14 21:26 发表评论
    ]]>
    C++认知误区(1)Q成员保护机?/title><link>http://www.shnenglu.com/heath/archive/2010/04/24/113445.html</link><dc:creator>Heath</dc:creator><author>Heath</author><pubDate>Sat, 24 Apr 2010 08:16:00 GMT</pubDate><guid>http://www.shnenglu.com/heath/archive/2010/04/24/113445.html</guid><wfw:comment>http://www.shnenglu.com/heath/comments/113445.html</wfw:comment><comments>http://www.shnenglu.com/heath/archive/2010/04/24/113445.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.shnenglu.com/heath/comments/commentRss/113445.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/heath/services/trackbacks/113445.html</trackback:ping><description><![CDATA[     摘要: 生活、工作中?x)有各种各样认知误区Q与自己认知相?zhn)的,不一定是错误?nbsp; <a href='http://www.shnenglu.com/heath/archive/2010/04/24/113445.html'>阅读全文</a><img src ="http://www.shnenglu.com/heath/aggbug/113445.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/heath/" target="_blank">Heath</a> 2010-04-24 16:16 <a href="http://www.shnenglu.com/heath/archive/2010/04/24/113445.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>写着?2)&mdash;&mdash;WoW角色资源dhttp://www.shnenglu.com/heath/archive/2010/04/24/113423.htmlHeathHeathSat, 24 Apr 2010 04:31:00 GMThttp://www.shnenglu.com/heath/archive/2010/04/24/113423.htmlhttp://www.shnenglu.com/heath/comments/113423.htmlhttp://www.shnenglu.com/heath/archive/2010/04/24/113423.html#Feedback2http://www.shnenglu.com/heath/comments/commentRss/113423.htmlhttp://www.shnenglu.com/heath/services/trackbacks/113423.html阅读全文

    Heath 2010-04-24 12:31 发表评论
    ]]>
    Slerp or Lerphttp://www.shnenglu.com/heath/archive/2010/03/14/109689.htmlHeathHeathSun, 14 Mar 2010 09:54:00 GMThttp://www.shnenglu.com/heath/archive/2010/03/14/109689.htmlhttp://www.shnenglu.com/heath/comments/109689.htmlhttp://www.shnenglu.com/heath/archive/2010/03/14/109689.html#Feedback1http://www.shnenglu.com/heath/comments/commentRss/109689.htmlhttp://www.shnenglu.com/heath/services/trackbacks/109689.htmlUnderstanding Slerp, Then Not Using It对Slerp的v源及(qing)性能做了(jin)详细的讨论。Slerpq不局限于l数Q因而不要认为只对Quaternion有效。作者认为Slerp?x)带来效率问题,即便l过优化也ƈ不能辑ֈ理想的速度(与lerp做比较而言)Q而且优化往往?x)降低代码的易读性。文章给Z(jin)一个结论:(x)如果插DE中的常量速度不是必须的,那么最好用线性的lerp?/p>

    Jason Gregory在他的引擎架构设计一书中也用“To SLERP or Not to SLERP (That’s Still the Question)”一节介绍?jin)开发者对Slerp的争论,q介l他在Naughty Dog的同事针对PS3的优化方法,使Slerp可达?0周期/兌Q相比Lerp?6.25周期/兌已经很不错了(jin)?/p>

    之前实没对Slerp的效率问题作q多的考虑Q引擎的Slerp直接使用的是D3DXQuaternionSlerpQMS应该对其做了(jin)优化Q效率怎么栯一下才知道?jin)?/p>

    Heath 2010-03-14 17:54 发表评论
    ]]>
    þþþþþþƷŮ99| Ʒþ| 99ȾƷþֻоƷ| 94þù׾Ʒ| þav| ëƬþþþþùëƬ| ƷŷƬþùŷ... ƷŷƬþùŷ | 91ƷùۺϾþ| þó˾Ʒ| þþƷ7777| þþþþüƷþþ| ߾þþƷĹ| þǿdŮվ| AVþþþòվ | Ӱһþþþó˾Ʒۺ | ŷƷ˿þþĻ | þþۺ㽶ۺ| ĻþþƷ| պ뾫Ʒþһ| þþƷɧ| ˾Ʒһþ| ھƷþþþӰԺ| þþƷĻ | ھƷþۺ88 | Ʒҹþ| Ʒþþþþ| þþƷŷ| ޹˾þһWWW| þҹ³˿Ƭ| Ʒþþþþ| þþƷһۺ| þþƷһ| ĻþþƷ| ձþþþþĻ| ˾þó˳ۺ222| ھƷþþþӰԺ| þۺϾƷһ | ҹƷþþþþžŵӰ| ŷպƷþþþ| 99þù޸ۿ2024 | Ʒպҹþ|