Skip to content

Commit 6a8a61a

Browse files
committed
Well, everything's fixed except for the goddamn asset downloader.
1 parent 8ebf78a commit 6a8a61a

File tree

88 files changed

+10033
-2972
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+10033
-2972
lines changed

indra/newview/LuaInventory_f.cpp

Lines changed: 82 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <boost/tokenizer.hpp>
1919

2020

21+
void requestInventoryAsset_Event(LLUUID reqID,LLUUID task_id,LLUUID item_id);
2122
void giveInventoryItem_Event(LLUUID to_agent, LLUUID item_id, LLUUID im_session_id);
2223
LLUUID TraverseCategories(const std::string& target_cat, LLViewerInventoryCategory *ccat=NULL, int i=0);
2324
void Lua_onAssetDownloaded(LLVFS *vfs,const LLUUID& asset_uuid,LLAssetType::EType type,void* user_data, S32 status, LLExtStat ext_status);
@@ -102,6 +103,7 @@ LLUUID getInventoryItemUUID(const std::string& name, int type)
102103

103104
LLUUID getInventoryAssetUUID(const std::string& name, int type)
104105
{
106+
llinfos << "getInventoryAssetUUID("<< name <<","<< type <<")" << llendl;
105107
LLViewerInventoryCategory::cat_array_t cats;
106108
LLViewerInventoryItem::item_array_t items;
107109
LunaFindItemByName byn(name,(LLAssetType::EType)type);
@@ -114,6 +116,7 @@ LLUUID getInventoryAssetUUID(const std::string& name, int type)
114116

115117
std::string getInventoryItemName(LLUUID key, int type)
116118
{
119+
llinfos << "getInventoryItemName("<< key <<","<< type <<")" << llendl;
117120
LLInventoryItem *item = gInventory.getItem(key);
118121
if(!item)
119122
{
@@ -205,56 +208,23 @@ void giveInventoryItem(LLUUID to_agent, LLUUID item_id, LLUUID im_session_id)
205208
CB_Args3<LLUUID,LLUUID,LLUUID>(giveInventoryItem_Event,to_agent,item_id,im_session_id);
206209
}
207210

208-
LLUUID requestInventoryAsset(LLUUID item_id,LLUUID task_id)
209-
{
210-
LLUUID new_item_id=LLUUID::generateNewID();
211-
LLViewerInventoryItem *item = gInventory.getItem(item_id);
212-
if(!item)
213-
{
214-
LuaError(llformat("Could not find item %s.",item_id.asString()).c_str());
215-
return LLUUID::null;
216-
}
217-
218-
if (!gAgent.allowOperation(PERM_COPY, item->getPermissions(),GP_OBJECT_MANIPULATE) && gAgent.isGodlike())
219-
{
220-
LuaError(llformat("You do not have copy permission on %s %s.",
221-
LLAssetType::lookupHumanReadable(item->getActualType()),
222-
item->getName()).c_str());
223-
return LLUUID::null;
224-
}
225-
LLHost source_sim = LLHost::invalid;
226-
LLUUID invfolderid = item->getParentUUID();
227-
gAssetStorage->getInvItemAsset(source_sim,
228-
gAgent.getID(),
229-
gAgent.getSessionID(),
230-
item->getPermissions().getOwner(),
231-
LLUUID::null,
232-
item->getUUID(),
233-
item->getAssetUUID(),
234-
item->getType(),
235-
&Lua_onAssetDownloaded,
236-
(void*)new LLUUID(new_item_id),
237-
TRUE);
238-
return new_item_id;
239-
}
240-
241-
242211
void Lua_onAssetDownloaded(LLVFS *vfs,const LLUUID& asset_uuid,LLAssetType::EType type,void* user_data, S32 status, LLExtStat ext_status)
243212
{
244213
// Pointer juggling. Yay.
245214
LLUUID req_key = *((LLUUID*)user_data);
246215
if(status == LL_ERR_NOERR)
247216
{
217+
llinfos << "requestInventoryAsset(): Asset received" << llendl;
248218
S32 size = vfs->getSize(asset_uuid, type);
249219
U8* buffer = new U8[size];
250220
vfs->getData(asset_uuid, type, buffer, 0, size);
251221

222+
LLViewerTextEditor* edit = new LLViewerTextEditor("",LLRect(0,0,0,0),S32_MAX,"");
252223
switch(type)
253224
{
254225
// Text-based assets only.
255226
case LLAssetType::AT_NOTECARD:
256227
case LLAssetType::AT_LSL_TEXT:
257-
LLViewerTextEditor* edit = new LLViewerTextEditor("",LLRect(0,0,0,0),S32_MAX,"");
258228
if(edit->importBuffer((char*)buffer, (S32)size))
259229
{
260230
std::string card = edit->getText();
@@ -269,13 +239,87 @@ void Lua_onAssetDownloaded(LLVFS *vfs,const LLUUID& asset_uuid,LLAssetType::ETyp
269239
return;
270240
}
271241
break;
272-
242+
default:
243+
LuaError(llformat("[requestInventoryAsset] Unknown type %s.",LLAssetType::lookup(type)).c_str());
244+
LUA_CALL("OnAssetFailed") << req_key << LUA_END;
245+
break;
273246
}
274247
}
275248
else
276249
{
277-
llinfos << "ao nc read error" << llendl;
250+
llinfos << "requestInventoryAsset(): Asset read error: " << status << llendl;
251+
LuaError("[requestInventoryAsset] Read error. ");
278252
LUA_CALL("OnAssetFailed") << req_key << LUA_END;
279253
return;
280254
}
281-
}
255+
}
256+
void requestInventoryAsset_Event(LLUUID &reqID,LLUUID &task_id,LLUUID &item_id)
257+
{
258+
llinfos << "requestInventoryAsset_Event("<< reqID <<","<< task_id <<","<< item_id <<"): Requesting asset." << llendl;
259+
//LLViewerInventoryItem *item = gInventory.getItem(item_id);
260+
261+
llinfos << "requestInventoryAsset("<< item_id <<","<< task_id <<"): Getting item" << llendl;
262+
LLViewerInventoryItem *item = gInventory.getItem(item_id);
263+
if(!item)
264+
{
265+
LuaError(llformat("Could not find item %s.",item_id.asString()).c_str());
266+
return;
267+
}
268+
269+
270+
llinfos << "requestInventoryAsset("<< item_id <<","<< task_id <<"): Checking if asset download is allowed" << llendl;
271+
if (!gAgent.allowOperation(PERM_COPY, item->getPermissions(),GP_OBJECT_MANIPULATE) && gAgent.isGodlike())
272+
{
273+
LuaError(llformat("You do not have copy permission on %s %s.",
274+
LLAssetType::lookupHumanReadable(item->getActualType()),
275+
item->getName()).c_str());
276+
return;
277+
}
278+
279+
llinfos << "requestInventoryAsset("<< item_id <<","<< task_id <<"): Queueing asset request" << llendl;
280+
281+
LLHost source_sim = LLHost::invalid;
282+
LLUUID invfolderid = item->getParentUUID();
283+
gAssetStorage->getInvItemAsset(source_sim,
284+
gAgent.getID(),
285+
gAgent.getSessionID(),
286+
item->getPermissions().getOwner(),
287+
task_id,
288+
item_id,
289+
item->getAssetUUID(),
290+
item->getType(),
291+
&Lua_onAssetDownloaded,
292+
(void*)new LLUUID(reqID),
293+
TRUE);
294+
}
295+
296+
297+
LLUUID requestInventoryAsset(LLUUID item_id,LLUUID task_id)
298+
{
299+
llinfos << "requestInventoryAsset("<< item_id <<","<< task_id <<"): Generating request key" << llendl;
300+
LLUUID new_item_id=LLUUID::generateNewID();
301+
302+
/*
303+
llinfos << "requestInventoryAsset("<< item_id <<","<< task_id <<"): Getting item" << llendl;
304+
LLViewerInventoryItem *item = gInventory.getItem(item_id);
305+
if(!item)
306+
{
307+
LuaError(llformat("Could not find item %s.",item_id.asString()).c_str());
308+
return LLUUID::null;
309+
}
310+
311+
312+
llinfos << "requestInventoryAsset("<< item_id <<","<< task_id <<"): Checking if asset download is allowed" << llendl;
313+
if (!gAgent.allowOperation(PERM_COPY, item->getPermissions(),GP_OBJECT_MANIPULATE) && gAgent.isGodlike())
314+
{
315+
LuaError(llformat("You do not have copy permission on %s %s.",
316+
LLAssetType::lookupHumanReadable(item->getActualType()),
317+
item->getName()).c_str());
318+
return LLUUID::null;
319+
}
320+
*/
321+
llinfos << "requestInventoryAsset("<< item_id <<","<< task_id <<"): Queueing asset request" << llendl;
322+
CB_Args3<LLUUID,LLUUID,LLUUID>(requestInventoryAsset_Event,new_item_id,task_id,item_id);
323+
324+
return new_item_id;
325+
}

indra/newview/LunaLua.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,10 @@ bool operator> (const CB_Base& entry1, const CB_Base& entry2)
254254
void FLLua::execClientEvents()
255255
{
256256
if(!sInstance)
257+
{
258+
llinfos << "LUA isn't running yet." << llendl;
257259
return;
260+
}
258261
if(sInstance->mPendingEvents)
259262
{
260263
lldebugs << __LINE__ << ": Events pending. Iterating through events." << llendl;

0 commit comments

Comments
 (0)